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


Python server.SocketIOServer方法代碼示例

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


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

示例1: handle

# 需要導入模塊: from socketio import server [as 別名]
# 或者: from socketio.server import SocketIOServer [as 別名]
def handle(self, addrport='', *args, **options):
        if not addrport:
            self.addr = ''
            self.port = DEFAULT_PORT
        else:
            m = match(naiveip_re, addrport)
            if m is None:
                raise CommandError('"%s" is not a valid port number '
                                   'or address:port pair.' % addrport)
            self.addr, _, _, _, self.port = m.groups()

        environ['DJANGO_SOCKETIO_PORT'] = str(self.port)

        if options.get('use_psyco'):
            try:
                from psycogreen.gevent import patch_psycopg
            except ImportError:
                raise CommandError(
                    'Could not patch psycopg. '
                    'Is psycogreen installed?')
            patch_psycopg()

        if options.get('use_reloader'):
            start_new_thread(reload_watcher, ())

        try:
            bind = (self.addr, int(self.port))
            print 'SocketIOServer running on %s:%s\n\n' % bind
            handler = self.get_handler(*args, **options)
            server = SocketIOServer(
                bind, handler, resource='socket.io', policy_server=True
            )
            server.serve_forever()
        except KeyboardInterrupt:
            for key, sock in six.iteritems(server.sockets):
                sock.kill(detach=True)
            server.stop()
            if RELOAD:
                print 'Reloading...\n\n'
                restart_with_reloader() 
開發者ID:abarto,項目名稱:tracker_project,代碼行數:42,代碼來源:socketio_runserver.py

示例2: run

# 需要導入模塊: from socketio import server [as 別名]
# 或者: from socketio.server import SocketIOServer [as 別名]
def run(self,handler):
        from socketio import server
        address = (self.host, self.port)
        server.SocketIOServer(address, handler, **self.options).serve_forever() 
開發者ID:Autodesk,項目名稱:arnold-usd,代碼行數:6,代碼來源:__init__.py

示例3: run

# 需要導入模塊: from socketio import server [as 別名]
# 或者: from socketio.server import SocketIOServer [as 別名]
def run(self, handler):
        from socketio import server
        address = (self.host, self.port)
        server.SocketIOServer(address, handler, **self.options).serve_forever() 
開發者ID:warriorframework,項目名稱:warriorframework,代碼行數:6,代碼來源:bottle.py


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