C# Class Zazzles.Bus

An event driven IPC interface. Can also be used to send event only within the running process.
Mostra file Open project: FOGProject/zazzles Class Usage Examples

Public Methods

Method Description
Dispose ( ) : void
Emit ( Channel channel, Newtonsoft.Json.Linq.JObject data, bool global = false ) : void

Emit a message to all listeners

GetCurrentMode ( ) : Mode
SetMode ( Mode mode ) : void

Set the mode of the bus instance. Upon calling this method, the IPC interface will initialize.

Subscribe ( Channel channel, Action action ) : void

Register an action with a channel. When a message is recieved on this channel, the method will be called.

Unsubscribe ( Channel channel, Action action ) : void

Unregister an action from a channel

Private Methods

Method Description
Emit ( Channel channel, string data, bool global = false ) : void

Emit a message to all listeners

EmitMessageFromSocket ( string message ) : void

Parse a message recieved in the socket and emit it to channels confined in its instance

Initializesocket ( ) : void

Initiate the socket that connects to all other FOG bus instances It MUST be assumed that this socket is compromised Do NOT send security relevant data across it

SendMessage ( string msg ) : void

Send a message to other bus instances

client_connect ( WebSocketSession clientSession ) : void
socket_RecieveMessage ( WebSocketSession session, string value ) : void

Called when the socket client recieves a message

socket_RecieveMessage ( object sender, WebSocket4Net.MessageReceivedEventArgs messageReceivedEventArgs ) : void

Called when the server socket recieves a message It will replay the message to all other instances, including the original sender unless told otherwise

Method Details

Dispose() public static method

public static Dispose ( ) : void
return void

Emit() public static method

Emit a message to all listeners
public static Emit ( Channel channel, Newtonsoft.Json.Linq.JObject data, bool global = false ) : void
channel Channel The channel to emit on
data Newtonsoft.Json.Linq.JObject The data to send
global bool Should the data be sent to other processes
return void

GetCurrentMode() public static method

public static GetCurrentMode ( ) : Mode
return Mode

SetMode() public static method

Set the mode of the bus instance. Upon calling this method, the IPC interface will initialize.
public static SetMode ( Mode mode ) : void
mode Mode
return void

Subscribe() public static method

Register an action with a channel. When a message is recieved on this channel, the method will be called.
public static Subscribe ( Channel channel, Action action ) : void
channel Channel The channel to register within
action Action The action (method) to register
return void

Unsubscribe() public static method

Unregister an action from a channel
public static Unsubscribe ( Channel channel, Action action ) : void
channel Channel
action Action
return void