示例#1
0
	def connectionLost(self, reason):
		if DEBUG >= 1:
			print("WebSocket connection closed: {0}".format(reason))
		WebSocketServerProtocol.connectionLost(self, reason)
		self.factory.unregister(self)
		name.pop(self.peer, None)
		self.sendUsers()
示例#2
0
   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)
示例#3
0
 def connectionLost(self, reason):
     WebSocketServerProtocol.connectionLost(self, reason)
     try:
         namespace = self.getNamespace()
     except NamespaceNotFound:
         pass
     else:
         namespace.client_disconnected(self)
示例#4
0
class ExceptionHandlingTests(unittest.TestCase):
    """
    Tests that we format various exception variations properly during
    connectionLost
    """

    def setUp(self):
        self.factory = WebSocketServerFactory()
        self.proto = WebSocketServerProtocol()
        self.proto.factory = self.factory
        self.proto.log = Mock()

    def tearDown(self):
        for call in [
                self.proto.autoPingPendingCall,
                self.proto.autoPingTimeoutCall,
                self.proto.openHandshakeTimeoutCall,
                self.proto.closeHandshakeTimeoutCall,
        ]:
            if call is not None:
                call.cancel()

    def test_connection_done(self):
        # pretend we connected
        self.proto._connectionMade()

        self.proto.connectionLost(Failure(ConnectionDone()))

        messages = ' '.join([str(x[1]) for x in self.proto.log.mock_calls])
        self.assertTrue('closed cleanly' in messages)

    def test_connection_aborted(self):
        # pretend we connected
        self.proto._connectionMade()

        self.proto.connectionLost(Failure(ConnectionAborted()))

        messages = ' '.join([str(x[1]) for x in self.proto.log.mock_calls])
        self.assertTrue(' aborted ' in messages)

    def test_connection_lost(self):
        # pretend we connected
        self.proto._connectionMade()

        self.proto.connectionLost(Failure(ConnectionLost()))

        messages = ' '.join([str(x[1]) for x in self.proto.log.mock_calls])
        self.assertTrue(' was lost ' in messages)

    def test_connection_lost_arg(self):
        # pretend we connected
        self.proto._connectionMade()

        self.proto.connectionLost(Failure(ConnectionLost("greetings")))

        messages = ' '.join([str(x[1]) + str(x[2]) for x in self.proto.log.mock_calls])
        self.assertTrue(' was lost ' in messages)
        self.assertTrue('greetings' in messages)
 def connectionLost(self, reason):
     """
     При аварийном завершении коннекта
     :param reason:
     :return:
     """
     #проверяется список приконекченных клиентов,
     #каждый клиент - одна вкладка
     if self.factory.clients[self] != '':
         #если не пуст список
         #json с новым списком клиентов и инфой, что один отдисконнектился
         disconnect_msg = json.dumps({'user_disconnect':
                                      self.factory.clients[self]})
         #возвращаем инфу клиенту о дисконекте
         self.factory.broadcast(disconnect_msg, self)
     #удаляем объект, чистим следы
     self.factory.remove_game(self)
     self.factory.unregister(self)
     #посылаем общее сообщение, что коннект завершен с причиной
     WebSocketServerProtocol.connectionLost(self, reason)
示例#6
0
 def connectionLost(self, reason):
     logger.debug('Connection lost: %s' % reason)
     WebSocketServerProtocol.connectionLost(self, reason)
     self.factory.unregister(self)
示例#7
0
 def connectionLost(self, reason):
     WebSocketServerProtocol.connectionLost(self, reason)
     #super(WebSocketProcessOutputterThing, self).connectionLost(self, reason)
     self.factory.unregister(self)
示例#8
0
	def connectionLost(self,reason):
		print "CONNECTION LOST %s" % reason
		WebSocketServerProtocol.connectionLost(self,reason)
		self.factory.unregister(self)
示例#9
0
文件: republisher.py 项目: ahaas/smap
 def connectionLost(self, *args):
     if self.client:
         self.client.finished.errback(*args)
     WebSocketServerProtocol.connectionLost(self, *args)
示例#10
0
 def connectionLost(self, reason):
   self.logout()
   BaseProtocol.connectionLost(self, reason)
示例#11
0
 def connectionLost(self,
                    reason):  # todo deconnect clients if server crashes
     WebSocketServerProtocol.connectionLost(self, reason)
     self.factory.unregister(self)
示例#12
0
 def connectionLost(self, reason):
     WebSocketServerProtocol.connectionLost(self, reason)
     self.factory.deregister(self)
示例#13
0
 def connectionLost(self, reason):
     WebSocketServerProtocol.connectionLost(self, reason)
     self.log.info('Client ' + self.peer + "@" + self.clientLibrary() +
                   ' on ' + self.clientPlatform() + " disconnected")
     self.factory.unregister(self)
     self._state = ClientState.disconnected
示例#14
0
 def connectionLost(self, reason):
     WebSocketServerProtocol.connectionLost(self, reason)
     self.factory.unregister(self)
     self.factory.broadcastChatUsers()
示例#15
0
 def connectionLost(self, reason):
     self.factory.lostConnection(self)
     WebSocketServerProtocol.connectionLost(self, reason)
示例#16
0
	def connectionLost(self,reason):
		self.factory.forward("stop",False,self)
		self.factory.stopProducing(self)
		WebSocketServerProtocol.connectionLost(self,reason)
		self.factory.unregister(self)
示例#17
0
 def connectionLost(self, reason):
     WebSocketServerProtocol.connectionLost(self, reason)
     if hasattr(self, "trans_sess"):
         self.trans_sess.stop()
 def connectionLost(self,reason): 
     #logger.debug("connectionLost() called for reason: ",reason)
     WebSocketServerProtocol.connectionLost(self,reason) 
     self.factory.unregister(self.feed_id,self.format,self.isFront) 
示例#19
0
	def connectionLost(self,reason):
		#self.factory.sendCommand("pause",False,self)
		self.deletePlaylist()
		self.deleteSegments()
		WebSocketServerProtocol.connectionLost(self,reason)
		self.factory.unregister(self)
 def connectionLost(self, reason):
     WebSocketServerProtocol.connectionLost(self, reason)
     Protocol.connectionLost(self, reason)
示例#21
0
 def connectionLost(self, reason):
     print("WebSocket connection lost: {0}".format(reason))
     WebSocketServerProtocol.connectionLost(self, reason)
     self.factory.unregister(self)
示例#22
0
 def connectionLost(self, reason):
     """Called when websocket client is disconnected"""
     self.factory.unregister(self)
     WebSocketServerProtocol.connectionLost(self, reason)
示例#23
0
 def connectionLost(self, reason):
     WebSocketServerProtocol.connectionLost(self, reason)
     BroadcastServerFactory.unregister(self)
示例#24
0
    def connectionLost(self,reason):
		WebSocketServerProtocol.connectionLost(self,reason)
		self.factory.unregister(self)
		print("Websocket connection lost: {0}".format(reason))
示例#25
0
文件: serve.py 项目: afcarl/earmark
 def connectionLost(self, reason):
     WebSocketServerProtocol.connectionLost(self, reason)
     if hasattr(self, "trans_sess"):
         self.trans_sess.stop()
 def connectionLost(self, reason):
     """ Overridden to ensure that we aren't attempting to
     send notifications on broken connections.
     """
     WebSocketServerProtocol.connectionLost(self, reason)
     self.factory.unregister(self)
示例#27
0
 def connectionLost(self, reason):
     self.factory.forward("stop", False, self)
     self.factory.stopProducing(self)
     WebSocketServerProtocol.connectionLost(self, reason)
     self.factory.unregister(self)
示例#28
0
 def connectionLost(self, reason):
     #self.factory.sendCommand("pause",False,self)
     self.deletePlaylist()
     self.deleteSegments()
     WebSocketServerProtocol.connectionLost(self, reason)
     self.factory.unregister(self)
示例#29
0
 def connectionLost(self, reason):
     WebSocketServerProtocol.connectionLost(self, reason)
     if hasattr(self, 'player'):
         self.player.destroy()
示例#30
0
 def connectionLost(self, reason):
     self.deletePlaylist()
     WebSocketServerProtocol.connectionLost(self, reason)
     self.factory.unregister(self)
示例#31
0
 def connectionLost(self, reason):
     self.factory.lostConnection(self)
     WebSocketServerProtocol.connectionLost(self, reason)
示例#32
0
 def onClose(self, wasClean, code, reason):
     reason.value = "Client closed connection"
     WebSocketServerProtocol.connectionLost(self, reason)
     self.factory.unregister(self)
     print("Connection to client closed!")
示例#33
0
 def connectionLost(self,reason):
     logger.info("Connection lost %s" % reason)
     WebSocketServerProtocol.connectionLost(self, reason)
     self.factory.unregister(self)
示例#34
0
 def connectionLost(self, *args):
     if self.client:
         self.client.finished.errback(*args)
     WebSocketServerProtocol.connectionLost(self, *args)
 def connectionLost(self, reason):
     """Log when the connection is lost"""
     self._log('Connection lost')
     WebSocketServerProtocol.connectionLost(self, reason)
示例#36
0
	def connectionLost(self,reason):
		self.do_feed = False
		self.factory.streamer.stopProducing()
		WebSocketServerProtocol.connectionLost(self,reason)
		self.factory.unregister(self)
示例#37
0
 def connectionLost(self, reason):
     WebSocketServerProtocol.connectionLost(self, reason)
     if hasattr(self, 'player'):
         self.player.destroy()
 def connectionLost(self, reason):
     WebSocketServerProtocol.connectionLost(self, reason)
     #super(WebSocketProcessOutputterThing, self).connectionLost(self, reason)
     self.factory.unregister(self)
示例#39
0
文件: server.py 项目: si618/pi-time
 def connectionLost(self, reason):
     logger.debug('Connection lost: %s' % reason)
     WebSocketServerProtocol.connectionLost(self, reason)
     self.factory.unregister(self)
示例#40
0
 def connectionLost(self, reason):
     WebSocketServerProtocol.connectionLost(self, reason)
     self.factory.unregister(self)
     self.redis.delete(self.peer)
示例#41
0
 def connectionLost(self, reason):
     WebSocketServerProtocol.connectionLost(self, reason)
     self.factory.unregister(self)
     bridge.socketIn.close()
     bridge.socketOut.close()
 def connectionLost(self, reason):
     WebSocketServerProtocol.connectionLost(self, reason)
 def connectionLost(self, reason):
   WebSocketServerProtocol.connectionLost(self, reason)
   self.factory.unregister(self)
示例#44
0
 def connectionLost(self, reason):
     print 'connectionLost'
     WebSocketServerProtocol.connectionLost(self, reason)
     self.factory.unregister(self)
示例#45
0
 def connectionLost(self, reason):
     self.do_feed = False
     self.factory.streamer.stopProducing()
     WebSocketServerProtocol.connectionLost(self, reason)
     self.factory.unregister(self)
示例#46
0
 def connectionLost(self, reason):
     WebSocketServerProtocol.connectionLost(self, reason)
     self.factory.unregister(self)
     world.rooms[world.players[self.name].location].remove_entity(
         world.players[self.name])
     world.rooms[world.players[self.name].location].alert_exit(self.name)