本文整理汇总了Python中autobahn.websocket.WebSocketServerProtocol类的典型用法代码示例。如果您正苦于以下问题:Python WebSocketServerProtocol类的具体用法?Python WebSocketServerProtocol怎么用?Python WebSocketServerProtocol使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WebSocketServerProtocol类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: connectionLost
def connectionLost(self, reason):
WebSocketServerProtocol.connectionLost(self, reason)
envelopes = handler.unregisterClient(self)
self.factory.sendEnvelopes(envelopes)
self.factory.unregister(self)
示例2: connectionLost
def connectionLost(self, reason):
WebSocketServerProtocol.connectionLost(self, reason)
if self.room:
self.factory.broadcast(self.room.setOnline(self.name, False), self.room.name, self)
if self.room.empty():
self.factory.roomEmpty(self.room.name)
self.factory.unregister(self)
示例3: connectionLost
def connectionLost(self, reason):
try:
self.factory.clients.remove(self)
except ValueError:
# client doesn't exist, pass
pass
WebSocketServerProtocol.connectionLost(self, reason)
示例4: sendMessage
def sendMessage(self, payload, binary=False):
if isinstance(payload, dict) and not binary:
msg = json.dumps(payload)
else:
msg = json.dumps({'message': payload})
WebSocketServerProtocol.sendMessage(self, msg, binary=binary)
示例5: connectionLost
def connectionLost(self, reason):
WebSocketServerProtocol.connectionLost(self, reason)
self.factory.stats.trackOctetsWireIn(self.trafficStats.preopenIncomingOctetsWireLevel + \
self.trafficStats.incomingOctetsWireLevel)
self.factory.stats.trackOctetsWireOut(self.trafficStats.preopenOutgoingOctetsWireLevel + \
self.trafficStats.outgoingOctetsWireLevel)
示例6: onMessageBegin
def onMessageBegin(self, opcode):
WebSocketServerProtocol.onMessageBegin(self, opcode)
if COMPUTE_HASH:
self.sha256 = hashlib.sha256()
else:
self.sha256 = None
self.count = 0
self.received = 0
self.next = BATCH_SIZE
示例7: connectionLost
def connectionLost(self, reason):
WebSocketServerProtocol.connectionLost(self, reason)
if self.connected:
self.room.user_disconnect(self.user_session)
self.connected = False
self.user_session = None
self.room = None
示例8: connectionLost
def connectionLost(self, reason):
"""
Unregister each client (self) as it disconnects.
"""
WebSocketServerProtocol.connectionLost(self, reason)
self.factory.unregister(self)
示例9: onClose
def onClose(self, wasClean, code, reason):
"""Connect closed, cleanup"""
# base logs
WebSocketServerProtocol.onClose(self, wasClean, code, reason)
if self.client is None:
if self.debug:
log.msg("MSP430ServerProtocol.onClose - No Client type")
return
self.client.onClose(wasClean, code, reason)
示例10: onClose
def onClose(self, wasClean, code, reason):
# logline("ONCLOSE: %s" % reason)
WebSocketServerProtocol.onClose(self, wasClean, code, reason)
delkey = None
for key in connections:
if connections[key]['wsh'] == self:
delkey = key
if delkey:
del connections[delkey]
logline("jsdb client %s disconnected." % delkey)
示例11: connectionMade
def connectionMade(self):
self.configuration = self.configuration
WebSocketServerProtocol.connectionMade(self)
self.lisaclientfactory = libs.LisaClientFactory(self)
if self.configuration['enable_secure_mode']:
self.conn = reactor.connectSSL(self.configuration['lisa_url'], self.configuration['lisa_engine_port_ssl'],
self.lisaclientfactory, CtxFactory()
)
else:
self.conn = reactor.connectTCP(self.configuration['lisa_url'],
self.configuration['lisa_engine_port'], self.lisaclientfactory)
示例12: connectionLost
def connectionLost(self, reason):
WebSocketServerProtocol.connectionLost(self, reason)
try:
del self.factory.posdict[self.peerstr]
except KeyError:
pass
try:
del self.factory.statedict[self.peerstr]
except KeyError:
pass
self.factory.unregister(self)
示例13: sendMessage
def sendMessage(self, msg):
""" This method is called by the User instance to send a message to the
robot.
@param msg: Message which should be sent
"""
uriBinary, msgURI = recursiveBinarySearch(msg)
WebSocketServerProtocol.sendMessage(self, json.dumps(msgURI))
for binData in uriBinary:
WebSocketServerProtocol.sendMessage(self,
binData[0] + binData[1].getvalue(), binary=True)
示例14: connectionLost
def connectionLost(self, reason):
global serial_port
global serial_device
global serial_baudrate
if not self.connection_invalid:
print "Disconnect Message Received"
if serial_port != None:
oldserial = serial_port
serial_port = None
serial_device = None
serial_baudrate = None
self.read_thread.stop()
self.read_thread.join()
oldserial.close()
WebSocketServerProtocol.connectionLost(self, reason)
示例15: sendMessage
def sendMessage(self, msg):
""" Internally used method to send a message to the robot.
Should not be used from outside the Protocol; instead use the
methods 'sendDataMessage' or 'sendErrorMessage'.
(Overwrites method from autobahn.websocket.WebSocketServerProtocol)
@param msg: Message which should be sent.
"""
uriBinary, msgURI = recursiveBinarySearch(msg)
WebSocketServerProtocol.sendMessage(self, json.dumps(msgURI))
for binData in uriBinary:
WebSocketServerProtocol.sendMessage(self,
binData[0] + binData[1].getvalue(), binary=True)