https://github.com/xconnio/wampproto-python
Project description
wampproto-python
Sans-IO implementation of the WAMP protocol in Python
This is a library that could be used to build a WAMP client or server. It operates on strings and bytes. A WAMP client can be split into two parts.
- Session establishment
- Session management.
Assuming we have a websocket connection established to a WAMP server using sub protocol wamp.2.json. The first
"message" is going to be sent by the client as HELLO
from wampproto.joiner import Joiner
j = Joiner("realm1")
# this doesn't actually send the message, it just returns the
# payload that needs to be sent over websocket.
hello = j.send_hello()
ws.send_str(hello)
response = ws.receive_str()
to_send = j.receive(response)
if to_send is None:
# if there is nothing to send, this means
# the server returned WELCOME.
print(j.get_session_details())
Now that the session is established, we could instantiate a WAMPSession instance
to handle further messages.
from wampproto.session import WAMPSession
from wampproto.messages import Call
from wampproto.idgen import SessionScopeIDGenerator
session = WAMPSession()
idgen = SessionScopeIDGenerator()
call = Call(idgen.next(), "foo.bar")
to_send = session.send_message(call)
ws.send_str(to_send)
incoming_payload = ws.receive_str()
result = session.receive(incoming_payload)
print(result)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file wampproto-0.4.0.tar.gz.
File metadata
- Download URL: wampproto-0.4.0.tar.gz
- Upload date:
- Size: 26.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fb3bba2f58035b12ed99577c29730b5137e0ff2a80cc2f38fabfedc7d686e2ce
|
|
| MD5 |
7d12a0f54fc64cb50760d1b7427c9c5b
|
|
| BLAKE2b-256 |
93c7ea22f0601be2052c1550e6378a3c20fb6a8da8c4eabe8ddce10bd531972a
|
File details
Details for the file wampproto-0.4.0-py3-none-any.whl.
File metadata
- Download URL: wampproto-0.4.0-py3-none-any.whl
- Upload date:
- Size: 45.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
125eb3992140fc15c6d48dea0fecf0e4f95fdd565072db42051fe94fd4786162
|
|
| MD5 |
68d2c21c01e353fe8081793c9eef807f
|
|
| BLAKE2b-256 |
963b4a3658cf1937c63af0f9d706f88e0eb879891d81e4b2c75e362ed92fe884
|