Beispiel #1
0
        /// <summary>
        /// Checks to see if their are any Subscribers to the broadcasted message
        /// and invokes ALL callbacks associated with it
        /// </summary>
        ///
        /// <param name="message">The message to be broadcasted (case sensitive)</param>
        /// <param name="data">Packet of information to be used by ALL recieving parties</param>
        ///
        /// <returns>
        /// 0 the message was broadcasted successfully
        /// 1 the message was blocked, but is now valid, and has been broadcasted
        /// -1 the message is blocked
        /// </returns>
        public int NotifySubscribers(string message, Callback.Packet data)
        {
            // Temporary BlockedMessage for checking blacklist
            BlockedMessage blocked;

            // Value to be returned
            int returnValue = 0;


            if (blockedMessages.TryGetValue(message, out blocked))
            {
                if (blocked.blockTime < 0 || --blocked.blockTime > 0)
                {
                    return(-1);
                }

                else if (blocked.blockTime == 0)
                {
                    UnblockMessage(message);
                    returnValue++;
                }
            }

            // Temporary delegate container for modifying subscription delegates
            Callback.Callback cb;

            // Check to see if the message has any valid subscriptions
            if (instance.subscriptions.TryGetValue(message, out cb))
            {
                // Invokes ALL associated delegates with the data Packet as the argument
                cb.Invoke(data);
            }

            return(returnValue);
        }
Beispiel #2
0
        /// <summary>
        /// Checks to see if their are any Subscribers to the broadcasted message
        /// and invokes ALL callbacks associated with it
        /// </summary>
        /// <param name="message">The message to be broadcasted (case sensitive)</param>
        /// <param name="data">Packet of information to be used by ALL recieving parties</param>
        public void NotifySubscribers(string message, Callback.Packet data)
        {
            // Temporary delegate container for modifying subscription delegates
            Callback.Callback cb;

            // Check to see if the message has any valid subscriptions
            if (instance.subscriptions.TryGetValue(message, out cb))
            {
                // Invokes ALL associated delegates with the data Packet as the argument
                cb.Invoke(data);
            }
        }
Beispiel #3
0
 /// <summary>
 /// Checks to see if their are any Subscribers to the broadcasted message
 /// and invokes ALL callbacks associated with it with an empty packet
 /// </summary>
 ///
 /// <param name="message">The message to be broadcasted (case sensitive)</param>
 ///
 /// <returns>
 /// 0 the message was broadcasted successfully
 /// 1 the message was blocked, but is now valid
 /// -1 the message is blocked
 /// </returns>
 public int NotifySubscribers(string message)
 {
     Callback.Packet data = new Callback.Packet();
     return(NotifySubscribers(message, data));
 }