Exemplo n.º 1
0
        /// <summary>
        /// Send Message To Client
        /// </summary>
        /// <param name="msg">GameMessage</param>
        /// <param name="client">Client we want to send. Send to all connected client if it's null</param>
        public void SendMessage(GameMessage msg)
        {
            NetOutgoingMessage om = this._client.CreateMessage();

            var b = SerializeTools.Serialize(msg);

            om.Write(b);
            om.Encrypt(this._algo);

            if (this._client.ConnectionStatus == NetConnectionStatus.Connected)
            {
                this._client.SendMessage(om, this._client.ServerConnection, NetDeliveryMethod.ReliableOrdered);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Send Message To Client
        /// </summary>
        /// <param name="msg">GameMessage</param>
        /// <param name="client">Client we want to send. Send to all connected client if it's null</param>
        public void SendMessage(GameMessage msg, NetConnection client = null)
        {
            NetOutgoingMessage om = this._server.CreateMessage();

            var b = SerializeTools.Serialize(msg);

            om.Write(b);
            om.Encrypt(this._algo);

            Console.ForegroundColor = ConsoleColor.Cyan;
            var clientId = client is null ? "All" : NetUtility.ToHexString(client.RemoteUniqueIdentifier);

            Console.WriteLine($"  Send  Message  To  {clientId}::MsgCode:{(Int32)msg.MsgCode},Content:{msg.Content}");
            Console.ResetColor();
            this._server.SendMessage(om, client, NetDeliveryMethod.ReliableOrdered);
        }