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


Python WebSocket.__init__方法代码示例

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


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

示例1: __init__

# 需要导入模块: from ws4py.websocket import WebSocket [as 别名]
# 或者: from ws4py.websocket.WebSocket import __init__ [as 别名]
 def __init__(self, url, protocols, extensions):
     sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0)
     WebSocket.__init__(self, sock, protocols=protocols, extensions=extensions)
     self.stream.always_mask = True
     self.stream.expect_masking = False
     self.key = b64encode(os.urandom(16))
     self.url = url
开发者ID:Ivideon,项目名称:WebSocket-for-Python,代码行数:9,代码来源:__init__.py

示例2: __init__

# 需要导入模块: from ws4py.websocket import WebSocket [as 别名]
# 或者: from ws4py.websocket.WebSocket import __init__ [as 别名]
 def __init__(self, *args, **kw):
     """
     Constructor. This will be called automatically
     by the server upon connection
     """
     WebSocket.__init__(self, *args, **kw)
     self.close_callback = None
开发者ID:haogefeifei,项目名称:drrr_like_chat,代码行数:9,代码来源:sock.py

示例3: __init__

# 需要导入模块: from ws4py.websocket import WebSocket [as 别名]
# 或者: from ws4py.websocket.WebSocket import __init__ [as 别名]
	def __init__(self, *args, **kw):
		WebSocket.__init__(self, *args, **kw)
		print str(self) + "connected"
		SUBSCRIBERS.add(self)
		global NextUID
		NextUID = NextUID + 1
		UID = NextUID
开发者ID:nickdanger3d,项目名称:hitztourney,代码行数:9,代码来源:HitzApp.py

示例4: __init__

# 需要导入模块: from ws4py.websocket import WebSocket [as 别名]
# 或者: from ws4py.websocket.WebSocket import __init__ [as 别名]
 def __init__(self, app_name, *args, **kw):
     self.app_name = app_name
     self.backend = get_backend()
     self.verbose = self.backend.verbose
     cherrypy.log.access_log.info(
         'Creating %s with args=%s and keywords=%s.' % (self.app_name, args, kw))
     WebSocket.__init__(self, *args, **kw)
     self.backend.register(self)
开发者ID:TBillTech,项目名称:domsocket,代码行数:10,代码来源:app_websocket.py

示例5: __init__

# 需要导入模块: from ws4py.websocket import WebSocket [as 别名]
# 或者: from ws4py.websocket.WebSocket import __init__ [as 别名]
    def __init__(self, *args, **kwargs):
        """
        This passes all arguments to the parent constructor.  In addition, it
        defines the following instance variables:

        send_lock: Used to guarantee thread-safety when sending RPC responses.

        client_locks: A dict mapping client ids to locks used by those clients.

        passthru_subscriptions: When we recieve a subscription request for a
            service method registered on a remote service, we pass that request
            along to the remote service and send back the responses.  This
            dictionary maps client ids to those subscription objects.

        session_fields: We copy session data for the  currently-authenticated
            user who made the incoming websocket connection; by default we only
            copy the username, but this can be overridden in configuration.
            Remember that Sideboard exposes two websocket handlers at /ws and
            /wsrpc, with /ws being auth-protected (so the username field will be
            meaningful) and /wsrpc being client-cert protected (so the username
            will always be 'rpc').

        header_fields: We copy header fields from the request that initiated the
            websocket connection.

        cached_queries and cached_fingerprints: When we receive a subscription
            update, Sideboard re-runs all of the subscription methods to see if
            new data needs to be pushed out.  We do this by storing all of the
            rpc methods and an MD5 hash of their return values.  We store a hash
            rather than the return values themselves to save on memory, since
            return values may be very large.

            The cached_queries dict has this structure:
                {
                    'client_id': {
                        'callback_id': (func, args, kwargs, client_data),
                        ...
                    },
                    ...
                }

            The cached_fingerprints dict has this structure:
                {
                    'client_id': {
                        'callback_id': 'md5_hash_of_return_value',
                        ...
                    },
                    ...
                }
        """
        WebSocket.__init__(self, *args, **kwargs)
        self.instances.add(self)
        self.send_lock = RLock()
        self.passthru_subscriptions = {}
        self.client_locks = defaultdict(RLock)
        self.cached_queries, self.cached_fingerprints = defaultdict(dict), defaultdict(dict)
        self.session_fields = self.check_authentication()
        self.header_fields = self.fetch_headers()
开发者ID:magfest,项目名称:sideboard,代码行数:60,代码来源:websockets.py

示例6: __init__

# 需要导入模块: from ws4py.websocket import WebSocket [as 别名]
# 或者: from ws4py.websocket.WebSocket import __init__ [as 别名]
    def __init__(self, *args, **kw):
        WebSocket.__init__(self, *args, **kw)

        # cherrypy.log("args type %s" % type(ws))
        #
        # for i in args:
        #     try:
        #         cherrypy.log("args  %s \n" % i)
        #     except Exception as error:
        #         cherrypy.log("Can't print args  because %s \n" % error)
        # cherrypy.log("args %s " % args)
        # cherrypy.log("kw %s " % kw)
        SUBSCRIBERS.add(self)
开发者ID:weldpua2008,项目名称:websocket-example,代码行数:15,代码来源:main.py

示例7: __init__

# 需要导入模块: from ws4py.websocket import WebSocket [as 别名]
# 或者: from ws4py.websocket.WebSocket import __init__ [as 别名]
    def __init__(self, url, protocols, extensions, heartbeat_freq=None):
        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0)
        WebSocket.__init__(self, sock, protocols=protocols, extensions=extensions,
                           heartbeat_freq=heartbeat_freq)
        self.stream.always_mask = True
        self.stream.expect_masking = False
        self.key = b64encode(os.urandom(16))
        self.url = url

        self.host = None
        self.scheme = None
        self.port = None
        self.resource = None

        self._parse_url()
开发者ID:KanoComputing,项目名称:nush,代码行数:17,代码来源:__init__.py

示例8: __init__

# 需要导入模块: from ws4py.websocket import WebSocket [as 别名]
# 或者: from ws4py.websocket.WebSocket import __init__ [as 别名]
    def __init__(self, *args, **kargs):

        '''New websockets can be registered with the radio on creation.
        Channel names can be passed in the URL, for example:

            ws://localhost:1002/ws/chan0/chan1

        A socket may be created with no channels, and then register one
        or more later on. This is how client-side Radio actually works.
        '''

        WebSocket.__init__(self, *args, **kargs)

        # derive a list of zero or more channels from the url
        channels = str(self.environ['REQUEST_URI'])[2:-1].split('/')[2:]

        # if channels is empty, this does nothing
        radio.register(channels, self.send, True)
开发者ID:KanoComputing,项目名称:nush,代码行数:20,代码来源:__main__.py

示例9: __init__

# 需要导入模块: from ws4py.websocket import WebSocket [as 别名]
# 或者: from ws4py.websocket.WebSocket import __init__ [as 别名]
    def __init__(self, *args, **kwargs):
        WebSocket.__init__(self, *args, **kwargs)
        self.debugger_store().chrome_channel.setSocket(self)

        common_domain_args = {
            'debugger_store': self.debugger_store()
        }

        runtime_domain = RuntimeDomain(**common_domain_args)
        debugger_domain = DebuggerDomain(
            runtime_domain,
            **common_domain_args)
        self.handlers = HandlerDomainSet(
            ConsoleDomain(**common_domain_args),
            debugger_domain,
            PageDomain(**common_domain_args),
            runtime_domain,
        )
开发者ID:Ayush-Mahajan,项目名称:nuclide,代码行数:20,代码来源:chromedebugger.py

示例10: __init__

# 需要导入模块: from ws4py.websocket import WebSocket [as 别名]
# 或者: from ws4py.websocket.WebSocket import __init__ [as 别名]
    def __init__(self, proto):
        """
        A :pep:`3156` ready websocket handler that works
        well in a coroutine-aware loop such as the one provided
        by the asyncio module.

        The provided `proto` instance is a
        :class:`asyncio.Protocol` subclass instance that will
        be used internally to read and write from the
        underlying transport.

        Because the base :class:`ws4py.websocket.WebSocket`
        class is still coupled a bit to the socket interface,
        we have to override a little more than necessary
        to play nice with the :pep:`3156` interface. Hopefully,
        some day this will be cleaned out.
        """
        _WebSocket.__init__(self, None)
        self.started = False
        self.proto = proto
开发者ID:10alc,项目名称:Spotify2.bundle,代码行数:22,代码来源:async_websocket.py

示例11: __init__

# 需要导入模块: from ws4py.websocket import WebSocket [as 别名]
# 或者: from ws4py.websocket.WebSocket import __init__ [as 别名]
    def __init__(self, url, protocols=None, extensions=None, heartbeat_freq=None):
        """
        A websocket client that implements :rfc:`6455` and provides a simple
        interface to communicate with a websocket server.

        This class works on its own but will block if not run in
        its own thread.

        When an instance of this class is created, a :py:mod:`socket`
        is created with the nagle's algorithm disabled and with
        the capacity to reuse a port that was just used.

        The address of the server will be extracted from the given
        websocket url.

        The websocket key is randomly generated, reset the
        `key` attribute if you want to provide yours.

        """
        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0)

        sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
        sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)

        WebSocket.__init__(self, sock, protocols=protocols,
                           extensions=extensions,
                           heartbeat_freq=heartbeat_freq)
        self.stream.always_mask = True
        self.stream.expect_masking = False
        self.key = b64encode(os.urandom(16))
        self.url = url

        self.host = None
        self.scheme = None
        self.port = None
        self.resource = None

        self._parse_url()
开发者ID:jsheffie,项目名称:WebSocket-for-Python,代码行数:40,代码来源:__init__.py

示例12: __init__

# 需要导入模块: from ws4py.websocket import WebSocket [as 别名]
# 或者: from ws4py.websocket.WebSocket import __init__ [as 别名]
    def __init__(self, *args, **kwargs):
        WebSocket.__init__(self, *args, **kwargs)
        common_domain_args = {
            'debugger': self.debugger(),
            'socket': self,
        }
        file_manager = FileManager(self)
        remote_object_manager = RemoteObjectManager()

        runtime_domain = RuntimeDomain(
            remote_object_manager,
            **common_domain_args)
        self.handlers = HandlerDomainSet(
            ConsoleDomain(**common_domain_args),
            DebuggerDomain(
                runtime_domain,
                file_manager,
                remote_object_manager,
                basepath=self.basepath(),
                **common_domain_args),
            PageDomain(**common_domain_args),
            runtime_domain,
        )
开发者ID:Staberinde,项目名称:nuclide,代码行数:25,代码来源:chromedebugger.py

示例13: __init__

# 需要导入模块: from ws4py.websocket import WebSocket [as 别名]
# 或者: from ws4py.websocket.WebSocket import __init__ [as 别名]
 def __init__(self, *args, **kwargs):
     WebSocket.__init__(self, *args, **kwargs)
     self.send_lock = RLock()
     self.client_locks, self.cached_queries, self.cached_fingerprints = \
         defaultdict(RLock), defaultdict(dict), defaultdict(dict)
     self.username = self.check_authentication()
开发者ID:ftobia,项目名称:sideboard,代码行数:8,代码来源:websockets.py

示例14: __init__

# 需要导入模块: from ws4py.websocket import WebSocket [as 别名]
# 或者: from ws4py.websocket.WebSocket import __init__ [as 别名]
 def __init__(self, *args, **kwargs):
     WebSocket.__init__(self, *args, **kwargs)
     self.controller = AuthenticateMessageController()
     self.user = None
     self.greenlet_listener = None
     self.is_open= False
开发者ID:mishto,项目名称:ChatApp,代码行数:8,代码来源:server.py

示例15: __init__

# 需要导入模块: from ws4py.websocket import WebSocket [as 别名]
# 或者: from ws4py.websocket.WebSocket import __init__ [as 别名]
 def __init__(self, *args, **kwargs):
   WebSocket.__init__(self,*args,**kwargs)
   self.service = JamrService()
开发者ID:dangan249,项目名称:JAMR,代码行数:5,代码来源:JamrResource.py


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