private static void HandleVesselList(VesselListReplyMsgData messageData) { var serverVessels = new List <string>(messageData.Vessels); var cacheObjects = new List <string>(UniverseSyncCache.Singleton.GetCachedObjects()); var requestedObjects = new List <string>(); foreach (var serverVessel in serverVessels) { if (!cacheObjects.Contains(serverVessel)) { requestedObjects.Add(serverVessel); } else { //Try to get it from cache... var vesselBytes = UniverseSyncCache.Singleton.GetFromCache(serverVessel); var vesselNode = ConfigNodeSerializer.Singleton.Deserialize(vesselBytes); if (vesselNode != null) { var vesselIdString = Common.ConvertConfigStringToGuidString(vesselNode.GetValue("pid")); var vesselId = new Guid(vesselIdString); if (vesselBytes.Length != 0 && vesselId != Guid.Empty) { System.AllPlayerVessels.Add(new VesselProtoUpdate { Loaded = false, VesselId = vesselId, VesselNode = vesselNode }); } else { Debug.LogError($"[LMP]: Cached object {serverVessel} is damaged"); requestedObjects.Add(serverVessel); } } } } NetworkSender.QueueOutgoingMessage(MessageFactory.CreateNew <VesselCliMsg> (new VesselsRequestMsgData { RequestList = requestedObjects.ToArray() })); }
/// <summary> /// Here we receive the vessel list msg from the server.We rty to get the vessels from the cache and if /// it fails or we don't have it in the cache we request that vessel info to the server. /// </summary> private static void HandleVesselList(VesselListReplyMsgData messageData) { var serverVessels = new List <string>(messageData.Vessels); var cacheObjects = new List <string>(UniverseSyncCache.GetCachedObjects()); var requestedObjects = new List <string>(); foreach (var serverVessel in serverVessels) { if (cacheObjects.Contains(serverVessel)) { //Try to get it from cache... var vesselBytes = UniverseSyncCache.GetFromCache(serverVessel); var vesselNode = ConfigNodeSerializer.Deserialize(vesselBytes); if (vesselNode != null) { var vesselId = Common.ConvertConfigStringToGuid(vesselNode.GetValue("pid")); if (vesselBytes.Length != 0 && vesselId != Guid.Empty) { var update = new VesselProtoUpdate(vesselNode, vesselId); if (update.ProtoVessel != null) { System.AllPlayerVessels.TryAdd(vesselId, update); } } else { LunaLog.LogError($"[LMP]: Cached object {serverVessel} is damaged"); requestedObjects.Add(serverVessel); } } } else { requestedObjects.Add(serverVessel); } } //Request the vessel data that we don't have. NetworkSender.QueueOutgoingMessage(MessageFactory.CreateNew <VesselCliMsg> (new VesselsRequestMsgData { RequestList = requestedObjects.ToArray() })); }
public void SendMessage(IMessageData msg) { TaskFactory.StartNew(() => NetworkSender.QueueOutgoingMessage(MessageFactory.CreateNew <PlayerColorCliMsg>(msg))); }
public void SendColorsRequest() { TaskFactory.StartNew(() => NetworkSender.QueueOutgoingMessage(NetworkMain.CliMsgFactory.CreateNew <PlayerColorCliMsg, PlayerColorRequestMsgData>())); }
public void SendMessage(IMessageData msg) { NetworkSender.QueueOutgoingMessage(MessageFactory.CreateNew <VesselCliMsg>(msg)); }
public void SendSettingsRequest() { TaskFactory.StartNew(() => NetworkSender.QueueOutgoingMessage(NetworkMain.CliMsgFactory.CreateNew <SettingsCliMsg, SettingsRequestMsgData>())); }
public void SendMessage(IMessageData messageData) { TaskFactory.StartNew(() => NetworkSender.QueueOutgoingMessage(MessageFactory.CreateNew <ChatCliMsg>(messageData))); }
public void SendLocksRequest() { TaskFactory.StartNew(() => NetworkSender.QueueOutgoingMessage(NetworkMain.CliMsgFactory.CreateNew<LockCliMsg, LockListRequestMsgData>())); }
public void SendWarpSubspacesRequest() { TaskFactory.StartNew(() => NetworkSender.QueueOutgoingMessage(NetworkMain.CliMsgFactory.CreateNew <WarpCliMsg, WarpSubspacesRequestMsgData>())); }