当前位置: 首页>>代码示例>>Python>>正文


Python SocketIO.wait方法代码示例

本文整理汇总了Python中socketIO_client.SocketIO.wait方法的典型用法代码示例。如果您正苦于以下问题:Python SocketIO.wait方法的具体用法?Python SocketIO.wait怎么用?Python SocketIO.wait使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在socketIO_client.SocketIO的用法示例。


在下文中一共展示了SocketIO.wait方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_emit_with_callback

# 需要导入模块: from socketIO_client import SocketIO [as 别名]
# 或者: from socketIO_client.SocketIO import wait [as 别名]
 def test_emit_with_callback(self):
     global ON_RESPONSE_CALLED
     ON_RESPONSE_CALLED = False
     socketIO = SocketIO('localhost', 8000)
     socketIO.emit('aaa', PAYLOAD, on_response)
     socketIO.wait(forCallbacks=True)
     self.assertEqual(ON_RESPONSE_CALLED, True)
开发者ID:graingert,项目名称:socketIO-client,代码行数:9,代码来源:tests.py

示例2: send_data

# 需要导入模块: from socketIO_client import SocketIO [as 别名]
# 或者: from socketIO_client.SocketIO import wait [as 别名]
def send_data(save_path):
    """
    Sends all the data files that are present in the specified path to the Qbike server.
    :param save_path: Requires the path in which the trips are saved.
    :return: Nothing. The data is sent to the Server and the txt files are removed from the path's directory.
    """
    end = False
    Trip_nb = 100
    while end == False:
        if not os.path.isfile('C:\Users\Joren\Documents\Ir 1B\P&O\P&O 3\Tryouts\Trips\Trip1.txt'):
            end = True

        else:
            for nb in reversed(range(0, 100)):
                Trip = os.path.join(save_path, "Trip" + str(nb) + ".txt")
                Trip_nb = str(nb)
                if os.path.isfile(Trip):
                    break

            Trip_path = os.path.join(save_path, r"Trip" + Trip_nb + r".txt")

            with open(Trip_path, "r") as Trip:
                batch = json.load(Trip)

            info = {'purpose': 'batch-sender', 'groupID': "cwa2", 'userID': ID}
            socketIO = SocketIO('dali.cs.kuleuven.be', 8080)
            socketIO.on('server_message', on_response)
            socketIO.emit('start', json.dumps(info), on_response)
            socketIO.wait(2)
            socketIO.emit('batch-tripdata', json.dumps(batch), on_response)
            socketIO.wait(5)

            os.remove(Trip_path)

    print "Sent Data"
开发者ID:bicyclus,项目名称:prototype1,代码行数:37,代码来源:batch_wmusic.py

示例3: __init__

# 需要导入模块: from socketIO_client import SocketIO [as 别名]
# 或者: from socketIO_client.SocketIO import wait [as 别名]
class makeSocket:

    def __init__(self):
        self.socket = SocketIO("https://glws.org/fuck")
        self.fn = self.socket.define(fuck, "/fuck")

    def emitready(self):
        try:
            self.fn.emit("isReady",{"wanna_fuck": "no thanks I\'m under age"})
            self.socket.wait(seconds=3)
            global globalready
            temp = globalready
            globalready = None
            return temp
        except TypeError:
            print 'something went wrong doing a ready command please try again'
            return False

    def emitgetdata(self, data):
        try:
            self.fn.emit("sendData", data)
            self.socket.wait(seconds=0.8)
            global globalgetData
            temp = globalgetData
            globalgetData = None
            return temp
        except TypeError:
            print 'something went wrong doing a sendData command please try again'
            return False
开发者ID:craked5,项目名称:opskins_bot,代码行数:31,代码来源:glws_conn.py

示例4: SocketIOHandler

# 需要导入模块: from socketIO_client import SocketIO [as 别名]
# 或者: from socketIO_client.SocketIO import wait [as 别名]
class SocketIOHandler(object):

    def __init__(self, cfg):
        """
        save the server config..
        """
        self.server_address = cfg['graphite_ip']
        self.server_port = cfg['graphite_port']
        self.namespace = cfg['graphite_namespace']
        self.socketIO = None
        self.channel = None

    def handle(self, non_metrics):
        if len(non_metrics) == 0:
            logging.debug('No metrics be handled!')
            return

        nm_list = []
        for nm in non_metrics:
            nm_list.append(dumps(nm.to_dict()))  # serialized to json
        msg_type = non_metrics[0].type
        self.socketIO = SocketIO(self.server_address, self.server_port, BaseNamespace)
        self.channel = self.socketIO.connect(self.namespace, BaseNamespace)
        self.channel.emit(msg_type, nm_list, self.on_response)  # send to server
        self.socketIO.wait(forCallbacks=True)
        logging.debug('SokcetIOHandler emitting %s to sever:\n %s' % (msg_type, dumps(nm_list)))

    def on_response(self, *args):
        # is it necessary?
        self.socketIO.disconnect()
        logging.debug('emit non metrics success!')
开发者ID:lwz7512,项目名称:logmotor,代码行数:33,代码来源:SocketIOHandler.py

示例5: __init__

# 需要导入模块: from socketIO_client import SocketIO [as 别名]
# 或者: from socketIO_client.SocketIO import wait [as 别名]
class WebSocketIO:
	def __init__(self):
		global host
		global port
		self.socketIO = SocketIO(host, port, LoggingNamespace)
		self.socketIO.on('wiiscale-connect', self.receive_connect)
		self.socketIO.on('wiiscale-disconnect', self.receive_disconnect)

	def wait(self):
		self.socketIO.wait(seconds = 1)

	def send_status(self, status):
		self.socketIO.emit('wiiscale-status', {'status': status})

	def send_weight(self, totalWeight):
		self.socketIO.emit('wiiscale-weight', {'totalWeight': totalWeight})

#	def send_connection_status(self, status):
#		self.socketIO.emit('wiiscale-connection', {'status': status})

	# Accepts True or False as argument
	def receive_connect(self):
		global sleep
		sleep = False

	def receive_disconnect(self):
		global board
		global sleep
		sleep = True
		board.disconnect()
开发者ID:Flerb,项目名称:Wii-Scale,代码行数:32,代码来源:wii-scale.py

示例6: run

# 需要导入模块: from socketIO_client import SocketIO [as 别名]
# 或者: from socketIO_client.SocketIO import wait [as 别名]
 def run(self, args):
     print('Listening to %s' % args.relay_url)
     try:
         worker = Worker(args.server_url, args.queue_token)
         worker.work()
         Namespace.channel = 'q/' + args.queue_token
         Namespace.worker = worker
         socket = SocketIO(
             args.relay_url, Namespace=Namespace, wait_for_connection=False)
         socket.wait()
     except ServerConnectionError:
         print_error('The server is down. Try again later.')
     except RelayConnectionError:
         print_error('The relay is down. Try again later.')
     except HTTPBadRequest:
         print_error(
             'There was an error processing your request.\n'
             '- Check that the server URL is correct (--server_url).\n'
             '- Upgrade the framework (pip install -U crosscompute).')
     except HTTPUnauthorized:
         print_error(
             'The server rejected the token. '
             'Make sure your token is valid.')
     except KeyboardInterrupt:
         pass
开发者ID:crosscompute,项目名称:crosscompute,代码行数:27,代码来源:work.py

示例7: SocketServerThread

# 需要导入模块: from socketIO_client import SocketIO [as 别名]
# 或者: from socketIO_client.SocketIO import wait [as 别名]
class SocketServerThread(threading.Thread):
    """A socket server to hold the connection."""

    def __init__(self):
        super(SocketServerThread, self).__init__()
        threading.Thread.__init__(self)

    def run(self):
        try:
            print("threading has begun")
            self.io = SocketIO('http://10.224.59.158', 3000, verify=False)
            print("Created new SocketServer")
            self.io.on('connected', self.handleClientMessage)
            self.io.on('reply', self.on_server_response)
            self.io.wait()
            return
        except (e):
            print("There was an error in the server thread.")
        print("threading has completed")
        # self.io.wait(seconds=10)

    def on_connect(self):
        print('[Connected]')

    def on_server_response(self, responseObj):
        print('Server response received', type(responseObj))
        # responseDict = json.loads(responseObj)
        sublime.active_window().active_view().run_command("annotate_log", responseObj)
        

    def handleServerMessage(self, *args):
        print("Server Message", args)

    def handleClientMessage(self, *args):
        print("Client Message", args)
开发者ID:BrandonJF,项目名称:PubSublimePlus,代码行数:37,代码来源:pub2web.py

示例8: ListenIO

# 需要导入模块: from socketIO_client import SocketIO [as 别名]
# 或者: from socketIO_client.SocketIO import wait [as 别名]
	def ListenIO(self):
		# socketIO = SocketIO('192.168.1.33', 3000)		
		# socketIO = SocketIO('192.168.1.223', 3000)		
		socketIO = SocketIO('localhost', 3000)		
		socketIO.on('serverToPython', self.listener)
		socketIO.emit('clientType', 'Python')
		socketIO.wait(seconds = 6000)
开发者ID:ImmersiveSystems,项目名称:net-robo,代码行数:9,代码来源:ClientClass.py

示例9: Client

# 需要导入模块: from socketIO_client import SocketIO [as 别名]
# 或者: from socketIO_client.SocketIO import wait [as 别名]
class Client(object):
  def __init__(self, client_factory):
    self.logger = logging.getLogger('Graduation')
    self.socket = None
    self.client_factory = client_factory
    self.host = client_factory.host
    self.port = client_factory.port

  def connect(self):
    self.socket = SocketIO(self.host, self.port, LoggingNamespace);
    self.socket.on('device_data_response', self.on_response);
    self.sendMessage(0)
    self.socket.wait()

  def on_response(self):
    time.sleep(2);
    tem = random.randint(0, 40);
    self.sendMessage(tem)

  def sendMessage(self, tem):
    data = dict();
    data["id"] = 1
    data["name"] = "name"
    params = dict();
    params["temperature"] = tem
    data["params"] = params
    self.socket.emit('device_data', data)
开发者ID:chenshuchao,项目名称:graduation_design,代码行数:29,代码来源:main.py

示例10: main

# 需要导入模块: from socketIO_client import SocketIO [as 别名]
# 或者: from socketIO_client.SocketIO import wait [as 别名]
def main(sip,port):
    global SERVER_IP
    global SERVER_PORT
    global SERVER_ADDR
    global socketIO
    global machine



    SERVER_IP = sip
    SERVER_PORT = port
    SERVER_ADDR = SERVER_IP + ":" + str(SERVER_PORT)
    socketIO = SocketIO(SERVER_IP, SERVER_PORT, LoggingNamespace)

    enter_nick()
    machine = sm("Test")
    signal.signal(signal.SIGINT, exit_match)

    

    socketIO.on(cs.JOIN_MATCH, machine.sock_onjoin_match)
    socketIO.on(cs.NEW_MATCH, machine.sock_match_confirm)
    socketIO.on(cs.BEGIN_MATCH, machine.sock_begin_match)
    socketIO.on(cs.RESULT, machine.sock_onresult)
    socketIO.on(cs.REMATCH, machine.sock_onrematch)
    socketIO.on(cs.LEAVE, machine.sock_onleave)

    socketIO.wait()
开发者ID:prudhvid,项目名称:rock-paper,代码行数:30,代码来源:client.py

示例11: Command

# 需要导入模块: from socketIO_client import SocketIO [as 别名]
# 或者: from socketIO_client.SocketIO import wait [as 别名]
class Command(BaseCommand):
    args = '<hostname> <public port> <runserver port> <socket port>'
    help = 'Listens over socket.io websocket'

    def handle(self, *args, **options):
        if len(args) != 4:
            raise Exception("Arguments needed: %s" % self.args)

        # parse arguments
        runserver_host = "%s:%s" % (args[0], args[2])
        runserver_cmd = "python manage.py runserver %s" % runserver_host
        nodejs_cmd = "node %s %s %s %s" % (nodjango_indexjs, args[1], args[2], args[3])

        try:
            # start nodejs proxy
            proc2 = Popen(nodejs_cmd, shell=True, preexec_fn=os.setsid, stdout=sys.stdout, stderr=sys.stderr)

            # start django runserver
            proc1 = Popen(runserver_cmd, shell=True, preexec_fn=os.setsid, stdout=sys.stdout, stderr=sys.stderr)

            time.sleep(2)

            # start django private socketio
            self.socket = SocketIO('127.0.0.1', int(args[3]), Namespace=DjangoNamespace)
            print '* * *\t django socket started'
            self.socket.wait()

        finally:
            print 'killing...'
            os.killpg(proc1.pid, signal.SIGTERM)
            os.killpg(proc2.pid, signal.SIGTERM)
            print 'killed!'
开发者ID:ginking,项目名称:django-socketio-events,代码行数:34,代码来源:runserverjs.py

示例12: DocumentSyncTest

# 需要导入模块: from socketIO_client import SocketIO [as 别名]
# 或者: from socketIO_client.SocketIO import wait [as 别名]
class DocumentSyncTest(BaseTestCase):
    def setUp(self):
        super(DocumentSyncTest, self).setUp()
        self.client = SocketIO('localhost', config.SERVER_PORT, DocumentNamespace)
        self.doc = self.client.define(DocumentNamespace, DOCUMENT_NAMESPACE)
        global RECEIVED
        RECEIVED = {}

    def tearDown(self):
        super(DocumentSyncTest, self).tearDown()
        self.client.disconnect()

    def test_echo(self):
        self.doc.on('echo', on_echo_response)

        self.doc.emit('echo', 'hello world')
        self.client.wait(seconds=1)

        self.assertTrue(RECEIVED.get('on_echo_response', False))

    def test_single_client(self):
        self.doc.on('userlist', on_userlist_response)
        self.doc.on('document', on_document_response)

        self.doc.emit('join', {'username': 'Florian', 'document': DOCUMENT_ID})

        self.client.wait(seconds=1)

        self.doc.emit('leave', {'username': 'Florian', 'document': DOCUMENT_ID})

        self.assertTrue(RECEIVED.get('on_userlist_response', False))
        self.assertTrue(RECEIVED.get('on_document_response', False))
开发者ID:veasy,项目名称:colmark,代码行数:34,代码来源:document_sync_test.py

示例13: Broadcaster

# 需要导入模块: from socketIO_client import SocketIO [as 别名]
# 或者: from socketIO_client.SocketIO import wait [as 别名]
class Broadcaster(object):
    port = 8080
    host = "localhost"

    def __init__(self, port=8080, host="localhost"):
        self.port = port
        self.host = host
        self.socketIO = SocketIO(host, int(port))

        self.socketIO.on("ack", self.logACK)

    def logACK(self, data):
        print("Acknowledgement received for %s" % data['original'])

    def emit(self, event, data):
        self.socketIO.emit(event, data)

    def on(self, event, callback):
        self.socketIO.on(event, callback)

    def wait(self, millis):
        self.socketIO.wait(millis)

    def wait_forever(self):
        self.socketIO.wait()
开发者ID:davidjonas,项目名称:Mediawerf,代码行数:27,代码来源:broadcaster.py

示例14: main

# 需要导入模块: from socketIO_client import SocketIO [as 别名]
# 或者: from socketIO_client.SocketIO import wait [as 别名]
def main():
    global g_socketIO,g_start_time,g_objects_lock
    g_objects_lock = threading.Lock()

    if(len(sys.argv)<2):
        print "Usage:",sys.argv[0]," {S|L|SL} (S=speaking, L=listening) - defaults to SL"
    if(len(sys.argv)==1):
        sys.argv.append("SL")	# Default arguments

    print "Listening to "+HOST+":"+str(PORT)

    g_socketIO = SocketIO(HOST, PORT, Namespace)

    print "Emitting adduser"
    g_socketIO.emit("adduser",socket.getfqdn()+";"+str(os.getpid()))

    g_start_time = time.time()
    if("S" in sys.argv[1]):
        print "Starting speaking"
        thread1 = threading.Thread(target=heartbeat_thread)
        thread1.daemon = True
        thread1.start()
    if("L" in sys.argv[1]):
        print "Starting listening"
        g_socketIO.wait()
    else:
        time.sleep(60*60*24*365*100)
开发者ID:pilgrimbeart,项目名称:nodejs-blackboard,代码行数:29,代码来源:socktest.py

示例15: main

# 需要导入模块: from socketIO_client import SocketIO [as 别名]
# 或者: from socketIO_client.SocketIO import wait [as 别名]
def main(argv):
    (roombaPort, launcherPort, production) = parse_args(argv)

    global launcher_port
    launcher_port = launcherPort
    print("launcher on port %s" % launcher_port)
    global roomba_port
    roomba_port = roombaPort
    print("roomba on port %s" % roomba_port)

    global roomba # define roomba as unscoped global variable
    global launcher # define launcher as unscoped global variable
    try:
        roomba = Serial(port = roombaPort, baudrate = const.ROOMBA_BAUD_RATE) # open serial connection to roomba
    except SerialException:
        print('Serial connection to Roomba over %s could not be established' % roombaPort)
        sys.exit(-1)

    try:
        launcher = Serial(port = launcherPort, baudrate = const.LAUNCHER_BAUD_RATE, writeTimeout = None) # open serial connection to launcher
    except SerialException:
        print('Serial connection to launcher over %s could not be established' % launcherPort)
        sys.exit(-1)

    roomba.write(const.SEQ_START) # start
    time.sleep(1)
    roomba.write(const.SEQ_MODE_SAFE) # enter safe mode
    time.sleep(0.2)

    socketIO = SocketIO(const.PROD_SERVER_HOST, const.PROD_SERVER_PORT, CommandControl, verify = False) if production else SocketIO(const.DEV_SERVER_HOST, const.DEV_SERVER_PORT, CommandControl)
    
    socketIO.on('command', on_command)
    socketIO.on('client-disconnect', on_client_disconnect)
    socketIO.wait()
开发者ID:hashtag-include,项目名称:tanks-irl-device,代码行数:36,代码来源:client.py


注:本文中的socketIO_client.SocketIO.wait方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。