websockets Documentation
Release 4.0sheet 2.1.1 Server • 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 subclass WebSocketServerProtocol and pass either this sub- class or a factory function as the create_protocol argument. 2.1.2 Client • Create a client with connect() which is similar to asyncio’s create_connection() subclass WebSocketClientProtocol and pass either this sub- class or a factory function as the create_protocol argument. • Call recv() and send() to receive and send messages at any time. • You may ping()0 码力 | 48 页 | 224.70 KB | 1 年前3
websockets Documentation
Release 5.0confidentiality and also reliability because they reduce the risk of interference by bad proxies. The WSS protocol is to WS what HTTPS is to HTTP: the connection is encrypted with TLS. WSS requires TLS certificates {name}!" await websocket.send(greeting) print(f"> {greeting}") ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER) ssl_context.load_cert_chain( pathlib.Path(__file__).with_name('localhost.pem')) start_server certificate import asyncio import pathlib import ssl import websockets ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT) ssl_context.load_verify_locations( pathlib.Path(__file__).with_name('localhost.pem'))0 码力 | 56 页 | 245.43 KB | 1 年前3
websockets Documentation
Release 9.0confidentiality and also reliability because they reduce the risk of interference by bad proxies. The WSS protocol is to WS what HTTPS is to HTTP: the connection is encrypted with Transport Layer Security (TLS) {name}!" await websocket.send(greeting) print(f"> {greeting}") ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER) localhost_pem = pathlib.Path(__file__).with_name("localhost.pem") ssl_context.load_ certificate import asyncio import pathlib import ssl import websockets ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT) localhost_pem = pathlib.Path(__file__).with_name("localhost.pem") ssl_context.load_0 码力 | 81 页 | 352.88 KB | 1 年前3
websockets Documentation
Release 6.0confidentiality and also reliability because they reduce the risk of interference by bad proxies. The WSS protocol is to WS what HTTPS is to HTTP: the connection is encrypted with TLS. WSS requires TLS certificates {name}!" await websocket.send(greeting) print(f"> {greeting}") ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER) ssl_context.load_cert_chain( pathlib.Path(__file__).with_name('localhost.pem')) start_server certificate import asyncio import pathlib import ssl import websockets ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT) ssl_context.load_verify_locations( pathlib.Path(__file__).with_name('localhost.pem'))0 码力 | 58 页 | 253.08 KB | 1 年前3
websockets Documentation
Release 3.4Cheat sheet Server • 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 subclass WebSocketServerProtocol and pass either this sub- class or a factory function as the create_protocol argument. Client • Create a client with connect() which is similar to asyncio’s create_connection() subclass WebSocketClientProtocol and pass either this sub- class or a factory function as the create_protocol argument. • Call recv() and send() to receive and send messages at any time. • You may ping()0 码力 | 36 页 | 192.66 KB | 1 年前3
Mypy 1.8.0 Documentationtyping module in earlier versions of Python than the addition, for example, using any of Literal, Protocol, TypedDict with Python 3.6. The easiest way to do this is to install and use the typing_extensions various protocol classes that correspond to common Python protocols, such as Iterable[T]. If a class defines a suitable __iter__ method, mypy understands that it implements the iterable protocol and is 5]) # Also OK Predefined protocol reference lists all protocols defined in typing and the signatures of the corresponding methods you need to define to implement each protocol. 1.9.2 Simple user-defined0 码力 | 234 页 | 902.89 KB | 1 年前3
Mypy 1.10.0+dev Documentationsubprotocols and subclassing protocols Invariance of protocol attributes Recursive protocols Using isinstance() with protocols Callback protocols Predefined protocol reference Dynamically typed code Operations platform checks Displaying the type of an expression Silencing linters Covariant subtyping of mutable protocol members is rejected Dealing with conflicting names Using a development mypy build Variables vs type html#module-typing] module in earlier versions of Python than the addition, for example, using any of Literal, Protocol, TypedDict with Python 3.6. The easiest way to do this is to install and use the typing_extensions0 码力 | 318 页 | 270.84 KB | 1 年前3
Mypy 1.8.0 Documentationsubprotocols and subclassing protocols Invariance of protocol attributes Recursive protocols Using isinstance() with protocols Callback protocols Predefined protocol reference Dynamically typed code Operations platform checks Displaying the type of an expression Silencing linters Covariant subtyping of mutable protocol members is rejected Dealing with conflicting names Using a development mypy build Variables vs type html#module-typing] module in earlier versions of Python than the addition, for example, using any of Literal, Protocol, TypedDict with Python 3.6. The easiest way to do this is to install and use the typing_extensions0 码力 | 318 页 | 271.55 KB | 1 年前3
Mypy 1.10.0+dev Documentationtyping module in earlier versions of Python than the addition, for example, using any of Literal, Protocol, TypedDict with Python 3.6. The easiest way to do this is to install and use the typing_extensions various protocol classes that correspond to common Python protocols, such as Iterable[T]. If a class defines a suitable __iter__ method, mypy understands that it implements the iterable protocol and is 5]) # Also OK Predefined protocol reference lists all protocols defined in typing and the signatures of the corresponding methods you need to define to implement each protocol. 1.9.2 Simple user-defined0 码力 | 234 页 | 913.89 KB | 1 年前3
websockets Documentation
Release 3.3Cheat sheet Server • 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 guide. These functions are built on top of low-level APIs reflecting the two phases of the WebSocket protocol: 1. An opening handshake, in the form of an HTTP Upgrade request; 2. Data transfer, as framed build and validate the request and response headers. The second phase is the core of the WebSocket protocol. websockets provides a standalone implementation on top of asyncio with a very simple API. For0 码力 | 32 页 | 176.18 KB | 1 年前3
共 401 条
- 1
- 2
- 3
- 4
- 5
- 6
- 41













