/// <summary> /// Registers a callback to the specified channelType with the given channelID /// </summary> /// <param name="channel"></param> /// <param name="callback"></param> public void Subscribe(ChannelTypes channelType, int channelID, EventHandler <NetworkMessageContainer> callback) { _sub.Subscribe(channelType.ToString() + channelID.ToString(), (rc, rv) => { try { callback(this, SerializationUtilities.DeserializeMsgPack <NetworkMessageContainer>(rv)); } catch (Exception e) { ConsoleManager.WriteLine("Redis exception! " + e.Message, ConsoleMessageType.Error); ConsoleManager.WriteLine(e.StackTrace, ConsoleMessageType.Error); } }); }
/// <summary> /// Publishes the message, using channelType and channelId to route the message appropriately /// </summary> /// <param name="channelType"></param> /// <param name="channelId"></param> /// <param name="msg"></param> public void PublishObject(ChannelTypes channelType, int channelId, NetworkMessageContainer msg) { _sub.Publish(channelType.ToString() + channelId.ToString(), msg.Serialize()); }
public void UnSubscribe(ChannelTypes channelType, int channelID, EventHandler <NetworkMessageContainer> callback) { _sub.Unsubscribe(channelType.ToString() + channelID.ToString(), (rc, rv) => { callback(this, SerializationUtilities.DeserializeMsgPack <NetworkMessageContainer>(rv)); }); }
/// <summary> /// Publishes the message, using channelType and channelId to route the message appropriately /// </summary> /// <param name="channelType"></param> /// <param name="channelId"></param> /// <param name="msg"></param> public Task PublishObjectAsync(ChannelTypes channelType, int channelId, NetworkMessageContainer msg) { return(_sub.PublishAsync(channelType.ToString() + channelId.ToString(), msg.Serialize())); }