https://github.com/matthewjohn/pycommio
Simple python event-based communication library.
https://github.com/matthewjohn/pycommio
communication communication-library python
Last synced: about 1 month ago
JSON representation
Simple python event-based communication library.
- Host: GitHub
- URL: https://github.com/matthewjohn/pycommio
- Owner: MatthewJohn
- Created: 2017-11-12T18:14:22.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-11-16T10:41:11.000Z (over 5 years ago)
- Last Synced: 2025-02-13T15:14:24.638Z (3 months ago)
- Topics: communication, communication-library, python
- Language: Python
- Homepage:
- Size: 10.7 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# PyCommIO
A simple two-communication for python server-client scenarios.
Sort of based on socket.io principles, but without the python compatibility issues.
## Please note that this project is still in VERY early stages
## Install
git clone https://github.com/MatthewJohn/PyCommIO
pip install --user ./PyCommIO## Server Example
from pycommio.server import Server
server = Server()
@server.on_connect
def conn(conn):
print 'got a connection'
conn.send_event('welcome', 'Some data')
conn.send_event('welcome', {'maybe': ['a', 'dict']})
@server.on_disconnect
def disconnect(conn):
print 'Connection lost'
@server.on('conn_test')
def conn_test(conn, data):
print 'Client initiate: %s' % data
@server.on('test')
def test(conn, data):
print 'got test data: %s' % data
server.start('0.0.0.0', 5000)## Client Example
from pycommio.client import Client
cl = Client('localhost', 5000)
@cl.on_connect
def on_conn(conn):
conn.send_event('conn_test', 'some test data')
@cl.on('welcome')
def welcome(conn, data):
print 'Server said: %s' % data
@cl.on_disconnect
def disconnect(conn):
print 'Connection lost'
cl.connect()
cl.send_event('test', 'this is my data')