Skip to content

ziyasal-archive/socket.io-csharp-emitter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

socket.io-csharp-emitter

A C# implementation of socket.io-emitter

Build status

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

How to use

PM> Install-Package SocketIO.Emitter
 IEmitter io = new Emitter(new EmitterOptions
    {
        Host = "localhost",
        Port = 6379
    });
  io.Emit("news","Hello from c# emitter");

API

Emitter(EmitterOptions opts)

The following options are allowed:

  • 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)
  • Version: Version of socket IO (EmitterOptions.EVersion.V0_9_9)

NB : If you use a version of socket.io >= 1.4.4 change property Version to EmitterOptions.EVersion.V1_4_4.

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

Specifies a specific room that you want to emit to.

Emitter#In(string room):IEmitter

 IEmitter io = new Emitter(new EmitterOptions
 {
    Host = "localhost",
    Port = 6379
 });
    
 io.In("room-name").Emit("news","Hello from c# emitter");

Emitter#To(string room):IEmitter

 IEmitter io = new Emitter(new EmitterOptions
 {
    Host = "localhost",
    Port = 6379
 });
    
 io.To("room-name").Emit("news","Hello from c# emitter");

Emitter#Of(string namespace):IEmitter

Specifies a specific namespace that you want to emit to.

 IEmitter io = new Emitter(new EmitterOptions
 {
    Host = "localhost",
    Port = 6379
 });
    
 io.Of("/nsp").In("room-name").Emit("news","Hello from c# emitter");

License

MIT

Open Source Projects in use

About

A C# implementation of socket.io-emitter

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •