• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python server.SocketIOServer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中socketio.server.SocketIOServer的典型用法代码示例。如果您正苦于以下问题:Python SocketIOServer类的具体用法?Python SocketIOServer怎么用?Python SocketIOServer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: handle

    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_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:LuckehPickle,项目名称:Comet,代码行数:28,代码来源:runserver_socketio.py


示例2: start_server

    def start_server(self, addrport="", *args, **options):

        if not addrport:
            self.addr = '127.0.0.1'
            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()

        # Make the port available here for the path:
        # socketio_tags.socketio ->
        # socketio_scripts.html ->
        # io.Socket JS constructor
        # allowing the port to be set as the client-side default there.
        environ["DJANGO_SOCKETIO_PORT"] = str(self.port)

        bind = (self.addr, int(self.port))
        print
        print "SocketIOServer running on http://%s:%s" % bind
        print
        handler = self.get_handler(*args, **options)
        server = SocketIOServer(bind, handler, resource="zircon",
                                policy_server=True)
        server.serve_forever()
开发者ID:hmartiro,项目名称:zircon,代码行数:27,代码来源:runserver_socketio.py


示例3: run_gevent_server

 def run_gevent_server(self):
     server = SocketIOServer(
         (self.host, self.port),
         self.app, namespace='socket.io',
         policy_server=False)
     log.info('Web server running on %s:%s', self.host, self.port)
     server.serve_forever()
开发者ID:kscottz,项目名称:SimpleSeer,代码行数:7,代码来源:Web.py


示例4: spawn_server

 def spawn_server(func, port):
     print "Serving port", port, func.__name__
     server = SocketIOServer(("localhost", port), func,
                     spawn=greenlet_pool,
                     cors="http://localhost:3000",
                     policy_server=False)
     server.serve_forever()
开发者ID:demetriuz,项目名称:gevent-socketio,代码行数:7,代码来源:test_runner.py


示例5: run

def run(addrport, opts):

    if not addrport:
        addr = ''
        port = settings.SIO_PORT
    else:
        m = match(naiveip_re, addrport)
        if m is None:
            raise Exception('"%s" is not a valid port number '
                               'or address:port pair.' % addrport)
        addr, _, _, _, port = m.groups()

    # Make the port available here for the path:
    #   socketio_tags.socketio ->
    #   socketio_scripts.html ->
    #   io.Socket JS constructor
    # allowing the port to be set as the client-side default there.
    os.environ["DJANGO_SOCKETIO_PORT"] = str(port)
    django.setup()
    try:
        bind = (addr, int(port))
        print
        print "SocketIOServer running on %s:%s" % bind
        print
        #inject this setting - needed to initialize zmq in 'green' mode
        settings._wrapped.USE_GEVENT=True
        handler = get_handler(static=opts.use_static_handler)
        server = SocketIOServer(bind, handler, resource="socket.io", policy_server=True)
        server.serve_forever()
    except KeyboardInterrupt:
        pass
开发者ID:izderadicka,项目名称:myplaces,代码行数:31,代码来源:runsocketio.py


示例6: main

    def main(self, host, port):
        got_request_exception.connect(exception_printer)

        self.stdout.write('Serving at {host}:{port}\n'.format(host = host, port = port))
        application = WSGIHandler()
        server = SocketIOServer((host, port), application, namespace = 'socket.io', policy_server = False)
        server.serve_forever()
开发者ID:gelliravi,项目名称:django-realtime,代码行数:7,代码来源:rungevent.py


示例7: run_dev_server

def run_dev_server():
    global server
    app.debug = True
    port = 5000
    dapp = DebuggedApplicationFix(app, evalex = True)
    server = SocketIOServer(('' if len(sys.argv) == 1 else sys.argv[1], port), dapp, resource="socket.io")
    server.serve_forever()
开发者ID:tomatocurry1,项目名称:MHacksPublic,代码行数:7,代码来源:server.py


示例8: start_server

def start_server(host_address):
    try:
        server = SocketIOServer(host_address, app, resource='socket.io')
        server.serve_forever()
    except:
        # assume for now server is already running
        pass
开发者ID:dbsr,项目名称:vimfox,代码行数:7,代码来源:run.py


示例9: socketio_server

def socketio_server():
    #server = SocketIOServer(('0.0.0.0', 0), SocketApp(), policy_server=False)
    server = SocketIOServer(('0.0.0.0', 38477), SocketApp(), policy_server=False)
    server.start()
    port = server.socket.getsockname()[1]
    print 'http://localhost:'+str(port)+'/'
    server.serve_forever()
开发者ID:bishopZ,项目名称:meditation-deathmatch,代码行数:7,代码来源:standalone-server.py


示例10: cli_server_socketio

def cli_server_socketio(
        managed,
        listen=None,
        application=None,
        port=None,
        **kwargs
        ):
    try:
        from socketio.server import SocketIOServer
    except ImportError:
        print(
                'import of socketio.server failed, bailing',
                file=sys.stderr,
                )
        sys.exit(1)

    if not managed and application is None:
        # inspect the caller
        outer_frame = inspect.getouterframes(inspect.currentframe())[2][0]
        app = outer_frame.f_globals['application']
    else:
        app = application

    # Managed (i.e. invoked by 'rain serve') invocations doesn't have the
    # ``listen`` parameter passed in, but have ``port`` set.
    # Just make up one listening on localhost.
    if managed and listen is None:
        listen = ('0.0.0.0', port, )

    server = SocketIOServer(listen, app, **kwargs)
    server.serve_forever()
开发者ID:yeahdongcn,项目名称:weiyu,代码行数:31,代码来源:server.py


示例11: socketio_server

def socketio_server():
    server = SocketIOServer(
        ('0.0.0.0', port),
        SocketApp(),
        policy_server=False)
    server.start()
    server.serve_forever()
开发者ID:bishopZ,项目名称:meditation-deathmatch,代码行数:7,代码来源:qt5-webview.py


示例12: handle

    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()

        # Make the port available here for the path:
        #   socketio_tags.socketio ->
        #   socketio_scripts.html ->
        #   io.Socket JS constructor
        # allowing the port to be set as the client-side default there.
        environ["DJANGO_SOCKETIO_PORT"] = str(self.port)

        start_new_thread(reload_watcher, ())
        try:
            bind = (self.addr, int(self.port))
            print
            print "SocketIOServer running on %s:%s" % bind
            print
            handler = self.get_handler(*args, **options)
            server = SocketIOServer(bind, handler, resource="socket.io", policy_server=True)
            server.serve_forever()
        except KeyboardInterrupt:
            if RELOAD:
                server.stop()
                print "Reloading..."
                restart_with_reloader()
            else:
                raise
开发者ID:sephii,项目名称:wwm,代码行数:35,代码来源:runserver_socketio.py


示例13: run_server

def run_server():
    #app.run('0.0.0.0', 8080, debug=True)
    global app
 
    print 'Starting SocketIO Server with Gevent Mode ...'
    app = SharedDataMiddleware(app, {})
    http_server = SocketIOServer(('', 80), app, namespace="socket.io", policy_server=False)
    http_server.serve_forever()
开发者ID:mmint-kanban,项目名称:-HackNight20130114,代码行数:8,代码来源:api.py


示例14: foo

 def foo():
     server = SocketIOServer(
             (host, port),
             app,
             namespace="socket.io",
             policy_server=False
             )
     server.serve_forever()
开发者ID:weltenwort,项目名称:madacra-py,代码行数:8,代码来源:server.py


示例15: main

def main():
    parser = argparse.ArgumentParser(description='Marteau Server')
    parser.add_argument('config', help='Config file', nargs='?')
    parser.add_argument('--version', action='store_true',
                        default=False,
                        help='Displays Marteau version and exits.')
    parser.add_argument('--log-level', dest='loglevel', default='info',
                        choices=LOG_LEVELS.keys() + [key.upper() for key in
                                                     LOG_LEVELS.keys()],
                        help="log level")
    parser.add_argument('--log-output', dest='logoutput', default='-',
                        help="log output")
    parser.add_argument('--host', help='Host', default='0.0.0.0')
    parser.add_argument('--port', help='Port', type=int, default=8080)
    args = parser.parse_args()

    if args.version:
        print(__version__)
        sys.exit(0)

    if args.config is None:
        parser.print_usage()
        sys.exit(0)

    # configure the logger
    configure_logger(logger, args.loglevel, args.logoutput)

    # loading the config file
    config = Config(args.config)

    # loading the app & the queue
    global_config = {}
    if config.has_section('marteau'):
        settings = config.get_map('marteau')
    else:
        settings = {}

    # check is redis is running
    if not redis_available():
        raise IOError('Marteau needs Redis to run.')

    # loading the fixtures plugins
    for fixture in settings.get('fixtures', []):
        import_string(fixture)

    logger.info('Loaded plugins: %s' % ', '.join(get_fixtures()))

    app = webapp(global_config, **settings)
    try:
        httpd = SocketIOServer((args.host, args.port), app,
                               resource="socket.io", policy_server=False)
        logger.info('Hammer ready, at http://%s:%s. Where are the nails ?' %
                    (args.host, args.port))
        httpd.serve_forever()
    except KeyboardInterrupt:
        sys.exit(0)
    finally:
        logger.info('Bye!')
开发者ID:mozilla-services,项目名称:marteau-web,代码行数:58,代码来源:runserver.py


示例16: main

def main():
    global PORT
    if len(sys.argv)>1:
        PORT=int(sys.argv[1])
    http_server = SocketIOServer(
        ('', PORT),App(), 
        policy_server=False, resource='socket.io'
        )
    # Start the server greenlets
    http_server.serve_forever()
开发者ID:izderadicka,项目名称:webresmon,代码行数:10,代码来源:webresmon.py


示例17: start_server

def start_server(host, port, hide_status, debug):
    app.debug = bool(debug)
    app.reloaded['hide_status'] = bool(hide_status)
    server = SocketIOServer((host, int(port)), app, resource='socket.io')
    print "Reloaded server started serving on: {}:{}.".format(host, port)
    try:
        server.serve_forever()
    except socket.error:
        print ("Reloaded server could not bind to port: {}. Is reloaded already"
               " running?".format(port))
        sys.exit(1)
开发者ID:dbsr,项目名称:reloaded,代码行数:11,代码来源:run.py


示例18: main

    def main():
        # Load application and config.
        app = loadapp('config:%s' % cfgfile, relative_to='.')
        server = SocketIOServer((host, port), app,
                                namespace="socket.io")

        try:
            print "Serving on %s:%d (http://127.0.0.1:%d) ..." % (host, port, port)
            server.serve_forever()
        except socket.error, e:
            print "ERROR SERVING WSGI APP: %s" % e
            sys.exit(1)
开发者ID:jonnyquan,项目名称:pyramid_socketio,代码行数:12,代码来源:serve.py


示例19: handle

 def handle(self, addrport="", **kwargs):
     if not addrport:
         self.addr = "127.0.0.1"
         self.port = 9000
     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()
     server = SocketIOServer((self.addr, int(self.port)), application)
     server.serve_forever()
开发者ID:finid,项目名称:drawnby,代码行数:12,代码来源:runserver_socketio.py


示例20: run_socket_server

def run_socket_server(addr, port, *args, **options):
    bind = (addr, int(port))
    print
    print "SocketIOServer running on %s:%s" % bind
    print
    handler = get_handler(*args, **options)
    server = SocketIOServer(bind, handler,
                            heartbeat_interval=5,
                            heartbeat_timeout=30,
                            resource="socket.io",
                            policy_server=True)
    server.serve_forever()
开发者ID:naphthalene,项目名称:hubcave,代码行数:12,代码来源:runserver_socketio.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python socketserver.BaseServer类代码示例发布时间:2022-05-27
下一篇:
Python policyserver.FlashPolicyServer类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap