Exemplo n.º 1
0
        /// <summary>
        /// Send an IGameMessage message to all connected clients except sender of the message.
        /// </summary>
        /// <param name="Message">Message to be send.</param>
        public void SendMessage(IGameMessage Message)
        {
            try
            {
                List <NetConnection> AllConnections = this.m_networkClass.m_netServer.Connections;
                AllConnections.Remove(this.netConnection);

                if (AllConnections.Count > 0)
                {
                    NetOutgoingMessage netOutgoingMessage = this.m_networkClass.m_netServer.CreateMessage();

                    netOutgoingMessage.Write((byte)Message.MessageType);
                    Message.EncodeMessage(netOutgoingMessage);

                    this.m_networkClass.m_netServer.SendMessage(netOutgoingMessage, AllConnections, NetDeliveryMethod.ReliableOrdered, 0);
                }
            }
            catch (Exception e)
            {
                Log.HandleEmptyMessage();
                Log.HandleLog(LOGMessageTypes.Error, e.ToString());
                Log.HandleEmptyMessage();
            }
        }