websockets Documentation
Release 5.0world!”: #!/usr/bin/env python import asyncio import websockets async def hello(uri): async with websockets.connect(uri) as websocket: await websocket.send("Hello world!") asyncio.get_event_loop().run_until_complete( Write a coroutine that handles a single connection. It receives a websocket protocol instance and the URI path in argument. – Call recv() and send() to receive and send messages at any time. – You may ping() handler. It must be a coroutine accepting two arguments: a WebSocketServerProtocol and the request URI. The host and port arguments, as well as unrecognized keyword arguments, are passed along to create_server()0 码力 | 56 页 | 245.43 KB | 1 年前3
websockets Documentation
Release 6.0world!”: #!/usr/bin/env python import asyncio import websockets async def hello(uri): async with websockets.connect(uri) as websocket: await websocket.send("Hello world!") asyncio.get_event_loop().run_until_complete( Write a coroutine that handles a single connection. It receives a websocket protocol instance and the URI path in argument. – Call recv() and send() to receive and send messages at any time. – You may ping() handler. It must be a coroutine accepting two arguments: a WebSocketServerProtocol and the request URI. The host and port arguments, as well as unrecognized keyword arguments, are passed along to create_server()0 码力 | 58 页 | 253.08 KB | 1 年前3
websockets Documentation
Release 4.0world!”: #!/usr/bin/env python import asyncio import websockets async def hello(uri): async with websockets.connect(uri) as websocket: await websocket.send("Hello world!") asyncio.get_event_loop().run_until_complete( Write a coroutine that handles a single connection. It receives a websocket protocol instance and the URI path in argument. – Call recv() and send() to receive and send messages at any time. – You may ping() handler. It must be a coroutine accepting two arguments: a WebSocketServerProtocol and the request URI. The host and port arguments, as well as unrecognized keyword arguments, are passed along to create_server()0 码力 | 48 页 | 224.70 KB | 1 年前3
websockets Documentation
Release 3.3Write a coroutine that handles a single connection. It receives a websocket protocol instance and the URI path in argument. – Call recv() and send() to receive and send messages at any time. – You may ping() handler. It must be a coroutine accepting two arguments: a WebSocketServerProtocol and the request URI. serve() is a wrapper around the event loop’s create_server() method. host, port as well as extra value) pairs. It can also be a callable taking the request path and headers in arguments. Return the URI of the request. static select_subprotocol(client_protos, server_protos) Pick a subprotocol among0 码力 | 32 页 | 176.18 KB | 1 年前3
websockets Documentation
Release 3.2Write a coroutine that handles a single connection. It receives a websocket protocol instance and the URI path in argument. – Call recv() and send() to receive and send messages at any time. – You may ping() handler. It must be a coroutine accepting two arguments: a WebSocketServerProtocol and the request URI. serve() is a wrapper around the event loop’s create_server() method. host, port as well as extra value) pairs. It can also be a callable taking the request path and headers in arguments. Return the URI of the request. select_subprotocol(client_protos, server_protos) Pick a subprotocol among those offered0 码力 | 32 页 | 170.46 KB | 1 年前3
websockets Documentation
Release 2.7Write a coroutine that handles a single connection. It receives a websocket protocol instance and the URI path in argument. – Call recv() and send() to receive and send messages at any time. – You may ping() handler. It must be a coroutine accepting two arguments: a WebSocketServerProtocol and the request URI. serve() accepts several optional arguments: •origins defines acceptable Origin HTTP headers — include value) pairs. It can also be a callable taking the request path and headers in arguments. Return the URI of the request. select_subprotocol(client_protos, server_protos) Pick a subprotocol among those offered0 码力 | 28 页 | 157.50 KB | 1 年前3
websockets Documentation
Release 3.4Write a coroutine that handles a single connection. It receives a websocket protocol instance and the URI path in argument. – Call recv() and send() to receive and send messages at any time. – You may ping() handler. It must be a coroutine accepting two arguments: a WebSocketServerProtocol and the request URI. The host and port arguments, as well as unrecognized keyword arguments, are passed along to create_server() and headers in arguments. Raise InvalidHandshake or a subclass if the handshake fails. Return the URI of the request. process_request(path, request_headers) Intercept the HTTP request and return an HTTP0 码力 | 36 页 | 192.66 KB | 1 年前3
websockets Documentation
Release 1.0. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 4.4 URI parser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . #!/usr/bin/env python import asyncio import websockets @asyncio.coroutine def hello(websocket, uri): name = yield from websocket.recv() print("< {}".format(name)) greeting = "Hello {}!".format(name) handler. It must be a coroutine accepting two arguments: a WebSocketServerProtocol and the request URI. The host and port arguments and other keyword ar- guments are passed to create_server. Whenever a0 码力 | 25 页 | 137.62 KB | 1 年前3
websockets Documentation
Release 9.0/usr/bin/env python import asyncio import websockets async def hello(): uri = "ws://localhost:8765" async with websockets.connect(uri) as websocket: await websocket.send("Hello world!") await websocket.recv() client example import asyncio import websockets async def hello(): uri = "ws://localhost:8765" async with websockets.connect(uri) as websocket: name = input("What's your name? ") await websocket.send(name) ssl_context.load_verify_locations(localhost_pem) async def hello(): uri = "wss://localhost:8765" async with websockets.connect( uri, ssl=ssl_context ) as websocket: name = input("What's your name? ")0 码力 | 81 页 | 352.88 KB | 1 年前3
websockets Documentation
Release 2.2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 4.4 URI parser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . handler. It must be a coroutine accepting two arguments: a WebSocketServerProtocol and the request URI. If provided, origin is a list of acceptable Origin HTTP headers. Include ’’ if the lack of an origin Documentation, Release 2.2.0 Return the URI of the request. 3.2 Client The websockets.client module defines a simple WebSocket client API. websockets.client.connect(uri, *, klass=WebSocketClientProtocol,0 码力 | 27 页 | 143.46 KB | 1 年前3
共 245 条
- 1
- 2
- 3
- 4
- 5
- 6
- 25













