Write data to a channel.
(self, channel, data)
| 130 | self.update(timeout=(timeout - time.time() + start)) |
| 131 | |
| 132 | def write_channel(self, channel, data): |
| 133 | """Write data to a channel.""" |
| 134 | # check if we're writing binary data or not |
| 135 | binary = type(data) == bytes |
| 136 | opcode = ABNF.OPCODE_BINARY if binary else ABNF.OPCODE_TEXT |
| 137 | |
| 138 | channel_prefix = chr(channel) |
| 139 | if binary: |
| 140 | channel_prefix = bytes(channel_prefix, "ascii") |
| 141 | |
| 142 | payload = channel_prefix + data |
| 143 | self.sock.send(payload, opcode=opcode) |
| 144 | |
| 145 | def close_channel(self, channel): |
| 146 | """Close a channel (v5 protocol only).""" |