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
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
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'))
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)
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'))
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'))
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)
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)
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)
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)
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)
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)
def connectionLost(self, reason): print 'connection lost' WebSocketClientProtocol.connectionLost(self, reason) self.factory.unregister(self) reactor.callLater(2, self.factory.connect)
def sendMessage(self, payload): self.debugExec() return WebSocketClientProtocol.sendMessage(self, payload)
def __init__(self, adapter=None): WebSocketClientProtocol.__init__(self) self._adapter = adapter if adapter is not None else Broker.get_instance( ).pyadapter
def connectionMade(self): print 'client connection made' WebSocketClientProtocol.connectionMade(self) self.postman.routes.append(self)
def __init__(self, *args, **kwargs): WebSocketClientProtocol.__init__(self, *args, **kwargs) self.fingerprint = "".join( random.choice("abcdefghijklmnopqrstuvwxyz") for i in range(16)) stats[self.fingerprint] = {}
def __init__(self): WebSocketClientProtocol.__init__(self) Session.__init__(self) self.restart_downtime = None
def connectionLost(self, reason): print 'client connection made' self.postman.routes.remove(self) WebSocketClientProtocol.connectionLost(self, reason)
def __init__(self, *args, **kwargs): WebSocketClientProtocol.__init__(self, *args, **kwargs) self.fingerprint = "".join(random.choice("abcdefghijklmnopqrstuvwxyz") for i in range(16)) stats[self.fingerprint] = {}
def __init__(self, factory): WebSocketClientProtocol.__init__(self) self.factory=factory
def connectionLost(self, reason): WebSocketClientProtocol.connectionLost(self, reason) self.factory.unregister(self)
def __init__(self): WebSocketClientProtocol.__init__(self) self.pingTask = task.LoopingCall(self.ping) self.gotPong = True
def __init__(self): WebSocketClientProtocol.__init__(self) Adapter.__init__(self) self._subscribe_q = [] self._listener_list = [] # no way to unsubscribe. Subscriptions last
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)
def connectionMade(self): # type: () -> None self.connection_made() WebSocketClientProtocol.connectionMade(self)
def __init__(self, output): WebSocketClientProtocol.__init__(self) self.output = output
def __init__(self, *args, **kwargs): WebSocketClientProtocol.__init__(self, *args, **kwargs) #args needed?
def connectionMade(self): WebSocketClientProtocol.connectionMade(self) DeepstreamProtocol.connectionMade(self)
def __init__(self): WebSocketClientProtocol.__init__(self) self._queue = []
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