public void ReceiveMessage(SubspaceMessage _message)
 {
     if (_message.GetMessageCode() == 1)
     {
         Logger.Log("Received message. Channel " + _message.GetMessageChannel() + " Message Code: " + _message.GetMessageCode()); //Log the message info to console.
     }
 }
Exemplo n.º 2
0
        /**
         * Sends a message along a channel in Subspace. Returns true if the message was sent.
         */
        public static Boolean SendSubspaceMessage(SubspaceMessage _message)
        {
            if (ChannelMap.ContainsKey(_message.GetMessageChannel()) == false) return false;

            foreach (ISubspaceInterface sSI in ChannelMap[_message.GetMessageChannel()])
            {
                sSI.ReceiveMessage(_message);
            }

            return true;
        }
 /**
  * All plug-ins using Subspace must implement this function. It gets called when
  * a message is sent along a channel.
  */
 public void ReceiveMessage(SubspaceMessage _message)
 {
     /**
      * Use some data in the message. Here we are getting the message code. Which is simply
      * any number you would like to use so other plugins know what "type" of message this is
      * and do the proper logic. In this case we are using it to see if the message is from the
      * second example plug-in to prevent showing our own message as well.
      */
     if (_message.GetMessageCode() == 2)
     {
         Logger.Log("Received message. Channel " + _message.GetMessageChannel()
                    + " Message Code: " + _message.GetMessageCode()); //Log the message info to console.
     }
 }
        private SubspaceMessage subspaceMessage; //The message object to send.

        #endregion Fields

        #region Constructors

        public SubspaceExample1()
        {
            /**
             * When creating a message the channel and message code must be provided.
             * As mentioned above these can be anything you wish.
             */
            subspaceMessage = new SubspaceMessage(messageChannel, messageCode);

            /**
             * Subscribe this plug-in to receive Subspace messages on channel 0.
             * Any plug-in that implements the ISubspaceInterface can subscribe.
             */
            Subspace.SubscribeToChannel(0, this);
        }
        public SubspaceExample2()
        {
            subspaceMessage = new SubspaceMessage(messageChannel, messageCode);

            Subspace.SubscribeToChannel(0, this);
        }