/// <summary>
 /// Initializes a new instance of the ReliableUdpSubscribeObject class using the specified
 /// callback method, message type and ip endpoint.
 /// </summary>
 /// <param name="callback">Callback method to receive messages</param>
 /// <param name="messageType">Message type to receive </param>
 /// <param name="ipEndPoint">Ip endpoint to receive from </param>
 internal ReliableUdpSubscribeObject(ReliableUdpMessageCallback callback,
                                     ReliableUdpMessageTypes messageType = ReliableUdpMessageTypes.Any, IPEndPoint ipEndPoint = null)
 {
     IpEndPoint                 = ipEndPoint;
     ReliableUdpMessageType     = messageType;
     ReliableUdpMessageCallback = callback;
 }
 /// <summary>
 /// Unsubscribes from reception of messages
 /// </summary>
 /// <param name="callback">Callback method that is used to subscribe to messages.
 /// If the same method was used for a set of subscriptions, all its subscriptions will be removed </param>
 internal void Unsubscribe(ReliableUdpMessageCallback callback)
 {
     try
     {
         System.Threading.Monitor.Enter(m_locker);
         foreach (ReliableUdpSubscribeObject subscriber in m_subscribers.ToArray())
         {
             if (subscriber.ReliableUdpMessageCallback == callback)
             {
                 m_subscribers.Remove(subscriber);
             }
         }
     }
     finally
     {
         System.Threading.Monitor.Exit(m_locker);
     }
 }
 /// <summary>
 /// Subscribes for reception of <see cref="ReliableUdpMessage"/> messages
 /// </summary>
 /// <param name="callback">Сallback method to receive messages</param>
 /// <param name="messageType">Message type to receive. Use ReliableUdpMessageTypes.Any
 ///  to receive all messages that comes from specified ip endpoint </param>
 /// <param name="ipEndPoint">Defines from what IP address and port to receive messages.
 /// Set IPEndPoint.Port property in 0 for obtaining messages from any port of the specified address.
 /// Set <c>null</c> to receive messages from any ip endpoint </param>
 /// <returns><see cref="ReliableUdpSubscribeObject"/>. Represents a subscriber.</returns>
 internal ReliableUdpSubscribeObject SubscribeOnMessages(ReliableUdpMessageCallback callback,
                                                         ReliableUdpMessageTypes messageType, IPEndPoint ipEndPoint)
 {
     try
     {
         System.Threading.Monitor.Enter(m_locker);
         ReliableUdpSubscribeObject subscribe = new ReliableUdpSubscribeObject(callback, messageType, ipEndPoint);
         if (m_subscribers.Contains(subscribe))
         {
             return(m_subscribers[m_subscribers.IndexOf(subscribe)]);
         }
         m_subscribers.Add(subscribe);
         return(subscribe);
     }
     finally
     {
         System.Threading.Monitor.Exit(m_locker);
     }
 }
 /// <summary>
 /// Unsubscribes from reception of messages
 /// </summary>
 /// <param name="callback">Callback method that is used to subscribe to messages.
 /// If the same method was used for a set of subscriptions, all its subscriptions will be removed </param>
 internal void Unsubscribe(ReliableUdpMessageCallback callback)
 {
     try
       {
     System.Threading.Monitor.Enter(m_locker);
     foreach (ReliableUdpSubscribeObject subscriber in m_subscribers.ToArray())
     {
       if (subscriber.ReliableUdpMessageCallback == callback)
       {
     m_subscribers.Remove(subscriber);
       }
     }
       }
       finally
       {
     System.Threading.Monitor.Exit(m_locker);
       }
 }
 /// <summary>
 /// Subscribes for reception of <see cref="ReliableUdpMessage"/> messages
 /// </summary>
 /// <param name="callback">Сallback method to receive messages</param>
 /// <param name="messageType">Message type to receive. Use ReliableUdpMessageTypes.Any
 ///  to receive all messages that comes from specified ip endpoint </param>
 /// <param name="ipEndPoint">Defines from what IP address and port to receive messages. 
 /// Set IPEndPoint.Port property in 0 for obtaining messages from any port of the specified address.
 /// Set <c>null</c> to receive messages from any ip endpoint </param>
 /// <returns><see cref="ReliableUdpSubscribeObject"/>. Represents a subscriber.</returns>
 internal ReliableUdpSubscribeObject SubscribeOnMessages(ReliableUdpMessageCallback callback,
     ReliableUdpMessageTypes messageType, IPEndPoint ipEndPoint)
 {
     try
       {
     System.Threading.Monitor.Enter(m_locker);
     ReliableUdpSubscribeObject subscribe = new ReliableUdpSubscribeObject(callback, messageType, ipEndPoint);
     if (m_subscribers.Contains(subscribe))
     {
       return m_subscribers[m_subscribers.IndexOf(subscribe)];
     }
     m_subscribers.Add(subscribe);
     return subscribe;
       }
       finally
       {
     System.Threading.Monitor.Exit(m_locker);
       }
 }
Пример #6
0
 /// <summary>
 /// Unsubscribes from reception of messages
 /// </summary>
 /// <param name="callback">Callback method that is used to subscribe to messages.
 /// If the same method was used for a set of subscriptions, all its subscriptions will be removed </param>
 public void Unsubscribe(ReliableUdpMessageCallback callback)
 {
     m_tcb.Unsubscribe(callback);
 }
Пример #7
0
 /// <summary>
 /// Subscribes for reception of <see cref="ReliableUdpMessage"/> messages
 /// </summary>
 /// <param name="callback">Сallback method to receive messages</param>
 /// <param name="messageType">Message type to receive. Use ReliableUdpMessageTypes.Any
 ///  to receive all messages that comes from specified ip endpoint </param>
 /// <param name="ipEndPoint">Defines from what IP address and port to receive messages. 
 /// Set IPEndPoint.Port property in 0 for obtaining messages from any port of the specified address.
 /// Set <c>null</c> to receive messages from any ip endpoint </param>
 /// <returns><see cref="ReliableUdpSubscribeObject"/>. Represents a subscriber.</returns>
 public ReliableUdpSubscribeObject SubscribeOnMessages(ReliableUdpMessageCallback callback,
                                                   ReliableUdpMessageTypes messageType =
                                                     ReliableUdpMessageTypes.Any, IPEndPoint ipEndPoint = null)
 {
     return m_tcb.SubscribeOnMessages(callback, messageType, ipEndPoint);
 }
Пример #8
0
 /// <summary>
 /// Unsubscribes from reception of messages
 /// </summary>
 /// <param name="callback">Callback method that is used to subscribe to messages.
 /// If the same method was used for a set of subscriptions, all its subscriptions will be removed </param>
 public void Unsubscribe(ReliableUdpMessageCallback callback)
 {
     m_tcb.Unsubscribe(callback);
 }
Пример #9
0
 /// <summary>
 /// Subscribes for reception of <see cref="ReliableUdpMessage"/> messages
 /// </summary>
 /// <param name="callback">Сallback method to receive messages</param>
 /// <param name="messageType">Message type to receive. Use ReliableUdpMessageTypes.Any
 ///  to receive all messages that comes from specified ip endpoint </param>
 /// <param name="ipEndPoint">Defines from what IP address and port to receive messages.
 /// Set IPEndPoint.Port property in 0 for obtaining messages from any port of the specified address.
 /// Set <c>null</c> to receive messages from any ip endpoint </param>
 /// <returns><see cref="ReliableUdpSubscribeObject"/>. Represents a subscriber.</returns>
 public ReliableUdpSubscribeObject SubscribeOnMessages(ReliableUdpMessageCallback callback,
                                                       ReliableUdpMessageTypes messageType =
                                                       ReliableUdpMessageTypes.Any, IPEndPoint ipEndPoint = null)
 {
     return(m_tcb.SubscribeOnMessages(callback, messageType, ipEndPoint));
 }