コード例 #1
0
ファイル: websocket.py プロジェクト: PromenadeSoftware/Parlay
 def onConnect(self, request):
     WebSocketClientProtocol.onConnect(self, request)
     self._connected.callback(True)
     # flush our subscription requests
     for _fn, topics in self._subscribe_q:
         self.subscribe(_fn, **topics)
     self._subscribe_q = []  # empty the list
コード例 #2
0
ファイル: websocket.py プロジェクト: Python3pkg/Parlay
 def onConnect(self, request):
     WebSocketClientProtocol.onConnect(self, request)
     self._connected.callback(True)
     # flush our subscription requests
     for _fn, topics in self._subscribe_q:
         self.subscribe(_fn, **topics)
     self._subscribe_q = []  # empty the list
コード例 #3
0
 def __init__(self):
     nonlocal app, websocket_id
     PytigonClientProtocolBase.__init__(self)
     WebSocketClientProtocol.__init__(self)
     self.app = app
     self.websocket_id = websocket_id
     app.websockets[websocket_id] = self
     self.status = 0
コード例 #4
0
ファイル: rat-socket.py プロジェクト: FuelRats/pipsqueak
 def onOpen(self):
     WebSocketClientProtocol.onOpen(self)
     MyClientProtocol.bot.say('[Websocket] Successfully openend connection to Websocket!', MyClientProtocol.debug_channel)
     print(
         '[Websocket] Authenticating with message: ' + '{ "action": "authorization", "bearer": "' + MyClientProtocol.bot.config.ratbot.apitoken + '"}')
     self.sendMessage(
         str('{ "action": "authorization", "bearer": "' + MyClientProtocol.bot.config.ratbot.apitoken + '"}').encode(
             'utf-8'))
コード例 #5
0
ファイル: websocket.py プロジェクト: Splawik/pytigon
 def __init__(self):
     nonlocal app, websocket_id
     PytigonClientProtocolBase.__init__(self)
     WebSocketClientProtocol.__init__(self)
     self.app = app
     self.websocket_id = websocket_id
     app.websockets[websocket_id] = self
     self.status = 0
コード例 #6
0
ファイル: rat-socket.py プロジェクト: tivec/pipsqueak
 def onClose(self, wasClean, code, reason):
     # print('onclose')
     MyClientProtocol.bot.say(
         '[RatTracker] Lost connection to RatTracker! Trying to reconnect...'
     )
     MyClientProtocol.bot.say(
         '[Websocket] Closed connection with Websocket. Reason: ' +
         str(reason), MyClientProtocol.debug_channel)
     WebSocketClientProtocol.onClose(self, wasClean, code, reason)
コード例 #7
0
ファイル: rat-socket.py プロジェクト: UncleClapton/pipsqueak
 def onOpen(self):
     WebSocketClientProtocol.onOpen(self)
     MyClientProtocol.bot.say('[Websocket] Successfully openend connection to Websocket!', MyClientProtocol.debug_channel)
     #print(
     #    '[Websocket] Authenticating with message: ' + '{ "action": "authorization", "bearer": "' + MyClientProtocol.bot.config.ratbot.apitoken + '"}')
     #self.sendMessage(
         #str('{ "action": "authorization", "bearer": "' + MyClientProtocol.bot.config.ratbot.apitoken + '"}').encode(
         #    'utf-8'))
     print("[Websocket] onOpen received, sending rattracker sub")
     self.sendMessage(str('{ "action":["stream","subscribe"], "id":"0xDEADBEEF" }').encode('utf-8'))
コード例 #8
0
ファイル: rat-socket.py プロジェクト: tivec/pipsqueak
 def onOpen(self):
     WebSocketClientProtocol.onOpen(self)
     MyClientProtocol.bot.say(
         '[Websocket] Successfully openend connection to Websocket!',
         MyClientProtocol.debug_channel)
     print('[Websocket] Authenticating with message: ' +
           '{ "action": "authorization", "bearer": "' +
           MyClientProtocol.bot.config.ratbot.apitoken + '"}')
     self.sendMessage(
         str('{ "action": "authorization", "bearer": "' +
             MyClientProtocol.bot.config.ratbot.apitoken +
             '"}').encode('utf-8'))
コード例 #9
0
 def __init__(self, dirmanager_thread, dirmanager, rlock):
     self.dirmanager_thread = dirmanager_thread
     self.rlock = rlock
     self.dirmanager = dirmanager
     self.is_busy = False
     self.isSending = False
     self.index = 0
     self.START_HEADER = "START_HEADER"
     self.END_HEADER = "END_HEADER"
     self.START_DATA = "START_DATA"
     self.END_DATA = "END_DATA"
     self.FRAGMENT_SIZE = 64
     WebSocketClientProtocol.__init__(self)
     dirmanager_thread.set_sender(self)
コード例 #10
0
ファイル: 17ce_client.py プロジェクト: daidr/17ce_client
 def __init__(self):
     self.handlers = {
         "LoginRt": self.onLoginRt,
         "Pong": self.onPong_,
         "TaskList": self.onTaskList
     }
     self.USERNAME = "******"  # modify to your username(email)
     self.UUID = hex(
         uuid.getnode())[2:-1]  # modify to your uuid or keep default
     self.LOCALIP = "192.168.1.1"  # modify to your local ip (optional)
     self.DNSIP = "127.0.0.1"  # modify to your dns ip (optional)
     self.USERID = 0
     self.NODEID = 0
     self.MONITORRESULT = []
     self.REQTASK = 0
     self.FINISHTASK = 0
     WebSocketClientProtocol.__init__(self)
コード例 #11
0
ファイル: CeCore.py プロジェクト: yuhu87/17ce_client
    def __init__(self):
        self.handlers = {
            "LoginRt": self.onLoginRt,
            "Pong": self.onPong_,
            "TaskList": self.onTaskList
        }

        self.USERNAME = sys.argv[2]
        self.UUID = sys.argv[3]
        self.LOCALIP = sys.argv[4]
        self.DNSIP = sys.argv[5]
        self.USERID = 0
        self.NODEID = 0
        self.MONITORRESULT = []
        self.REQTASK = 0
        self.FINISHTASK = 0
        WebSocketClientProtocol.__init__(self)
コード例 #12
0
ファイル: 17ce_client.py プロジェクト: daidr/17ce_client
 def sendMessage(self,
                 payload,
                 isBinary=False,
                 fragmentSize=None,
                 sync=False,
                 doNotCompress=False):
     payload = json.dumps(payload, ensure_ascii=False).encode('utf8')
     return WebSocketClientProtocol.sendMessage(self, payload, isBinary,
                                                fragmentSize, sync,
                                                doNotCompress)
コード例 #13
0
ファイル: slack.py プロジェクト: bigjust/helga
    def __init__(self, rtm_start_data, *a, **kw):
        BaseClient.__init__(self)

        # Slack prompts users to set up a bot account's name when setting up
        # the API key. So the bot's name is already defined server-side, and we
        # just have to look it up. In fact, we ignore settings.NICK.
        self.nickname = rtm_start_data['self']['name']

        # Additionally, it is just simpler to override the user's
        # COMMAND_PREFIX_BOTNICK setting here, so to reduce the need for manual
        # configuration.
        settings.COMMAND_PREFIX_BOTNICK = '@?' + self.nickname

        # Maps of channel/user id -> name
        channels = (
            (rtm_start_data.get('channels') or []) +
            (rtm_start_data.get('mpims') or []) +
            (rtm_start_data.get('ims') or []) +
            (rtm_start_data.get('groups') or [])
        )

        users = rtm_start_data.get('users') or []

        self._cache_all_channel_names(channels)
        self._cache_all_user_names(users)

        # FIXME: setup reactor recurring tasks to refresh the list of channels/users
        self.refresh_channels = task.LoopingCall(self._cache_all_channel_names)
        self.refresh_users = task.LoopingCall(self._cache_all_user_names)

        self.refresh_channels.start(60, now=False)
        self.refresh_users.start(60, now=False)

        # Check if i'm a bot
        self._i_am_bot = False

        for user in users:
            if user['name'] == self.nickname:
                self._i_am_bot = user['is_bot']
                break

        # With websockets, we'll get replies to messages we attempt to send.
        # Keep track of them in a map of request-id -> message
        self._requests = {}

        return WebSocketClientProtocol.__init__(self, *a, **kw)
コード例 #14
0
    def __init__(self, rtm_start_data, *a, **kw):
        BaseClient.__init__(self)

        # Slack prompts users to set up a bot account's name when setting up
        # the API key. So the bot's name is already defined server-side, and we
        # just have to look it up. In fact, we ignore settings.NICK.
        self.nickname = rtm_start_data['self']['name']

        # Additionally, it is just simpler to override the user's
        # COMMAND_PREFIX_BOTNICK setting here, so to reduce the need for manual
        # configuration.
        settings.COMMAND_PREFIX_BOTNICK = '@?' + self.nickname

        # Maps of channel/user id -> name
        channels = ((rtm_start_data.get('channels') or []) +
                    (rtm_start_data.get('mpims') or []) +
                    (rtm_start_data.get('ims') or []) +
                    (rtm_start_data.get('groups') or []))

        users = rtm_start_data.get('users') or []

        self._cache_all_channel_names(channels)
        self._cache_all_user_names(users)

        # FIXME: setup reactor recurring tasks to refresh the list of channels/users
        self.refresh_channels = task.LoopingCall(self._cache_all_channel_names)
        self.refresh_users = task.LoopingCall(self._cache_all_user_names)

        self.refresh_channels.start(60, now=False)
        self.refresh_users.start(60, now=False)

        # Check if i'm a bot
        self._i_am_bot = False

        for user in users:
            if user['name'] == self.nickname:
                self._i_am_bot = user['is_bot']
                break

        # With websockets, we'll get replies to messages we attempt to send.
        # Keep track of them in a map of request-id -> message
        self._requests = {}

        return WebSocketClientProtocol.__init__(self, *a, **kw)
コード例 #15
0
 def connectionLost(self, reason):
     print 'connection lost'
     WebSocketClientProtocol.connectionLost(self, reason)
     self.factory.unregister(self)
     reactor.callLater(2, self.factory.connect)
コード例 #16
0
 def sendMessage(self, payload):
     self.debugExec()
     return WebSocketClientProtocol.sendMessage(self, payload)
コード例 #17
0
ファイル: cloud_link.py プロジェクト: jedgentry/Parlay
 def __init__(self, adapter=None):
     WebSocketClientProtocol.__init__(self)
     self._adapter = adapter if adapter is not None else Broker.get_instance(
     ).pyadapter
コード例 #18
0
 def connectionMade(self):
     print 'client connection made'
     WebSocketClientProtocol.connectionMade(self)
     self.postman.routes.append(self)
コード例 #19
0
 def __init__(self, *args, **kwargs):
     WebSocketClientProtocol.__init__(self, *args, **kwargs)
     self.fingerprint = "".join(
         random.choice("abcdefghijklmnopqrstuvwxyz") for i in range(16))
     stats[self.fingerprint] = {}
コード例 #20
0
 def __init__(self):
     WebSocketClientProtocol.__init__(self)
     Session.__init__(self)
     self.restart_downtime = None
コード例 #21
0
 def connectionLost(self, reason):
     print 'client connection made'
     self.postman.routes.remove(self)
     WebSocketClientProtocol.connectionLost(self, reason)
コード例 #22
0
 def connectionLost(self, reason):
   print 'connection lost'
   WebSocketClientProtocol.connectionLost(self, reason)
   self.factory.unregister(self)
   reactor.callLater(2, self.factory.connect)
コード例 #23
0
ファイル: benchmark.py プロジェクト: Krukov/channels
 def __init__(self, *args, **kwargs):
     WebSocketClientProtocol.__init__(self, *args, **kwargs)
     self.fingerprint = "".join(random.choice("abcdefghijklmnopqrstuvwxyz") for i in range(16))
     stats[self.fingerprint] = {}
コード例 #24
0
 def __init__(self, factory):
     WebSocketClientProtocol.__init__(self)
     self.factory=factory
コード例 #25
0
 def connectionLost(self, reason):
     WebSocketClientProtocol.connectionLost(self, reason)
     self.factory.unregister(self)
コード例 #26
0
ファイル: car_main.py プロジェクト: OpenLuna/picar
 def __init__(self):
     WebSocketClientProtocol.__init__(self)
     self.pingTask = task.LoopingCall(self.ping)
     self.gotPong = True
コード例 #27
0
ファイル: websocket.py プロジェクト: Python3pkg/Parlay
 def __init__(self):
     WebSocketClientProtocol.__init__(self)
     Adapter.__init__(self)
     self._subscribe_q = []
     self._listener_list = []  # no way to unsubscribe. Subscriptions last
コード例 #28
0
ファイル: rat-socket.py プロジェクト: FuelRats/pipsqueak
 def onClose(self, wasClean, code, reason):
     # print('onclose')
     MyClientProtocol.bot.say('[RatTracker] Lost connection to RatTracker! Trying to reconnect...')
     MyClientProtocol.bot.say('[Websocket] Closed connection with Websocket. Reason: ' + str(reason), MyClientProtocol.debug_channel)
     WebSocketClientProtocol.onClose(self, wasClean, code, reason)
コード例 #29
0
	def connectionMade(self):
		# type: () -> None

		self.connection_made()
		WebSocketClientProtocol.connectionMade(self)
コード例 #30
0
 def __init__(self, output):
     WebSocketClientProtocol.__init__(self)
     self.output = output
コード例 #31
0
	def __init__(self, *args, **kwargs):
		WebSocketClientProtocol.__init__(self, *args, **kwargs) #args needed?
コード例 #32
0
ファイル: websocket.py プロジェクト: PromenadeSoftware/Parlay
 def __init__(self):
     WebSocketClientProtocol.__init__(self)
     Adapter.__init__(self)
     self._subscribe_q = []
     self._listener_list = []  # no way to unsubscribe. Subscriptions last
コード例 #33
0
 def connectionMade(self):
     WebSocketClientProtocol.connectionMade(self)
     DeepstreamProtocol.connectionMade(self)
コード例 #34
0
ファイル: car_main.py プロジェクト: OpenLuna/picar
 def __init__(self):
     WebSocketClientProtocol.__init__(self)
     self.pingTask = task.LoopingCall(self.ping)
     self.gotPong = True
コード例 #35
0
 def __init__(self):
     WebSocketClientProtocol.__init__(self)
     self._queue = []
コード例 #36
0
 def __init__(self):
     WebSocketClientProtocol.__init__(self)
     self._queue = []
コード例 #37
0
ファイル: main.py プロジェクト: RyanHope/pyagar
 def __init__(self, spectate, *args, **kwargs):
     WebSocketClientProtocol.__init__(self, *args, **kwargs)
     self.player = Player()
     self.ingame = False
     self.re_pattern = re.compile(u'[^\u0000-\uD7FF\uE000-\uFFFF]', re.UNICODE)
     self.spectate = spectate