How to use the ws4py.websocket.WebSocket.__init__ function in ws4py

To help you get started, we’ve selected a few ws4py examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Lawouach / WebSocket-for-Python / ws4py / async_websocket.py View on Github external
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
github DeForce / LalkaChat / modules / messaging / webchat.py View on Github external
def __init__(self, sock, protocols=None, extensions=None, environ=None, heartbeat_freq=None):
        WebSocket.__init__(self, sock)
        self.clients = []
        self.settings = cherrypy.engine.publish('get-settings', 'gui_chat')[0]
        self.type = 'gui_chat'
github Lawouach / WebSocket-for-Python / ws4py / client / __init__.py View on Github external
socktype = socket.SOCK_STREAM
                proto = 0
                canonname = ""
                sa = (self.host, self.port, 0, 0)

            sock = socket.socket(family, socktype, proto)
            sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
            sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
            if hasattr(socket, 'AF_INET6') and family == socket.AF_INET6 and \
              self.host.startswith('::'):
                try:
                    sock.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_V6ONLY, 0)
                except (AttributeError, socket.error):
                    pass

        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))
github Kitware / tangelo / tangelo / tangelo / pkgdata / plugin / vtkweb / web / vtkweb.py View on Github external
def __init__(self, *pargs, **kwargs):
            ws4py.websocket.WebSocket.__init__(self, *pargs, **kwargs)

            scheme = "ws"
            if cherrypy.config.get("server.ssl_private_key"):
                scheme = "wss"
            url = "%s://%s:%d/ws" % (scheme, hostname, port)

            tangelo.log_info(
                "VTKWEB",
                "websocket created at %s:%d/%s (proxy to %s)" % (hostname, port, key, url)
            )

            self.client = VTKWebSocketAB(url, self)
github thomasrynne / swisher / swisher / webcontrol.py View on Github external
def __init__(self, connections, handler_id, sock, protocols, extensions, environ):
        WebSocket.__init__(self, sock, protocols, extensions, environ)
        self.connections = connections
        self.handler_id = handler_id