Skip to content

Simple python event-based communication library.

Notifications You must be signed in to change notification settings

MatthewJohn/PyCommIO

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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')

About

Simple python event-based communication library.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages