當前位置: 首頁>>代碼示例>>Python>>正文


Python socketIO_client.SocketIO方法代碼示例

本文整理匯總了Python中socketIO_client.SocketIO方法的典型用法代碼示例。如果您正苦於以下問題:Python socketIO_client.SocketIO方法的具體用法?Python socketIO_client.SocketIO怎麽用?Python socketIO_client.SocketIO使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在socketIO_client的用法示例。


在下文中一共展示了socketIO_client.SocketIO方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: establishConnection

# 需要導入模塊: import socketIO_client [as 別名]
# 或者: from socketIO_client import SocketIO [as 別名]
def establishConnection(self):

		for i in range(self.retriesAllowed):
			self.socketIO = None
			try:
				self.socketIO = SocketIO(self.playerComms.ipaddr, self.playerComms.port)

				self.socketIO.on('pushQueue', self.pushQueue)
				self.socketIO.on('pushState', self.pushState)

#				self.socketIO.on(u'pushState', self.on_state_response)
#				self.socketIO.on(u'pushQueue', self.on_queue_response)

				# Request initial values
				self.socketIO.emit(u'getQueue')
				self.socketIO.emit(u'getState')
				return
			except Exception as ex:
				del(self.socketIO)
				logger.exception('Error connecting on attempt {0}'.format(i+1))
				time.sleep(0.5)
				pass
		raise RuntimeError('Unable to connect') 
開發者ID:dhrone,項目名稱:pydPiper,代碼行數:25,代碼來源:mdsVolumio2.py

示例2: run

# 需要導入模塊: import socketIO_client [as 別名]
# 或者: from socketIO_client import SocketIO [as 別名]
def run(self):

		logging.debug(u"Volumio 2 musicdata service starting")
		logging.debug(u"Connecting to Volumio Web Service on {0}:{1}".format(self.server, self.port))

		with SocketIO(self.server, self.port) as socketIO:
			logging.debug(u"Connected to Volumio Web Service")
			self.socketIO = socketIO
			socketIO.on(u'pushState', self.on_state_response)
			socketIO.on(u'pushMultiRoomDevices', self.on_multiroomdevices_response)
			socketIO.on(u'pushQueue', self.on_queue_response)
			socketIO.emit(u'GetState', on_GetState_response)

			# Request initial values
			socketIO.emit(u'getQueue', '')
			socketIO.emit(u'getState', '')

			while not self.exitapp[0]:
				socketIO.wait_for_callbacks(seconds=20)
				socketIO.emit(u'getQueue', '')
				socketIO.emit(u'getState', '') 
開發者ID:dhrone,項目名稱:pydPiper,代碼行數:23,代碼來源:musicdata_volumio2.py

示例3: init

# 需要導入模塊: import socketIO_client [as 別名]
# 或者: from socketIO_client import SocketIO [as 別名]
def init():
    """
    Init configuration for SocketIO client.

    Returns:
        Event client that will be able to set listeners.
    """
    from socketIO_client import SocketIO, BaseNamespace
    from . import get_event_host
    from gazu.client import make_auth_header

    path = get_event_host()
    socketIO = SocketIO(path, None, headers=make_auth_header())
    main_namespace = socketIO.define(BaseNamespace, "/events")
    socketIO.main_namespace = main_namespace
    socketIO.on('error', connect_error)
    return socketIO 
開發者ID:cgwire,項目名稱:gazu,代碼行數:19,代碼來源:events.py

示例4: startListenForMessengerServer

# 需要導入模塊: import socketIO_client [as 別名]
# 或者: from socketIO_client import SocketIO [as 別名]
def startListenForMessengerServer():
    global messengerSocket

    cookie = getMessengerAuthToken()

    if not cookie.status_code == 200:
        log.error('ERROR : Messenger username / password rejected by server')
        sys.exit()

    messengerSocket = SocketIO('https://%s' % messengerHost, messengerPort, LoggingNamespace, cookies={'connect.sid': cookie.cookies['connect.sid']}, transports='websocket')

    log.info("Connected to messenger chat socket.io")
    messengerSocket.on('connect', onHandleMessengerConnect)
    messengerSocket.on('reconnect', onHandleMessengerReconnect)
    messengerSocket.on('disconnect', onHandleMessengerDisconnect)

    watchdog.start("MessengerServerListen", waitForMessengerServer)
    return messengerSocket 
開發者ID:letsRobot,項目名稱:letsrobot,代碼行數:20,代碼來源:networking.py

示例5: watch_mempool

# 需要導入模塊: import socketIO_client [as 別名]
# 或者: from socketIO_client import SocketIO [as 別名]
def watch_mempool(crypto, callback=lambda tx: print(tx['txid']), verbose=False):
    from socketIO_client import SocketIO
    if verbose:
        import logging
        logging.getLogger('socketIO-client').setLevel(logging.DEBUG)
        logging.basicConfig()

    services = get_optimal_services(crypto, 'address_balance')

    for service in services:
        socketio_url = service.socketio_url
        if not socketio_url:
            continue
        try:
            socketIO = SocketIO(socketio_url, verify=False,) # namespace=LoggingNamespace)
            socketIO.emit('subscribe', 'inv');
            socketIO.on('tx', callback)
            socketIO.wait()
        except KeyboardInterrupt:
            return
        except:
            print("failed") 
開發者ID:priestc,項目名稱:moneywagon,代碼行數:24,代碼來源:__init__.py

示例6: __init__

# 需要導入模塊: import socketIO_client [as 別名]
# 或者: from socketIO_client import SocketIO [as 別名]
def __init__(self, bot):
        self.bot = bot
        self.host, port_str = self.bot.config.websocket_server_url.split(':')
        self.port = int(port_str)
        self.sio = SocketIO(self.host, self.port)
        self.sio.on(
            'bot:process_request:{}'.format(self.bot.config.username),
            self.on_remote_command
        )
        self.thread = threading.Thread(target=self.process_messages)
        self.logger = logging.getLogger(type(self).__name__) 
開發者ID:PokemonGoF,項目名稱:PokemonGo-Bot,代碼行數:13,代碼來源:websocket_remote_control.py

示例7: __init__

# 需要導入模塊: import socketIO_client [as 別名]
# 或者: from socketIO_client import SocketIO [as 別名]
def __init__(self, bot, url):
        self.bot = bot
        self.host, port_str = url.split(':')
        self.port = int(port_str)
        self.sio = SocketIO(self.host, self.port) 
開發者ID:PokemonGoF,項目名稱:PokemonGo-Bot,代碼行數:7,代碼來源:socketio_handler.py

示例8: create_socket

# 需要導入模塊: import socketIO_client [as 別名]
# 或者: from socketIO_client import SocketIO [as 別名]
def create_socket(server, port):
    socket = SocketIO(server, port)
    socket.on('result', print_result)
    socket.on('server_error', print_server_error)

    return socket 
開發者ID:UFAL-DSG,項目名稱:cloud-asr,代碼行數:8,代碼來源:run_online_recognition.py

示例9: create_sockets

# 需要導入模塊: import socketIO_client [as 別名]
# 或者: from socketIO_client import SocketIO [as 別名]
def create_sockets(server, port, n):
    sockets = []

    for i in range(0, n):
        socket = SocketIO(server, port)
        socket.on('result', print_result(i))
        socket.on('server_error', print_server_error(i))

        sockets.append(socket)

    return sockets 
開發者ID:UFAL-DSG,項目名稱:cloud-asr,代碼行數:13,代碼來源:benchmark_online_recognition.py

示例10: setUp

# 需要導入模塊: import socketIO_client [as 別名]
# 或者: from socketIO_client import SocketIO [as 別名]
def setUp(self):
        self.socketIO = SocketIO('localhost', 8000)
        self.received_responses = 0
        self.expected_responses = 0
        time.sleep(1) 
開發者ID:UFAL-DSG,項目名稱:cloud-asr,代碼行數:7,代碼來源:test_online_recognition.py

示例11: connect

# 需要導入模塊: import socketIO_client [as 別名]
# 或者: from socketIO_client import SocketIO [as 別名]
def connect(self, timeout=None):
        timeout = timeout or 30.0
        with self.lock:
            if self._isConnected():
                raise ValueError("'connect' called when already connected")

        with self.lock:
            t0 = time.time()
            self.connection_status.status = ConnectionStatus.connecting
            while True:
                try:
                    self.socketIO = SocketIO(self.url, wait_for_connection=False)
                    break
                except (TimeoutError, ConnectionError):
                    if time.time() - t0 > timeout:
                        raise
                    time.sleep(0.5)

            self.reactorThread = threading.Thread(target=self.socketIO.wait)

            if isinstance(self.socketIO._transport_instance, WebsocketTransport):
                self.socketIO._transport_instance._connection.lock = threading.Lock()

            self.reactorThread.daemon = True
            self.namespace = self.socketIO.define(self._namespaceFactory, self.path)
            self.reactorThread.start()

            while self.connection_status.status == ConnectionStatus.connecting and \
                    (time.time() - t0 < timeout):
                self.connection_cv.wait(timeout)

        if self.connection_status.status == ConnectionStatus.connected:
            return self

        if self.connection_status.status == ConnectionStatus.connecting:
            message = "Connection timed out"
        else:
            message = self.connection_status.message
        raise pyfora.ConnectionError(message) 
開發者ID:ufora,項目名稱:ufora,代碼行數:41,代碼來源:SocketIoJsonInterface.py

示例12: __init__

# 需要導入模塊: import socketIO_client [as 別名]
# 或者: from socketIO_client import SocketIO [as 別名]
def __init__(self, server_host, server_port, task_config_filename,
                 gpu, ignore_load):
        os.environ['CUDA_VISIBLE_DEVICES'] = '%d' % gpu
        self.task_config = load_json(task_config_filename)
        # self.data_path = self.task_config['data_path']
        print(self.task_config)
        self.ignore_load = ignore_load

        self.local_model = None
        self.dataset = None

        self.log_filename = self.task_config['log_filename']
        # logger
        self.logger = logging.getLogger("client")
        self.fh = logging.FileHandler(os.path.join(log_dir, os.path.basename(self.log_filename)))
        self.fh.setLevel(logging.INFO)
        # create console handler with a higher log level
        self.ch = logging.StreamHandler()
        self.ch.setLevel(logging.ERROR)
        # create formatter and add it to the handlers
        self.formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
        self.fh.setFormatter(self.formatter)
        self.ch.setFormatter(self.formatter)
        # add the handlers to the logger
        self.logger.addHandler(self.fh)
        self.logger.addHandler(self.ch)
        self.logger.info(self.task_config)
        self.sio = SocketIO(server_host, server_port, None, {'timeout': 36000})
        self.register_handles()
        print("sent wakeup")
        self.sio.emit('client_wake_up')
        self.sio.wait()

    ########## Socket Event Handler ########## 
開發者ID:FederatedAI,項目名稱:FATE,代碼行數:36,代碼來源:fl_client.py

示例13: main

# 需要導入模塊: import socketIO_client [as 別名]
# 或者: from socketIO_client import SocketIO [as 別名]
def main():

   global commandArgs
   global robotID
   global appServerSocketIO

   parser = argparse.ArgumentParser(description='start robot control program')

   parser.add_argument('robot_id', help='Robot ID')   
   parser.add_argument('--reverse-ssh-key-file', default='/home/pi/reverse_ssh_key1.pem')
   parser.add_argument('--reverse-ssh-host', default='ubuntu@1.1.1.1')
   
   commandArgs = parser.parse_args()
   print commandArgs
   robotID = commandArgs.robot_id


   print "connecting to app server socket.io"
   appServerSocketIO = SocketIO('robotstreamer.com', 8022, LoggingNamespace)
   print "finished connecting to app server"
   
   appServerSocketIO.on('connect', onHandleAppServerConnect)
   appServerSocketIO.on('reconnect', onHandleAppServerReconnect)
   appServerSocketIO.on('disconnect', onHandleAppServerDisconnect)
    
   appServerSocketIO.on('reverse_ssh_8872381747239', startReverseSshProcess)
   appServerSocketIO.on('end_reverse_ssh_8872381747239', endReverseSshProcess)


   while True:
      appServerSocketIO.wait(seconds=1) 
開發者ID:robotstreamer,項目名稱:robotstreamer,代碼行數:33,代碼來源:old_reverse_ssh.py

示例14: connect

# 需要導入模塊: import socketIO_client [as 別名]
# 或者: from socketIO_client import SocketIO [as 別名]
def connect(self):
        """Initiate the channel we want to start streams from."""
        self.socketIO = SocketIO(
            host=self.iosocket_server,
            port=80,
            resource=self.iosocket_resource,
            proxies=self.proxies,
            headers=self.headers,
            transports=["websocket"],
            Namespace=AtlasNamespace,
        )

        self.socketIO.on(self.EVENT_NAME_ERROR, self.handle_error) 
開發者ID:RIPE-NCC,項目名稱:ripe-atlas-cousteau,代碼行數:15,代碼來源:stream.py

示例15: startListenForChatServer

# 需要導入模塊: import socketIO_client [as 別名]
# 或者: from socketIO_client import SocketIO [as 別名]
def startListenForChatServer():
    global chatSocket

    chatSocket = SocketIO(chatHostPort['host'], chatHostPort['port'], LoggingNamespace, transports='websocket')

    log.info("Connected to chat socket.io")
    chatSocket.on('chat_message_with_name', onHandleChatMessage)
    chatSocket.on('connect', onHandleChatConnect)
    chatSocket.on('reconnect', onHandleChatReconnect)
    chatSocket.on('disconnect', onHandleChatDisconnect)
    watchdog.start("ChatServerListen", waitForChatServer)
    return chatSocket 
開發者ID:letsRobot,項目名稱:letsrobot,代碼行數:14,代碼來源:networking.py


注:本文中的socketIO_client.SocketIO方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。