예제 #1
0
        public void SendMessageToClient(ClientStructure client, IServerMessageBase message)
        {
            var outmsg = Server.CreateMessage(message.GetMessageSize());

            message.Data.SentTime = LunaTime.UtcNow.Ticks;
            message.Serialize(outmsg);

            client.LastSendTime = ServerContext.ServerClock.ElapsedMilliseconds;
            client.BytesSent   += outmsg.LengthBytes;

            var sendResult = Server.SendMessage(outmsg, client.Connection, message.NetDeliveryMethod, message.Channel);

            Server.FlushSendQueue(); //Manually force to send the msg
        }
예제 #2
0
        public static void SendMessageToClient(ClientStructure client, IServerMessageBase message)
        {
            //var msg = ServerContext.ServerMessageFactory.CreateNew<NetOutgoingMessage>(message.Data);

            var outmsg = Server.CreateMessage(message.GetMessageSize());

            message.Data.SentTime = LunaNetworkTime.UtcNow.Ticks;
            message.Serialize(outmsg);
            client.LastSendTime = ServerContext.ServerClock.ElapsedMilliseconds;
            client.BytesSent   += (uint)outmsg.LengthBytes;
            try
            {
                Server.SendMessage(outmsg, client.Connection, message.NetDeliveryMethod, message.Channel);
            }
            catch (Exception e)
            {
                ClientException.HandleDisconnectException("Send network message error: ", client, e);
                return;
            }

            Plugin.LmpPluginHandler.FireOnMessageSent(client, message);
        }