Beispiel #1
0
def ws(req, res):
    WebSocket.handshake(req, res)

    connection = req.environ.get('pulsar.connection')
    if not connection:
        res.status(404).send(b'File not found')
        return

    factory = partial(WebSocket, handler)
    connection.upgrade(factory)
    res.status(102).send(b'')
Beispiel #2
0
def ws(req, res):
    WebSocket.handshake(req, res)

    reader = req.environ.get('async.reader')
    writer = req.environ.get('async.writer')

    socket = WebSocket(handler)
    socket.claim_transport(writer.transport)

    res.headers['Upgrade'] = 'WebSocket'
    res.headers['Connection'] = 'Upgrade'
    res.status(101).end()