53 state_negotiation =
"negotiation"
61 def __init__(self, mode, codecs_lst, fp=None, id=""):
65 self.
codecscodecs = codecs_lst
67 self.
codecscodecs = atlas.codecs.ids
70 else: self.
idid = mode
74 self.
send_strsend_str =
"ATLAS %s\n" % self.
idid
86 def get_send_str(self):
91 def __call__(self, str=""):
92 if str: self.
strstr = self.
strstr + str
101 def process_line(self, line):
102 raise AttributeError(
"User NegotiationClient or NegotiationServer instead")
104 def collect_until_newline(self):
106 ok = string.find(self.
strstr,
"\n")<0
108 ok = read_str = self.
fpfp.recv(1)
109 self.
strstr = self.
strstr + read_str
110 ok = read_str
and string.find(self.
strstr,
"\n")<0
112 newline_pos = string.find(self.
strstr,
"\n")
114 res = self.
strstr[:newline_pos]
115 self.
strstr = self.
strstr[newline_pos+1:]
118 def iwill(self, codecs):
119 return string.join([
"IWILL %s\n" % c
for c
in codecs],
"") +
'\n'
121 def ican(self, codecs):
122 return string.join([
"ICAN %s\n" % c
for c
in codecs],
"") +
'\n'
124 def analyse_line_codecs(self, line):
125 modes = string.split(line)
126 if len(modes)>=2
and modes[0]==
"ICAN":
143 def __init__(self, codecs=(), fp=
None, id=
""):
144 Negotiation.__init__(self,
"server", codecs, fp, id)
146 def process_line(self, line):
148 if line[:5]!=
"ATLAS":
149 return self.
failfail(
"Huh?\n\n")
156 if len(modes)>=2
and modes[0]==
"ICAN" and \
157 modes[1]
in self.
codecscodecs:
163 if not line
or line==
"\r":
173 def __init__(self, codecs=(), fp=
None, id=
""):
174 Negotiation.__init__(self,
"client", codecs, fp, id)
176 def process_line(self, line):
178 if line[:5]!=
"ATLAS":
179 return self.
failfail(
"Huh?\n\n")
185 return self.
failfail(
"")
187 if len(modes)>=2
and modes[0]==
"IWILL" and \
188 modes[1]
in self.
codecscodecs:
def process_line(self, line)
def collect_until_newline(self)
def analyse_line_codecs(self, line)