You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+17-3Lines changed: 17 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,9 +23,23 @@ from centrifuge import Client
23
23
24
24
See [example code](https://github.com/centrifugal/centrifuge-python/blob/master/example.py) and [how to run it](#run-example) locally.
25
25
26
+
## JSON vs Protobuf protocols
27
+
28
+
By default, SDK uses JSON protocol. If you want to use Protobuf protocol instead then pass `use_protobuf=True` option.
29
+
30
+
When using JSON protocol:
31
+
32
+
* all payloads (data to publish, connect/subscribe data) you pass to the library are encoded to JSON internally using `json.dumps` before sending to server. So make sure you pass only JSON-serializable data to the library.
33
+
* all payloads received from server are decoded to Python objects using `json.loads` internally before passing to your code.
34
+
35
+
When using Protobuf protocol:
36
+
37
+
* all payloads you pass to the library must be `bytes` or `None` if optional. If you pass non-`bytes` data – exception will be raised.
38
+
* all payloads received from the library will be `bytes` or `None` if not present.
39
+
26
40
## Run tests
27
41
28
-
To run tests first start Centrifugo server:
42
+
To run tests, first start Centrifugo server:
29
43
30
44
```bash
31
45
docker run -p 8000:8000 centrifugo/centrifugo:v5 centrifugo --client_insecure --log_level debug
@@ -37,12 +51,12 @@ And then:
37
51
python -m venv env
38
52
. env/bin/activate
39
53
make dev
40
-
python -m unittest discover -s tests
54
+
make test
41
55
```
42
56
43
57
## Run example
44
58
45
-
Start Centrifugo with config like this (defines namespace called "example", enables features used in the example):
59
+
To run [example](https://github.com/centrifugal/centrifuge-python/blob/master/example.py), first start Centrifugo with config like this:
0 commit comments