Skip to content

Latest commit

 

History

History
41 lines (27 loc) · 761 Bytes

File metadata and controls

41 lines (27 loc) · 761 Bytes

cyaim-websocket-client-python

WebSocket client for Cyaim.WebSocketServer with automatic endpoint discovery (Python)

Installation

pip install -e .

Usage

import asyncio
from cyaim_websocket_client import WebSocketClientFactory

async def main():
    factory = WebSocketClientFactory('http://localhost:5000', '/ws')
    client = factory.create_client()
    
    await client.connect()
    
    # Get forecasts
    forecasts = await client.send_request('weatherforecast.get')
    
    # Get forecast by city
    forecast = await client.send_request(
        'weatherforecast.getbycity',
        {'city': 'Beijing'}
    )
    
    await client.disconnect()

if __name__ == '__main__':
    asyncio.run(main())

License

MIT