Skip to main content

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

Project description

MeshSocket (Python)

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.0.tar.gz (11.6 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.0-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: meshsocket-0.1.0.tar.gz
  • Upload date:
  • Size: 11.6 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.0.tar.gz
Algorithm Hash digest
SHA256 705b352953dc33a304f02d0f3d954724bd57b4eec9ee6797f18ba3c4298d2dab
MD5 0de1bfd13c61435d38319b3fad69e3e0
BLAKE2b-256 2ab61359f5c202f7aacac96848d8cfab213978b02497efe2217873207d289f62

See more details on using hashes here.

Provenance

The following attestation bundles were made for meshsocket-0.1.0.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.0-py3-none-any.whl.

File metadata

  • Download URL: meshsocket-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.7 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6d7a91ec51ec78378d7e1f4aba588567eac753f0769fa9e2c471a1d0280b43e1
MD5 0ad5f7e9fa0e9e7f7e2227b0efa982f5
BLAKE2b-256 9aa2bc6e7d1b6fa23f2848b849cbc0ce29c197ed9ebc5f26cebd48a3ceb9937a

See more details on using hashes here.

Provenance

The following attestation bundles were made for meshsocket-0.1.0-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