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


Python SocketIOServer.serve_forever方法代码示例

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


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

示例1: socketio_server

# 需要导入模块: from socketio.server import SocketIOServer [as 别名]
# 或者: from socketio.server.SocketIOServer import serve_forever [as 别名]
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,代码行数:9,代码来源:standalone-server.py

示例2: cli_server_socketio

# 需要导入模块: from socketio.server import SocketIOServer [as 别名]
# 或者: from socketio.server.SocketIOServer import serve_forever [as 别名]
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,代码行数:33,代码来源:server.py

示例3: run_dev_server

# 需要导入模块: from socketio.server import SocketIOServer [as 别名]
# 或者: from socketio.server.SocketIOServer import serve_forever [as 别名]
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,代码行数:9,代码来源:server.py

示例4: socketio_server

# 需要导入模块: from socketio.server import SocketIOServer [as 别名]
# 或者: from socketio.server.SocketIOServer import serve_forever [as 别名]
def socketio_server():
    server = SocketIOServer(
        ('0.0.0.0', port),
        SocketApp(),
        policy_server=False)
    server.start()
    server.serve_forever()
开发者ID:bishopZ,项目名称:meditation-deathmatch,代码行数:9,代码来源:qt5-webview.py

示例5: start_server

# 需要导入模块: from socketio.server import SocketIOServer [as 别名]
# 或者: from socketio.server.SocketIOServer import serve_forever [as 别名]
    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,代码行数:29,代码来源:runserver_socketio.py

示例6: handle

# 需要导入模块: from socketio.server import SocketIOServer [as 别名]
# 或者: from socketio.server.SocketIOServer import serve_forever [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()

        # 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,代码行数:37,代码来源:runserver_socketio.py

示例7: run_gevent_server

# 需要导入模块: from socketio.server import SocketIOServer [as 别名]
# 或者: from socketio.server.SocketIOServer import serve_forever [as 别名]
 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,代码行数:9,代码来源:Web.py

示例8: handle

# 需要导入模块: from socketio.server import SocketIOServer [as 别名]
# 或者: from socketio.server.SocketIOServer import serve_forever [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_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,代码行数:30,代码来源:runserver_socketio.py

示例9: run

# 需要导入模块: from socketio.server import SocketIOServer [as 别名]
# 或者: from socketio.server.SocketIOServer import serve_forever [as 别名]
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,代码行数:33,代码来源:runsocketio.py

示例10: spawn_server

# 需要导入模块: from socketio.server import SocketIOServer [as 别名]
# 或者: from socketio.server.SocketIOServer import serve_forever [as 别名]
 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,代码行数:9,代码来源:test_runner.py

示例11: main

# 需要导入模块: from socketio.server import SocketIOServer [as 别名]
# 或者: from socketio.server.SocketIOServer import serve_forever [as 别名]
    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,代码行数:9,代码来源:rungevent.py

示例12: start_server

# 需要导入模块: from socketio.server import SocketIOServer [as 别名]
# 或者: from socketio.server.SocketIOServer import serve_forever [as 别名]
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,代码行数:9,代码来源:run.py

示例13: run_server

# 需要导入模块: from socketio.server import SocketIOServer [as 别名]
# 或者: from socketio.server.SocketIOServer import serve_forever [as 别名]
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,代码行数:10,代码来源:api.py

示例14: foo

# 需要导入模块: from socketio.server import SocketIOServer [as 别名]
# 或者: from socketio.server.SocketIOServer import serve_forever [as 别名]
 def foo():
     server = SocketIOServer(
             (host, port),
             app,
             namespace="socket.io",
             policy_server=False
             )
     server.serve_forever()
开发者ID:weltenwort,项目名称:madacra-py,代码行数:10,代码来源:server.py

示例15: main

# 需要导入模块: from socketio.server import SocketIOServer [as 别名]
# 或者: from socketio.server.SocketIOServer import serve_forever [as 别名]
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,代码行数:60,代码来源:runserver.py


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