Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

pubber/socket.io-python-emitter

Open more actions menu
 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

socket.io-python-emitter

A Python implementation of socket.io-emitter

socket.io provides a hook point to easily allow you to emit events to browsers from anywhere so socket.io-python-emitter communicates with socket.io servers through redis.

How to use

Install via pip

pip install socket.io-emitter
  io=Emitter({'host': 'localhost', 'port':6379})
  io.Emit('broadcast event','Hello from socket.io-python-emitter')
        

API

Emitter(opts)

The following options are allowed:

  • client: is a redis-py compatible client This argument is optional.
  • key: the name of the key to pub/sub events on as prefix (socket.io)
  • host: host to connect to redis on (localhost)
  • port: port to connect to redis on (6379)

If you don't want to supply a redis client object, and want socket.io-python-emitter to initialize one for you, make sure to supply the host and port options.

Specifies a specific room that you want to emit to.

Emitter#In(room):Emitter

  io=Emitter({'host': 'localhost', 'port':6379})
  io.In("room-name").Emit("news","Hello from python emitter");

Emitter#To(room):Emitter

 io=Emitter({'host': 'localhost', 'port':6379})
    
 io.To("room-name").Emit("news","Hello from python emitter");

We are flattening the room parameter from [] and *argv, so you can also send to several rooms like this (both examples are valid):

 io=Emitter({'host': 'localhost', 'port':6379})

 io.To(["room1", "room2"]).Emit("news","Hello from python emitter");
 io.To("room1", "room2").Emit("news","Hello from python emitter");

Emitter#Of(namespace):Emitter

Specifies a specific namespace that you want to emit to.

 io=Emitter({'host': 'localhost', 'port':6379})
    
 io.Of("/nsp").In("room-name").Emit("news","Hello from python emitter");

License

MIT

###Open Source Projects in Use

About

Python implementation of socket.io-emitter

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 100.0%
Morty Proxy This is a proxified and sanitized view of the page, visit original site.