Implementation of the WebSocket protocol from RFC 6455. This class supports versions 7 and 8 of the protocol in addition to the final version 13.
| 792 | |
| 793 | |
| 794 | class WebSocketProtocol13(WebSocketProtocol): |
| 795 | """Implementation of the WebSocket protocol from RFC 6455. |
| 796 | |
| 797 | This class supports versions 7 and 8 of the protocol in addition to the |
| 798 | final version 13. |
| 799 | """ |
| 800 | |
| 801 | # Bit masks for the first byte of a frame. |
| 802 | FIN = 0x80 |
| 803 | RSV1 = 0x40 |
| 804 | RSV2 = 0x20 |
| 805 | RSV3 = 0x10 |
| 806 | RSV_MASK = RSV1 | RSV2 | RSV3 |
| 807 | OPCODE_MASK = 0x0F |
| 808 | |
| 809 | stream = None # type: IOStream |
| 810 | |
| 811 | def __init__( |
| 812 | self, |
| 813 | handler: "_WebSocketDelegate", |
| 814 | mask_outgoing: bool, |
| 815 | params: _WebSocketParams, |
| 816 | ) -> None: |
| 817 | WebSocketProtocol.__init__(self, handler) |
| 818 | self.mask_outgoing = mask_outgoing |
| 819 | self.params = params |
| 820 | self._final_frame = False |
| 821 | self._frame_opcode = None |
| 822 | self._masked_frame = None |
| 823 | self._frame_mask = None # type: Optional[bytes] |
| 824 | self._frame_length = None |
| 825 | self._fragmented_message_buffer = None # type: Optional[bytes] |
| 826 | self._fragmented_message_opcode = None |
| 827 | self._waiting = None # type: object |
| 828 | self._compression_options = params.compression_options |
| 829 | self._decompressor = None # type: Optional[_PerMessageDeflateDecompressor] |
| 830 | self._compressor = None # type: Optional[_PerMessageDeflateCompressor] |
| 831 | self._frame_compressed = None # type: Optional[bool] |
| 832 | # The total uncompressed size of all messages received or sent. |
| 833 | # Unicode messages are encoded to utf8. |
| 834 | # Only for testing; subject to change. |
| 835 | self._message_bytes_in = 0 |
| 836 | self._message_bytes_out = 0 |
| 837 | # The total size of all packets received or sent. Includes |
| 838 | # the effect of compression, frame overhead, and control frames. |
| 839 | self._wire_bytes_in = 0 |
| 840 | self._wire_bytes_out = 0 |
| 841 | self.ping_callback = None # type: Optional[PeriodicCallback] |
| 842 | self.last_ping = 0.0 |
| 843 | self.last_pong = 0.0 |
| 844 | self.close_code = None # type: Optional[int] |
| 845 | self.close_reason = None # type: Optional[str] |
| 846 | |
| 847 | # Use a property for this to satisfy the abc. |
| 848 | @property |
| 849 | def selected_subprotocol(self) -> Optional[str]: |
| 850 | return self._selected_subprotocol |
| 851 |
no outgoing calls
no test coverage detected