Skip to main content

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

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.2.tar.gz (12.4 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.2-py3-none-any.whl (13.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for meshsocket-0.1.2.tar.gz
Algorithm Hash digest
SHA256 3fb4895b3b228c1d7081cc6225cb96d0a8efbbcc2386b95e0ca5bece94e7b788
MD5 c7b38230f0c3f724040aaac624964eff
BLAKE2b-256 859ccf38bc94fe317a7ddc58c71c4d2db64604424260fa31c42f6e064d4f224c

See more details on using hashes here.

Provenance

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

File metadata

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

File hashes

Hashes for meshsocket-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c35530a0c8fc4d71eff035bb1b6b089a9ef2e9e754c6b27a250b20e5b0c3935d
MD5 dc2f148ee2a93c9e2e7ae0ac4805fb05
BLAKE2b-256 d9d35fb4f7a012c0de04e8f2bf19866249cfbec719d9c3a96f604911dfe47979

See more details on using hashes here.

Provenance

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

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 files

0.1.1

2 files

0.1.0

2 files

Supported by

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