示例#1
0
        /// <summary>
        /// "controllerDest" of "m" is the target controller... 0 (for unity), 1, 2, 3...  (if -1 then for ALL controllers)
        /// "controllerIndex" of l is the receiving controller.  Same as dest...  -1 is wildcard for all messages
        /// </summary>
        public void SendToListeners(ControllerMessage msg)
        {
            List <BCListener> deadListeners = new List <BCListener>();

            UpdateSafeList();
            foreach (BCListener bcListener in m_BCListenersSafe)
            {
                if (bcListener == null)
                {
                    deadListeners.Add(bcListener);
                }
                else
                {
                    bcListener.OnGameMessage(msg);
                }

                // send to attached controllers
                RouteControllerMessages(msg);
            }

            foreach (BCListener bcListener in deadListeners)
            {
                RemoveListener(bcListener);
            }

            UpdateSafeList();
        }
示例#2
0
 public void OnGameMessage(ControllerMessage msg)
 {
     UpdateSafeList();
     foreach (Listener listener in m_ListenersSafe.FindAll(bcListener => ((msg.ControllerDest < 0) || (bcListener.m_ControllerIndex < 0) ||
                                                                          (bcListener.m_ControllerIndex == msg.ControllerDest)) &&
                                                           ((bcListener.m_MessageType == "*") || (bcListener.m_MessageType == msg.Name))))
     {
         this.gameObject.BroadcastMessage(listener.m_Handler, msg, SendMessageOptions.RequireReceiver);
     }
     UpdateSafeList();
 }
示例#3
0
 /// <summary>
 /// Forwards messages to the controllers... listens for any "controller" messages (msgs > 0)
 /// and sends them.
 /// </summary>
 private void RouteControllerMessages(ControllerMessage msg)
 {
     // just messages for controllers... (-1 dest is for ALL)
     if ((msg.ControllerDest > 0) || (msg.ControllerDest < 0))
     {
         JSONObject json = msg.Payload;
         json.AddField("type", msg.Name);
         json.AddField("controller_dest", msg.ControllerDest.ToString());
         //Debug.Log ("Game Message Sent: " + json.ToString ());
         BCLibProvider.Instance.BladeCast_Game_SendMessage(json);
     }
 }
示例#4
0
 /// <summary>
 /// "controllerDest" of "m" is the target controller... 0 (for unity), 1, 2, 3...  (if -1 then for ALL controllers)
 /// "controllerIndex" of l is the receiving controller.  Same as dest...  -1 is wildcard for all messages
 /// </summary>
 public void SendToListeners(ControllerMessage msg)
 {
     BCMessenger.Instance.SendToListeners(msg);
 }