Skip to main content

https://github.com/xconnio/wampproto.py

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

wampproto-0.3.0.tar.gz (25.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wampproto-0.3.0-py3-none-any.whl (43.5 kB view details)

Uploaded Python 3

File details

Details for the file wampproto-0.3.0.tar.gz.

File metadata

  • Download URL: wampproto-0.3.0.tar.gz
  • Upload date:
  • Size: 25.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.13

File hashes

Hashes for wampproto-0.3.0.tar.gz
Algorithm Hash digest
SHA256 c4c424374829ce3874b6d0aba79067b7ed679cfe8f9e14fcc755b187099dceac
MD5 f4117860ab2e404b2b880516a0bf5197
BLAKE2b-256 d4b7e0639f5e01c85f2726f4a23e4ea789a47e1ee24d5f2707c00fe7f1884311

See more details on using hashes here.

File details

Details for the file wampproto-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: wampproto-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 43.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.13

File hashes

Hashes for wampproto-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ee34884388868bff3aa93d4dce0bc7b4b1e74d961ddebf8fcc8dc9f4cc4e4999
MD5 55ad4cfa0440a09e5ad8b31c7e183c6c
BLAKE2b-256 18a1528a26e7d7958e63f20b578ce24342e27fdc28ad4efb41f95f6d1c4f9d34

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page