MCPcopy Create free account
hub / github.com/miguelgrinberg/python-socketio / __init__

Method __init__

src/socketio/packet.py:25–43  ·  view source on GitHub ↗
(self, packet_type=EVENT, data=None, namespace=None, id=None,
                 binary=None, encoded_packet=None)

Source from the content-addressed store, hash-verified

23 json = _json
24
25 def __init__(self, packet_type=EVENT, data=None, namespace=None, id=None,
26 binary=None, encoded_packet=None):
27 self.packet_type = packet_type
28 self.data = data
29 self.namespace = namespace
30 self.id = id
31 if self.uses_binary_events and \
32 (binary or (binary is None and self.data_is_binary(
33 self.data))):
34 if self.packet_type == EVENT:
35 self.packet_type = BINARY_EVENT
36 elif self.packet_type == ACK:
37 self.packet_type = BINARY_ACK
38 else:
39 raise ValueError('Packet does not support binary payload.')
40 self.attachment_count = 0
41 self.attachments = []
42 if encoded_packet:
43 self.attachment_count = self.decode(encoded_packet) or 0
44
45 def encode(self):
46 """Encode the packet for transmission.

Callers

nothing calls this directly

Calls 2

data_is_binaryMethod · 0.95
decodeMethod · 0.95

Tested by

no test coverage detected