cleanup
This commit is contained in:
parent
e7b7b4cd6b
commit
09e46d3713
|
@ -416,8 +416,6 @@ class Usage(ServerBase, unittest.TestCase):
|
||||||
def test_one_happy_one_jilted(self):
|
def test_one_happy_one_jilted(self):
|
||||||
p1 = self.new_protocol()
|
p1 = self.new_protocol()
|
||||||
p2 = self.new_protocol()
|
p2 = self.new_protocol()
|
||||||
print(dir(p1.factory))
|
|
||||||
return
|
|
||||||
|
|
||||||
token1 = b"\x00"*32
|
token1 = b"\x00"*32
|
||||||
side1 = b"\x01"*8
|
side1 = b"\x01"*8
|
||||||
|
@ -427,7 +425,6 @@ class Usage(ServerBase, unittest.TestCase):
|
||||||
p2.send(handshake(token1, side=side2))
|
p2.send(handshake(token1, side=side2))
|
||||||
self.flush()
|
self.flush()
|
||||||
|
|
||||||
print("shouldn't be events yet")
|
|
||||||
self.assertEqual(self._usage.events, []) # no events yet
|
self.assertEqual(self._usage.events, []) # no events yet
|
||||||
|
|
||||||
p1.send(b"\x00" * 13)
|
p1.send(b"\x00" * 13)
|
||||||
|
@ -464,8 +461,6 @@ class Usage(ServerBase, unittest.TestCase):
|
||||||
p1c.disconnect()
|
p1c.disconnect()
|
||||||
self.flush()
|
self.flush()
|
||||||
|
|
||||||
for x in self._usage.events:
|
|
||||||
print(x)
|
|
||||||
self.assertEqual(len(self._usage.events), 1, self._usage)
|
self.assertEqual(len(self._usage.events), 1, self._usage)
|
||||||
self.assertEqual(self._usage.events[0]["mood"], "lonely")
|
self.assertEqual(self._usage.events[0]["mood"], "lonely")
|
||||||
|
|
||||||
|
|
|
@ -56,8 +56,7 @@ class TransitConnection(LineReceiver):
|
||||||
"""
|
"""
|
||||||
if self._buddy is not None:
|
if self._buddy is not None:
|
||||||
log.msg("buddy_disconnected {}".format(self._buddy.get_token()))
|
log.msg("buddy_disconnected {}".format(self._buddy.get_token()))
|
||||||
# XXX if our buddy is a WebSocket, this isn't the right way?
|
self._buddy._client.disconnect()
|
||||||
self._buddy._client.transport.loseConnection()
|
|
||||||
self._buddy = None
|
self._buddy = None
|
||||||
|
|
||||||
def connectionMade(self):
|
def connectionMade(self):
|
||||||
|
@ -76,9 +75,10 @@ class TransitConnection(LineReceiver):
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def tracer(oldstate, theinput, newstate):
|
if False:
|
||||||
print("TRACE: {}: {} --{}--> {}".format(id(self), oldstate, theinput, newstate))
|
def tracer(oldstate, theinput, newstate):
|
||||||
self._state.set_trace_function(tracer)
|
print("TRACE: {}: {} --{}--> {}".format(id(self), oldstate, theinput, newstate))
|
||||||
|
self._state.set_trace_function(tracer)
|
||||||
|
|
||||||
def lineReceived(self, line):
|
def lineReceived(self, line):
|
||||||
"""
|
"""
|
||||||
|
@ -133,16 +133,8 @@ class TransitConnection(LineReceiver):
|
||||||
# XXX this probably resulted in a log message we've not refactored yet
|
# XXX this probably resulted in a log message we've not refactored yet
|
||||||
# self.factory.transitFinished(self, self._got_token, self._got_side,
|
# self.factory.transitFinished(self, self._got_token, self._got_side,
|
||||||
# self.describeToken())
|
# self.describeToken())
|
||||||
# XXX describeToken -> self._state.get_token()
|
|
||||||
|
|
||||||
|
|
||||||
# XXX multiple-inheritance sucks...
|
|
||||||
# ("Transit" wants to be "the factory" but the base class is slightly
|
|
||||||
# different for websocket versus "normal" socket .. so maybe we need
|
|
||||||
# to make Transit *not* the factory directly?)
|
|
||||||
|
|
||||||
##WebSocketServerFactory):#protocol.ServerFactory):
|
|
||||||
|
|
||||||
class Transit(object):
|
class Transit(object):
|
||||||
"""
|
"""
|
||||||
I manage pairs of simultaneous connections to a secondary TCP port,
|
I manage pairs of simultaneous connections to a secondary TCP port,
|
||||||
|
@ -179,7 +171,6 @@ class Transit(object):
|
||||||
MAXLENGTH = 10*MB
|
MAXLENGTH = 10*MB
|
||||||
# TODO: unused
|
# TODO: unused
|
||||||
MAXTIME = 60*SECONDS
|
MAXTIME = 60*SECONDS
|
||||||
## protocol = TransitConnection
|
|
||||||
|
|
||||||
def __init__(self, usage, get_timestamp):
|
def __init__(self, usage, get_timestamp):
|
||||||
self.active_connections = ActiveConnections()
|
self.active_connections = ActiveConnections()
|
||||||
|
@ -236,7 +227,6 @@ class WebSocketTransitConnection(WebSocketServerProtocol):
|
||||||
"""
|
"""
|
||||||
if self._buddy is not None:
|
if self._buddy is not None:
|
||||||
log.msg("buddy_disconnected {}".format(self._buddy.get_token()))
|
log.msg("buddy_disconnected {}".format(self._buddy.get_token()))
|
||||||
# XXX if our buddy is tcp this is wrong
|
|
||||||
self._buddy._client.disconnect()
|
self._buddy._client.disconnect()
|
||||||
self._buddy = None
|
self._buddy = None
|
||||||
|
|
||||||
|
@ -252,12 +242,12 @@ class WebSocketTransitConnection(WebSocketServerProtocol):
|
||||||
self.factory.transit.usage,
|
self.factory.transit.usage,
|
||||||
)
|
)
|
||||||
|
|
||||||
def tracer(oldstate, theinput, newstate):
|
if False:
|
||||||
print("WSTRACE: {}: {} --{}--> {}".format(id(self), oldstate, theinput, newstate))
|
def tracer(oldstate, theinput, newstate):
|
||||||
self._state.set_trace_function(tracer)
|
print("WSTRACE: {}: {} --{}--> {}".format(id(self), oldstate, theinput, newstate))
|
||||||
|
self._state.set_trace_function(tracer)
|
||||||
|
|
||||||
def onOpen(self):
|
def onOpen(self):
|
||||||
# print("onOpen")
|
|
||||||
self._state.connection_made(self)
|
self._state.connection_made(self)
|
||||||
|
|
||||||
def onMessage(self, payload, isBinary):
|
def onMessage(self, payload, isBinary):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user