(self, packet_type=EVENT, data=None, namespace=None, id=None,
binary=None, encoded_packet=None)
| 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. |
nothing calls this directly
no test coverage detected