Skip to main content

pondsocket-client

Python client for the PondSocket server. Connects to PondSocket servers (Python, Go, or TypeScript implementation) over WebSocket.

Modeled after the JavaScript client architecture (@eleven-am/pondsocket-client) rather than the Go one — the JS client fixes several bugs the Go client has (see Parity notes below).

Install

pip install pondsocket-client

Quick start

import asyncio
from pondsocket_client import PondClient


async def main() -> None:
    client = PondClient("ws://localhost:8000/ws", {"token": "secret"})
    await client.connect()

    channel = client.create_channel("/chat/42", {"username": "alice"})
    channel.on_message_event("message", lambda m: print(m.payload))
    channel.on_join(lambda user: print("joined:", user))
    channel.join()

    channel.send_message("message", {"text": "hello"})

    response = await channel.send_for_response("ping", {"text": "abc"})
    print("got pong:", response)

    await asyncio.sleep(10)
    await client.disconnect()


asyncio.run(main())

Architecture

BaseClient (abstract)
  ├── channel registry
  ├── inbound event routing (ACK / UNAUTHORIZED / CONNECTION / per-channel)
  ├── connection state machine: DISCONNECTED → CONNECTING → CONNECTED
  └── exponential reconnect

WebSocketClient(BaseClient)  (abstract)
  ├── opens via `websockets` library
  └── receive loop pumps inbound to BaseClient

PondClient(WebSocketClient)  (concrete)
  ├── URL handling (http → ws, https → wss)
  └── appends query-string params

The Channel class holds the per-channel state machine (IDLE → JOINING → JOINED → STALLED → CLOSED/DECLINED), a bounded outbound queue (drops oldest on overflow), and a send_for_response that correlates inbound replies by requestId.

Connection states

Subscribe via client.on_connection_change(handler):

State When
DISCONNECTED initial; after disconnect or socket close
CONNECTING connect() called; socket handshake in flight
CONNECTED socket open AND server sent the CONNECTION event

Channel states

Subscribe via channel.on_channel_state_change(handler):

State Meaning
IDLE created but join() not called
JOINING join() called; awaiting ACKNOWLEDGE
JOINED server acknowledged; messages flow
STALLED socket dropped while JOINED; will rejoin on reconnect
CLOSED leave() called
DECLINED server sent UNAUTHORIZED; channel is terminal — create a new one

Parity notes

Compared to the Go client (go/pondsocket-client/):

Behavior Go Python
send_for_response correlation event name (buggy) requestId (correct)
Reconnect backoff linear despite comment true exponential, capped
UNAUTHORIZED handling not implemented → DECLINED state
Connection state bool (no CONNECTING) three-state enum
Outbound queue unbounded bounded, drops oldest
Join while disconnected dropped silently deferred until CONNECTED

The Python client follows the JS client design where the two diverge.

Public API

from pondsocket_client import (
    PondClient,
    Channel,
    ConnectionState,
    ClientOptions,
    ResponseTimeoutError,
)

Also exposed for adapter authors: BaseClient, WebSocketClient, Publisher (type alias).

License

GPL-3.0-or-later.

Metadata

Release files for pondsocket-client 0.0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pondsocket-client 0.0.6
File Size Uploaded Provenance Actions
pondsocket_client-0.0.6.tar.gz 13.0 kB Without provenance Details for pondsocket_client-0.0.6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pondsocket-client 0.0.6
File Interpreter ABI Platform Actions
pondsocket_client-0.0.6-py3-none-any.whl Python 3 none any Details for pondsocket_client-0.0.6-py3-none-any.whl

Total release size: 24.4 kB

Release files / pondsocket_client-0.0.6.tar.gz

Download URL pondsocket_client-0.0.6.tar.gz
Size 13.0 kB
Tags Source
SHA-256 checksum
How to use checksums
42c123c219e2cd978d30c196dcecd309dc05e0b3b0e4d79040b3e76c66fb0a9d
BLAKE2b-256 checksum
How to use checksums
8755c7a567c0dc93a0ac9855788eb993a7c62c51648f02321ab84bf1f0c708e2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.0

Release files / pondsocket_client-0.0.6-py3-none-any.whl

Download URL pondsocket_client-0.0.6-py3-none-any.whl
Size 11.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1e793d9a5a9b39e76c90643095f7f36d9b1d063b45ccebc25282107157c39c03
BLAKE2b-256 checksum
How to use checksums
a4c6019ab0312deacf3e6246b04974e54109184a6ace9de37489a547856ce829
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.0

Security for pondsocket-client 0.0.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page