예제 #1
0
 /// <summary>
 /// Server-side method to handle instantiation messages from client-side components
 /// asking for initialization data
 /// </summary>
 /// <param name="message">Message from client</param>
 protected void HandleComponentInstantiationMessage(IncomingEntityMessage message)
 {
     if (HasComponent((ComponentFamily)message.Message))
     {
         GetComponent <Component>((ComponentFamily)message.Message).HandleInstantiationMessage(message.Sender);
     }
 }
예제 #2
0
 /// <summary>
 /// Func to handle an incoming network message
 /// </summary>
 /// <param name="message"></param>
 public virtual void HandleNetworkMessage(IncomingEntityMessage message)
 {
     switch (message.Message.Type)
     {
     case EntityMessage.ComponentMessage:
         HandleComponentMessage(new IncomingEntityComponentMessage(message.Message.NetId, message.Message.Parameters), message.Message.Sender);
         break;
     }
 }
예제 #3
0
        /// <summary>
        /// Server-side method to handle instantiation messages from client-side components
        /// asking for initialization data
        /// </summary>
        /// <param name="message">Message from client</param>
        protected void HandleComponentInstantiationMessage(IncomingEntityMessage message)
        {
            uint netID = (uint)message.Message;

            if (!_netIDs.ContainsKey(netID))
            {
                return;
            }
            _netIDs[netID].HandleInstantiationMessage(message.Sender);
        }
예제 #4
0
        /// <summary>
        /// Func to handle an incoming network message
        /// </summary>
        /// <param name="message"></param>
        public virtual void HandleNetworkMessage(IncomingEntityMessage message)
        {
            switch (message.MessageType)
            {
            case EntityMessage.ComponentMessage:
                HandleComponentMessage((IncomingEntityComponentMessage)message.Message, message.Sender);
                break;

            case EntityMessage.ComponentInstantiationMessage:     //Server Only
                HandleComponentInstantiationMessage(message);
                break;
            }
        }
예제 #5
0
        protected void ProcessMsgBuffer()
        {
            if (!Started)
            {
                return;
            }
            if (!MessageBuffer.Any())
            {
                return;
            }
            var misses = new List <IncomingEntityMessage>();

            while (MessageBuffer.Any())
            {
                IncomingEntityMessage incomingEntity = MessageBuffer.Dequeue();
                if (!Entities.ContainsKey(incomingEntity.Message.EntityUid))
                {
                    incomingEntity.LastProcessingAttempt = DateTime.Now;
                    if ((incomingEntity.LastProcessingAttempt - incomingEntity.ReceivedTime).TotalSeconds > incomingEntity.Expires)
                    {
                        misses.Add(incomingEntity);
                    }
                }
                else
                {
                    Entities[incomingEntity.Message.EntityUid].HandleNetworkMessage(incomingEntity);
                }
            }

            foreach (IncomingEntityMessage miss in misses)
            {
                MessageBuffer.Enqueue(miss);
            }

            MessageBuffer.Clear(); //Should be empty at this point anyway.
        }
예제 #6
0
 /// <summary>
 /// Handle an incoming network message by passing the message to the EntityNetworkManager
 /// and handling the parsed result.
 /// </summary>
 /// <param name="msg">Incoming raw network message</param>
 public void HandleEntityNetworkMessage(NetIncomingMessage msg)
 {
     if (!Initialized)
     {
         IncomingEntityMessage emsg = ProcessNetMessage(msg);
         if (emsg.MessageType != EntityMessage.Null)
         {
             MessageBuffer.Enqueue(emsg);
         }
     }
     else
     {
         ProcessMsgBuffer();
         IncomingEntityMessage emsg = ProcessNetMessage(msg);
         if (!_entities.ContainsKey(emsg.Uid))
         {
             MessageBuffer.Enqueue(emsg);
         }
         else
         {
             _entities[emsg.Uid].HandleNetworkMessage(emsg);
         }
     }
 }
예제 #7
0
        protected void ProcessMsgBuffer()
        {
            if (!Initialized)
            {
                return;
            }
            if (!MessageBuffer.Any())
            {
                return;
            }
            var misses = new List <IncomingEntityMessage>();

            while (MessageBuffer.Any())
            {
                IncomingEntityMessage entMsg = MessageBuffer.Dequeue();
                if (!_entities.ContainsKey(entMsg.Uid))
                {
                    entMsg.LastProcessingAttempt = DateTime.Now;
                    if ((entMsg.LastProcessingAttempt - entMsg.ReceivedTime).TotalSeconds > entMsg.Expires)
                    {
                        misses.Add(entMsg);
                    }
                }
                else
                {
                    _entities[entMsg.Uid].HandleNetworkMessage(entMsg);
                }
            }

            foreach (IncomingEntityMessage miss in misses)
            {
                MessageBuffer.Enqueue(miss);
            }

            MessageBuffer.Clear(); //Should be empty at this point anyway.
        }