Skip to main content

A client SDK for communicating with Ticos Server

Project description

Ticos Client Python SDK

A Python SDK for communicating with Ticos Server.

Note: Check the latest SDK version at GitHub Releases

Installation

pip install ticos-client==0.1.5

Usage

from ticos import TicosClient

def main():
    # Create a client instance
    client = TicosClient("localhost", 9999)
    
    # Set message handlers
    client.set_motion_handler(lambda id: print(f"Received motion message id: {id}"))
    client.set_emotion_handler(lambda id: print(f"Received emotion message id: {id}"))
    client.set_message_handler(lambda msg: print(f"Received message: {msg}"))

    # Connect to server with auto-reconnect enabled
    if client.connect(True):
        print("Connected to server successfully")
        
        # Send a message with custom data
        message = {
            "func": "motion",
            "id": "1",
            "data": {
                "speed": 1.0,
                "repeat": 3
            }
        }
        
        if client.send_message(message):
            print("Message sent successfully")
        else:
            print("Failed to send message")

if __name__ == "__main__":
    main()

API Reference

TicosClient

Constructor

client = TicosClient(host: str, port: int)

Methods

  • connect(auto_reconnect: bool = True) -> bool

    • Connect to the server
    • Returns True if connection successful
  • disconnect()

    • Disconnect from the server
  • send_message(message: dict) -> bool

    • Send a message to the server
    • message: A dictionary containing the message data
    • Returns True if message sent successfully
  • set_message_handler(handler: Callable[[dict], None])

    • Set handler for general messages
  • set_motion_handler(handler: Callable[[str], None])

    • Set handler for motion messages
  • set_emotion_handler(handler: Callable[[str], None])

    • Set handler for emotion messages

Message Format

Messages should be dictionaries with the following structure:

{
    "func": str,      # Function/message type (e.g., "motion", "emotion")
    "id": str,        # Message identifier
    "data": dict      # Optional additional data, TBD
}

Development

  1. Clone the repository
  2. Install development dependencies:
    pip install -r requirements-dev.txt
    
  3. Run tests:
    python -m pytest tests/
    

License

Apache License 2.0

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

ticos_client-0.1.5.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

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

ticos_client-0.1.5-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file ticos_client-0.1.5.tar.gz.

File metadata

  • Download URL: ticos_client-0.1.5.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for ticos_client-0.1.5.tar.gz
Algorithm Hash digest
SHA256 917bb294488776a1f49396fd6601bdf51864a7fc37baacedc2da93aa6b6ecdb1
MD5 80cb2941811e158b1a86d8a209b0c7ef
BLAKE2b-256 379c94bb74c058fe6ce90abd411386b7ca7a36381d6aeba0f7209c7ff0f2f9a1

See more details on using hashes here.

File details

Details for the file ticos_client-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: ticos_client-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for ticos_client-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 dd05ada08ec3cd46f0887738a72e93351119107a62da11b400eaed5e827066da
MD5 20731c31e40efb35230ffa9fcd7d0535
BLAKE2b-256 7d3f43b64e9245ca589ea1044970e251f17628f2e96c17ff6dfa2b2ae991282b

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