public void SendMessageToClient(ClientStructure client, IServerMessageBase message) { if (message.MessageType == ServerMessageType.SyncTime) { SyncTimeSystem.RewriteMessage(client, message); } message.Data.SentTime = DateTime.UtcNow.Ticks; var messageBytes = message.Serialize(GeneralSettings.SettingsStore.CompressionEnabled); if (messageBytes == null) { LunaLog.Error("Error serializing message!"); return; } client.LastSendTime = ServerContext.ServerClock.ElapsedMilliseconds; client.BytesSent += messageBytes.Length; var outmsg = Server.CreateMessage(messageBytes.Length); outmsg.Write(messageBytes); Server.SendMessage(outmsg, client.Connection, message.NetDeliveryMethod, message.Channel); Server.FlushSendQueue(); //Manually force to send the msg }
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 }
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); }