Skip to main content

Lightweight WebSocket mesh networking — broadcast, direct routing, and request/response over a simple JSON wire protocol.

Project description

MeshSocket (Python)

PyPI Downloads Python versions

A lightweight WebSocket mesh networking library. Nodes connect to a central relay and communicate by broadcast, direct routing, and request/response — all over a simple JSON wire protocol.

Install

pip install meshsocket

Quickstart (client)

import asyncio
from meshsocket import MeshSocket

async def main():
    sock = MeshSocket(url="ws://localhost:8765", name="my-node",
                      channel="demo", role="device", can_broadcast=True)

    async def on_toggle(payload):
        print("got", payload)
        return {"ok": True}            # a returned value is delivered as the reply

    sock.on("toggle", on_toggle)

    await sock.start()                 # connect + identify
    await sock.wait_until_ready()
    await sock.send("reading", {"temp_c": 21.4})   # broadcast to the channel
    await asyncio.sleep(60)
    await sock.stop()

asyncio.run(main())

Wire protocol

Every message is a JSON object:

{ "id": "uuid", "type": "message_type", "payload": "<any JSON or null>", "reply_to": "uuid or null" }

If a handler returns a value, the receiver sends a reply with reply_to set to the original id, enabling request/response round-trips.

Compatibility

from meshsocket import MeshSocket is the supported import. The historical from socketCore import MeshSocket still works (that module is published alongside the package) so existing code keeps running while it migrates.

Other language clients

Swift (SPM, zero-dependency) and a planned JavaScript client live in the same repo: https://github.com/Mariner10/MeshSocket

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

meshsocket-0.1.1.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

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

meshsocket-0.1.1-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

Details for the file meshsocket-0.1.1.tar.gz.

File metadata

  • Download URL: meshsocket-0.1.1.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for meshsocket-0.1.1.tar.gz
Algorithm Hash digest
SHA256 187113dd74f0988ded02048c77bc46cfc783164971c5b465a447f556f829e70d
MD5 27d853279dfd8359cdbf4cd2504cc877
BLAKE2b-256 1ae87d0f56ce0f1126d776e3f73a6726b87dd1180c3a6162bbddbe725297eb9b

See more details on using hashes here.

Provenance

The following attestation bundles were made for meshsocket-0.1.1.tar.gz:

Publisher: publish.yml on Mariner10/MeshSocket

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file meshsocket-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: meshsocket-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 12.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for meshsocket-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 82841110d83fbc908e5cef9ec6d2a5888a36b3735b185e7cf22251ab91850360
MD5 f8430cb9e89702535f268a045382c676
BLAKE2b-256 bb5fbd0a499d2dfd3b8ad7048c30d6de5e7e5e03abc54a9868571bf63bed3209

See more details on using hashes here.

Provenance

The following attestation bundles were made for meshsocket-0.1.1-py3-none-any.whl:

Publisher: publish.yml on Mariner10/MeshSocket

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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