Esempio n. 1
0
 /// <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);
         }
     });
 }
Esempio n. 2
0
 /// <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());
 }
Esempio n. 3
0
 public void UnSubscribe(ChannelTypes channelType, int channelID, EventHandler <NetworkMessageContainer> callback)
 {
     _sub.Unsubscribe(channelType.ToString() + channelID.ToString(), (rc, rv) => { callback(this, SerializationUtilities.DeserializeMsgPack <NetworkMessageContainer>(rv)); });
 }
Esempio n. 4
0
 /// <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()));
 }