|
@@ -29,7 +29,6 @@ class PlayerProtocol(protocol.Protocol):
|
|
|
self.queue_twgs = self.factory.queue_twgs
|
|
|
self.queue_twgs.get().addCallback(self.serverDataReceived)
|
|
|
|
|
|
-
|
|
|
def serverDataReceived(self, chunk):
|
|
|
|
|
|
|
|
@@ -43,7 +42,7 @@ class PlayerProtocol(protocol.Protocol):
|
|
|
else:
|
|
|
|
|
|
if self.user is None:
|
|
|
- self.buffer += chunk.decode("utf-8", 'ignore')
|
|
|
+ self.buffer += chunk.decode("utf-8", "ignore")
|
|
|
|
|
|
|
|
|
|
|
@@ -59,16 +58,16 @@ class PlayerProtocol(protocol.Protocol):
|
|
|
self.buffer = ""
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
self.transport.write(chunk)
|
|
|
self.queue_twgs.get().addCallback(self.serverDataReceived)
|
|
@@ -103,7 +102,7 @@ class PlayerProtocol(protocol.Protocol):
|
|
|
|
|
|
|
|
|
class GlueFactory(protocol.ClientFactory):
|
|
|
-
|
|
|
+
|
|
|
maxDelay = 10
|
|
|
protocol = PlayerProtocol
|
|
|
|
|
@@ -151,11 +150,19 @@ class TWGSServer(protocol.Protocol):
|
|
|
if chunk is False:
|
|
|
self.transport.loseConnection()
|
|
|
else:
|
|
|
- self.buffer += chunk.decode('utf-8', 'ignore')
|
|
|
+ self.buffer += chunk.decode("utf-8", "ignore")
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ while "\x08" in self.buffer:
|
|
|
+ part = self.buffer.partition("\x08")
|
|
|
+ self.buffer = part[0][:-1] + part[2]
|
|
|
|
|
|
- while '\n' in self.buffer:
|
|
|
- part = self.buffer.partition('\n')
|
|
|
- line = part[0].replace('\r', '')
|
|
|
+
|
|
|
+
|
|
|
+ while "\n" in self.buffer:
|
|
|
+ part = self.buffer.partition("\n")
|
|
|
+ line = part[0].replace("\r", "")
|
|
|
self.gotLine(line)
|
|
|
self.buffer = part[2]
|
|
|
|