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


Python FlashPolicyServer.start方法代码示例

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


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

示例1: SocketIOServer

# 需要导入模块: from socketio.policyserver import FlashPolicyServer [as 别名]
# 或者: from socketio.policyserver.FlashPolicyServer import start [as 别名]
class SocketIOServer(WSGIServer):
    """A WSGI Server with a resource that acts like an SocketIO."""

    def __init__(self, *args, **kwargs):
        self.sockets = {}
        if "resource" in kwargs:
            print "DEPRECATION WARNING: use `namespace` instead of `resource`"
        self.namespace = kwargs.pop("resource", kwargs.pop("namespace", "socket.io"))
        self.transports = kwargs.pop("transports", None)

        if kwargs.pop("policy_server", True):
            self.policy_server = FlashPolicyServer()
        else:
            self.policy_server = None

        kwargs["handler_class"] = SocketIOHandler
        super(SocketIOServer, self).__init__(*args, **kwargs)

    def start_accepting(self):
        if self.policy_server is not None:
            try:
                self.policy_server.start()
            except error, ex:
                sys.stderr.write("FAILED to start flash policy server: %s\n" % (ex,))
            except Exception:
                traceback.print_exc()
                sys.stderr.write("FAILED to start flash policy server.\n\n")
开发者ID:jgelens,项目名称:gevent-socketio,代码行数:29,代码来源:server.py

示例2: SocketIOServer

# 需要导入模块: from socketio.policyserver import FlashPolicyServer [as 别名]
# 或者: from socketio.policyserver.FlashPolicyServer import start [as 别名]
class SocketIOServer(WSGIServer):
    """A WSGI Server with a resource that acts like an SocketIO."""

    def __init__(self, *args, **kwargs):
        """
        This is just like the standard WSGIServer __init__, except with a
        few additional ``kwargs``:

        :param resource: The URL which has to be identified as a socket.io request.  Defaults to the /socket.io/ URL.
        :param transports: Optional list of transports to allow. List of
            strings, each string should be one of
            handler.SocketIOHandler.handler_types.
        :param policy_server: Boolean describing whether or not to use the
            Flash policy server.  Default True.
        :param policy_listener : A tuple containing (host, port) for the
            policy server.  This is optional and used only if policy server
            is set to true.  The default value is 0.0.0.0:843
        """
        self.sockets = {}
        if 'namespace' in kwargs:
            print("DEPRECATION WARNING: use resource instead of namespace")
            self.resource = kwargs.pop('namespace', 'socket.io')
        else:
            self.resource = kwargs.pop('resource', 'socket.io')

        self.transports = kwargs.pop('transports', None)

        if kwargs.pop('policy_server', True):
            try:
                address = args[0][0]
            except TypeError:
                address = args[0].address[0]
            policylistener = kwargs.pop('policy_listener', (address, 10843))
            self.policy_server = FlashPolicyServer(policylistener)
        else:
            self.policy_server = None

        kwargs['handler_class'] = SocketIOHandler
        super(SocketIOServer, self).__init__(*args, **kwargs)

    def start_accepting(self):
        if self.policy_server is not None:
            try:
                if not self.policy_server.started:
                    self.policy_server.start()
            except error, ex:
                sys.stderr.write(
                    'FAILED to start flash policy server: %s\n' % (ex, ))
            except Exception:
                traceback.print_exc()
                sys.stderr.write('FAILED to start flash policy server.\n\n')
开发者ID:mbarkhau,项目名称:gevent-socketio,代码行数:53,代码来源:server.py

示例3: SocketIOServer

# 需要导入模块: from socketio.policyserver import FlashPolicyServer [as 别名]
# 或者: from socketio.policyserver.FlashPolicyServer import start [as 别名]
class SocketIOServer(WSGIServer):
    """A WSGI Server with a resource that acts like an SocketIO."""

    def __init__(self, *args, **kwargs):
        """
        This is just like the standard WSGIServer __init__, except with a
        few additional ``kwargs``:

        :param namespace: The namespace to use. Defaults to the global
            namespace.
        :param transports: Optional list of transports to allow. List of
            strings, each string should be one of
            handler.SocketIOHandler.handler_types.
        :param policy_server: Boolean describing whether or not to use the
            Flash policy server.  Default True.
        """
        self.sockets = {}
        if 'resource' in kwargs:
            print "DEPRECATION WARNING: use `namespace` instead of `resource`"
        self.namespace = kwargs.pop('resource', kwargs.pop('namespace',
                                                           'socket.io'))
        self.transports = kwargs.pop('transports', None)

        if kwargs.pop('policy_server', True):
            policylistener = kwargs.pop('policy_listener', (args[0][0], 843))
            self.policy_server = FlashPolicyServer(policylistener)
        else:
            self.policy_server = None

        kwargs['handler_class'] = SocketIOHandler
        super(SocketIOServer, self).__init__(*args, **kwargs)

    def start_accepting(self):
        if self.policy_server is not None:
            try:
                self.policy_server.start()
            except error, ex:
                sys.stderr.write(
                    'FAILED to start flash policy server: %s\n' % (ex, ))
            except Exception:
                traceback.print_exc()
                sys.stderr.write('FAILED to start flash policy server.\n\n')
开发者ID:philipn,项目名称:gevent-socketio,代码行数:44,代码来源:server.py

示例4: SocketIOServer

# 需要导入模块: from socketio.policyserver import FlashPolicyServer [as 别名]
# 或者: from socketio.policyserver.FlashPolicyServer import start [as 别名]
class SocketIOServer(WSGIServer):
    """A WSGI Server with a resource that acts like an SocketIO."""

    def __init__(self, *args, **kwargs):
        self.sessions = {}
        self.resource = kwargs.pop('resource')
        if kwargs.pop('policy_server', True):
            self.policy_server = FlashPolicyServer()
        else:
            self.policy_server = None
        kwargs['handler_class'] = SocketIOHandler
        super(SocketIOServer, self).__init__(*args, **kwargs)

    def start_accepting(self):
        if self.policy_server is not None:
            try:
                self.policy_server.start()
            except error, ex:
                sys.stderr.write('FAILED to start flash policy server: %s\n' % (ex, ))
            except Exception:
                traceback.print_exc()
                sys.stderr.write('FAILED to start flash policy server.\n\n')
开发者ID:fzuslide,项目名称:Motsquare,代码行数:24,代码来源:server.py

示例5: SocketIOServer

# 需要导入模块: from socketio.policyserver import FlashPolicyServer [as 别名]
# 或者: from socketio.policyserver.FlashPolicyServer import start [as 别名]
class SocketIOServer(WSGIServer):
    """A WSGI Server with a resource that acts like an SocketIO."""

    def __init__(self, *args, **kwargs):
        """This is just like the standard WSGIServer __init__, except with a
        few additional ``kwargs``:

        :param resource: The URL which has to be identified as a
            socket.io request.  Defaults to the /socket.io/ URL.

        :param transports: Optional list of transports to allow. List of
            strings, each string should be one of
            handler.SocketIOHandler.handler_types.

        :param policy_server: Boolean describing whether or not to use the
            Flash policy server.  Default True.

        :param policy_listener: A tuple containing (host, port) for the
            policy server.  This is optional and used only if policy server
            is set to true.  The default value is 0.0.0.0:843

        :param heartbeat_interval: int The timeout for the server, we
            should receive a heartbeat from the client within this
            interval. This should be less than the
            ``heartbeat_timeout``.

        :param heartbeat_timeout: int The timeout for the client when
            it should send a new heartbeat to the server. This value
            is sent to the client after a successful handshake.

        :param close_timeout: int The timeout for the client, when it
            closes the connection it still X amounts of seconds to do
            re open of the connection. This value is sent to the
            client after a successful handshake.

        :param log_file: str The file in which you want the PyWSGI
            server to write its access log.  If not specified, it
            is sent to `stderr` (with gevent 0.13).

        """
        self.sockets = {}
        if 'namespace' in kwargs:
            print("DEPRECATION WARNING: use resource instead of namespace")
            self.resource = kwargs.pop('namespace', 'socket.io')
        else:
            self.resource = kwargs.pop('resource', 'socket.io')

        self.transports = kwargs.pop('transports', None)

        if kwargs.pop('policy_server', True):
            try:
                address = args[0][0]
            except TypeError:
                try:
                    address = args[0].address[0]
                except AttributeError:
                    address = args[0].cfg_addr[0]
            policylistener = kwargs.pop('policy_listener', (address, 10843))
            self.policy_server = FlashPolicyServer(policylistener)
        else:
            self.policy_server = None

        # Extract other config options
        self.config = {
            'heartbeat_timeout': 60,
            'close_timeout': 60,
            'heartbeat_interval': 25,
        }
        for f in ('heartbeat_timeout', 'heartbeat_interval', 'close_timeout'):
            if f in kwargs:
                self.config[f] = int(kwargs.pop(f))

        if not 'handler_class' in kwargs:
            kwargs['handler_class'] = SocketIOHandler


        if not 'ws_handler_class' in kwargs:
            self.ws_handler_class = WebSocketHandler
        else:
            self.ws_handler_class = kwargs.pop('ws_handler_class')

        log_file = kwargs.pop('log_file', None)
        if log_file:
            kwargs['log'] = open(log_file, 'a')

        super(SocketIOServer, self).__init__(*args, **kwargs)

    def start_accepting(self):
        if self.policy_server is not None:
            try:
                if not self.policy_server.started:
                    self.policy_server.start()
            except error, ex:
                sys.stderr.write(
                    'FAILED to start flash policy server: %s\n' % (ex, ))
            except Exception:
                traceback.print_exc()
                sys.stderr.write('FAILED to start flash policy server.\n\n')
开发者ID:AndrewJHart,项目名称:gevent-socketio,代码行数:100,代码来源:server.py

示例6: SocketIOServer

# 需要导入模块: from socketio.policyserver import FlashPolicyServer [as 别名]
# 或者: from socketio.policyserver.FlashPolicyServer import start [as 别名]
class SocketIOServer(WSGIServer):
    """A WSGI Server with a resource that acts like an SocketIO."""

    def __init__(self, *args, **kwargs):
        """This is just like the standard WSGIServer __init__, except with a
        few additional ``kwargs``:

        :param resource: The URL which has to be identified as a
            socket.io request.  Defaults to the /socket.io/ URL.

        :param transports: Optional list of transports to allow. List of
            strings, each string should be one of
            handler.SocketIOHandler.handler_types.

        :param policy_server: Boolean describing whether or not to use the
            Flash policy server.  Default True.

        :param policy_listener : A tuple containing (host, port) for the
            policy server.  This is optional and used only if policy server
            is set to true.  The default value is 0.0.0.0:843

        :param heartbeat_interval: int The timeout for the server, we
            should receive a heartbeat from the client within this
            interval. This should be less than the
            ``heartbeat_timeout``.

        :param heartbeat_timeout: int The timeout for the client when
            it should send a new heartbeat to the server. This value
            is sent to the client after a successful handshake.

        :param close_timeout: int The timeout for the client, when it
            closes the connection it still X amounts of seconds to do
            re open of the connection. This value is sent to the
            client after a successful handshake.

        """
        self.sockets = {}
        if "namespace" in kwargs:
            print("DEPRECATION WARNING: use resource instead of namespace")
            self.resource = kwargs.pop("namespace", "socket.io")
        else:
            self.resource = kwargs.pop("resource", "socket.io")

        self.transports = kwargs.pop("transports", None)

        if kwargs.pop("policy_server", True):
            try:
                address = args[0][0]
            except TypeError:
                address = args[0].address[0]
            policylistener = kwargs.pop("policy_listener", (address, 10843))
            self.policy_server = FlashPolicyServer(policylistener)
        else:
            self.policy_server = None

        # Extract other config options
        self.config = {"heartbeat_timeout": 60, "close_timeout": 60, "heartbeat_interval": 25}
        for f in ("heartbeat_timeout", "heartbeat_interval", "close_timeout"):
            if f in kwargs:
                self.config[f] = int(kwargs.pop(f))

        kwargs["handler_class"] = SocketIOHandler
        super(SocketIOServer, self).__init__(*args, **kwargs)

    def start_accepting(self):
        if self.policy_server is not None:
            try:
                if not self.policy_server.started:
                    self.policy_server.start()
            except error, ex:
                sys.stderr.write("FAILED to start flash policy server: %s\n" % (ex,))
            except Exception:
                traceback.print_exc()
                sys.stderr.write("FAILED to start flash policy server.\n\n")
开发者ID:pgiraud,项目名称:gevent-socketio,代码行数:76,代码来源:server.py


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