simple-message-channels/README.md

35 lines
677 B
Markdown
Raw Permalink Normal View History

2020-06-29 23:53:17 +00:00
# simple-message-channels
2020-06-29 23:54:30 +00:00
[![Build Status](https://drone.autonomic.zone/api/badges/hyperpy/simple-message-channels/status.svg)](https://drone.autonomic.zone/hyperpy/simple-message-channels)
## Sans I/O wire protocol for Hypercore
2020-06-29 23:53:17 +00:00
2020-07-07 14:05:55 +00:00
## Install
2020-06-29 23:53:17 +00:00
```sh
$ pip install simple-message-channels
```
2020-07-07 14:05:55 +00:00
## Example
```python
2020-08-01 16:53:22 +00:00
from simple_message_channels import SimpleMessageChannel
2020-08-05 06:16:17 +00:00
smc1 = SimpleMessageChannel()
smc2 = SimpleMessageChannel()
2020-08-01 16:53:22 +00:00
2020-08-05 06:16:17 +00:00
payload = smc1.send(0, 1, b"foo")
2020-08-05 06:00:22 +00:00
print(f"sent: {payload}")
2020-08-01 16:53:22 +00:00
2020-08-03 20:23:11 +00:00
for idx in range(0, len(payload)):
2020-08-05 06:16:17 +00:00
smc2.recv(payload[idx : idx + 1])
print(f"received: {smc2.messages}")
2020-08-01 16:53:22 +00:00
```
Output:
```sh
2020-08-05 06:00:22 +00:00
sent: b'\x04\x01foo'
2020-08-05 06:16:17 +00:00
received: [(0, 1, b'foo')]
2020-07-07 14:05:55 +00:00
```