public static void HandleMessage(ClientStructure client, IClientMessageBase message) { var messageData = message.Data as PlayerStatusBaseMsgData; switch (messageData?.PlayerStatusMessageType) { case PlayerStatusMessageType.Request: SendOtherPlayerStatusesToNewPlayer(client); //We don't use this message anymore so we can recycle it message.Recycle(); break; case PlayerStatusMessageType.Set: var data = (PlayerStatusSetMsgData)messageData; if (data.PlayerStatus.PlayerName != client.PlayerName) { return; } client.PlayerStatus.VesselText = data.PlayerStatus.VesselText; client.PlayerStatus.StatusText = data.PlayerStatus.StatusText; MessageQueuer.RelayMessage <PlayerStatusSrvMsg>(client, data); break; } }
public override void HandleMessage(ClientStructure client, IClientMessageBase message) { var data = (CraftLibraryBaseMsgData)message.Data; if (data.PlayerName != client.PlayerName) { return; } switch (data.CraftMessageType) { case CraftMessageType.UploadFile: CraftLibraryHandler.HandleUploadFileMessage(client, (CraftLibraryUploadMsgData)data); break; case CraftMessageType.RequestFile: CraftLibraryHandler.HandleRequestFileMessage(client, (CraftLibraryRequestMsgData)data); break; case CraftMessageType.DeleteFile: CraftLibraryHandler.HandleDeleteFileMessage(client, (CraftLibraryDeleteMsgData)data); break; case CraftMessageType.ListRequest: //We don't use this message anymore so we can recycle it message.Recycle(); CraftLibrarySystem.SendCraftList(client); break; default: throw new ArgumentOutOfRangeException(); } }
public static void HandleMessage(ClientStructure client, IClientMessageBase message) { var data = message.Data as KerbalBaseMsgData; switch (data?.KerbalMessageType) { case KerbalMessageType.Request: KerbalSystem.HandleKerbalsRequest(client); //We don't use this message anymore so we can recycle it message.Recycle(); break; case KerbalMessageType.Proto: KerbalSystem.HandleKerbalProto(client, (KerbalProtoMsgData)data); break; case KerbalMessageType.Remove: KerbalSystem.HandleKerbalRemove(client, (KerbalRemoveMsgData)data); break; default: throw new NotImplementedException("Kerbal type not implemented"); } }
public override void HandleMessage(ClientStructure client, IClientMessageBase message) { var messageData = message.Data as PlayerColorBaseMsgData; switch (messageData?.PlayerColorMessageType) { case PlayerColorMessageType.Request: SendAllPlayerColors(client); //We don't use this message anymore so we can recycle it message.Recycle(); break; case PlayerColorMessageType.Set: var data = (PlayerColorSetMsgData)messageData; if (data.PlayerColor.PlayerName != client.PlayerName) { return; } Array.Copy(data.PlayerColor.Color, client.PlayerColor, data.PlayerColor.Color.Length); MessageQueuer.RelayMessage <PlayerColorSrvMsg>(client, data); break; } }
public static void HandleMessage(ClientStructure client, IClientMessageBase message) { var data = (GroupBaseMsgData)message.Data; switch (data.GroupMessageType) { case GroupMessageType.ListRequest: var msgData = ServerContext.ServerMessageFactory.CreateNewMessageData <GroupListResponseMsgData>(); msgData.Groups = GroupSystem.Groups.Values.ToArray(); msgData.GroupsCount = msgData.Groups.Length; MessageQueuer.SendToClient <GroupSrvMsg>(client, msgData); //We don't use this message anymore so we can recycle it message.Recycle(); break; case GroupMessageType.CreateGroup: GroupSystem.CreateGroup(client.PlayerName, ((GroupCreateMsgData)data).GroupName); break; case GroupMessageType.RemoveGroup: GroupSystem.RemoveGroup(client.PlayerName, ((GroupRemoveMsgData)data).GroupName); break; case GroupMessageType.GroupUpdate: GroupSystem.UpdateGroup(client.PlayerName, ((GroupUpdateMsgData)data).Group); break; } }
public override void HandleMessage(ClientStructure client, IClientMessageBase message) { var data = message.Data as HandshakeBaseMsgData; switch (data?.HandshakeMessageType) { case HandshakeMessageType.Request: SetAndSendHandshakeChallangeMessage(client); break; case HandshakeMessageType.Response: try { HandshakeHandler.HandleHandshakeResponse(client, (HandshakeResponseMsgData)data); } catch (Exception e) { LunaLog.Debug($"Error in HANDSHAKE_REQUEST from {((HandshakeResponseMsgData)data).PlayerName}: {e}"); HandshakeSystemSender.SendHandshakeReply(client, HandshakeReply.MalformedHandshake, "Malformed handshake"); } break; default: throw new NotImplementedException("Handshake type not implemented"); } //We don't use this message so we can recycle it message.Recycle(); }
public override void HandleMessage(ClientStructure client, IClientMessageBase message) { var data = (LockBaseMsgData)message.Data; switch (data.LockMessageType) { case LockMessageType.ListRequest: LockSystemSender.SendAllLocks(client); //We don't use this message anymore so we can recycle it message.Recycle(); break; case LockMessageType.Acquire: var acquireData = (LockAcquireMsgData)data; if (acquireData.Lock.PlayerName == client.PlayerName) { LockSystemSender.SendLockAcquireMessage(client, acquireData.Lock, acquireData.Force); } break; case LockMessageType.Release: var releaseData = (LockReleaseMsgData)data; if (releaseData.Lock.PlayerName == client.PlayerName) { LockSystemSender.ReleaseAndSendLockReleaseMessage(client, releaseData.Lock); } break; default: throw new ArgumentOutOfRangeException(); } }
public override void HandleMessage(ClientStructure client, IClientMessageBase message) { var messageData = message.Data as VesselBaseMsgData; switch (messageData?.VesselMessageType) { case VesselMessageType.Sync: HandleVesselsSync(client, messageData); message.Recycle(); break; case VesselMessageType.Proto: HandleVesselProto(client, messageData); break; case VesselMessageType.Dock: HandleVesselDock(client, messageData); break; case VesselMessageType.Remove: HandleVesselRemove(client, messageData); break; case VesselMessageType.Position: VesselRelaySystem.HandleVesselMessage(client, messageData); if (!GeneralSettings.SettingsStore.ShowVesselsInThePast || client.Subspace == WarpContext.LatestSubspace) { VesselDataUpdater.WritePositionDataToFile(messageData); } break; case VesselMessageType.Flightstate: VesselRelaySystem.HandleVesselMessage(client, messageData); break; case VesselMessageType.Update: VesselDataUpdater.WriteUpdateDataToFile(messageData); MessageQueuer.RelayMessage <VesselSrvMsg>(client, messageData); break; case VesselMessageType.Resource: VesselDataUpdater.WriteResourceDataToFile(messageData); MessageQueuer.RelayMessage <VesselSrvMsg>(client, messageData); break; case VesselMessageType.PartSync: VesselDataUpdater.WriteModuleDataToFile(messageData); MessageQueuer.RelayMessage <VesselSrvMsg>(client, messageData); break; case VesselMessageType.Fairing: VesselDataUpdater.WriteFairingDataToFile(messageData); MessageQueuer.RelayMessage <VesselSrvMsg>(client, messageData); break; default: throw new NotImplementedException("Vessel message type not implemented"); } }
public override void HandleMessage(ClientStructure client, IClientMessageBase message) { var data = message.Data as HandshakeBaseMsgData; switch (data?.HandshakeMessageType) { case HandshakeMessageType.Request: HandshakeHandler.HandleHandshakeRequest(client, (HandshakeRequestMsgData)data); break; default: throw new NotImplementedException("Handshake type not implemented"); } message.Recycle(); }
public override void HandleMessage(ClientStructure client, IClientMessageBase message) { var data = (AdminBaseMsgData)message.Data; switch (data.AdminMessageType) { case AdminMessageType.ListRequest: AdminSystemSender.SendAdminList(client); //We don't use this message anymore so we can recycle it message.Recycle(); break; default: throw new ArgumentOutOfRangeException(); } }
public static void HandleMessage(ClientStructure client, IClientMessageBase message) { var data = (FlagBaseMsgData)message.Data; switch (data.FlagMessageType) { case FlagMessageType.ListRequest: FlagSystem.HandleFlagListRequestMessage(client); //We don't use this message anymore so we can recycle it message.Recycle(); break; case FlagMessageType.FlagData: FlagSystem.HandleFlagDataMessage(client, (FlagDataMsgData)data); break; } }
public override void HandleMessage(ClientStructure client, IClientMessageBase message) { var messageData = message.Data as ScenarioBaseMsgData; switch (messageData?.ScenarioMessageType) { case ScenarioMessageType.Request: ScenarioSystem.SendScenarioModules(client); break; case ScenarioMessageType.Data: ScenarioSystem.ParseReceivedScenarioData(client, messageData); break; } //We don't use this message anymore so we can recycle it message.Recycle(); }
public override void HandleMessage(ClientStructure client, IClientMessageBase message) { //We don't use this message anymore so we can recycle it message.Recycle(); var newMotd = GeneralSettings.SettingsStore.ServerMotd; if (newMotd.Length > 255) { newMotd = newMotd.Substring(0, 255); //We don't wanna send a huuuge message! } newMotd = newMotd.Replace("%Name%", client.PlayerName).Replace(@"\n", Environment.NewLine); var msgData = ServerContext.ServerMessageFactory.CreateNewMessageData <MotdReplyMsgData>(); msgData.MessageOfTheDay = newMotd; MessageQueuer.SendToClient <MotdSrvMsg>(client, msgData); }
public override void HandleMessage(ClientStructure client, IClientMessageBase message) { var data = (ChatBaseMsgData)message.Data; if (data.From != client.PlayerName) { return; } switch (data.ChatMessageType) { case ChatMessageType.ListRequest: ChatSystem.SendPlayerChatChannels(client); //We don't use this message anymore so we can recycle it message.Recycle(); break; case ChatMessageType.Join: ChatSystemReceiver.HandleJoinMessage(client, (ChatJoinMsgData)data); break; case ChatMessageType.Leave: ChatSystemReceiver.HandleLeaveMessage(client, (ChatLeaveMsgData)data); break; case ChatMessageType.ChannelMessage: ChatSystemReceiver.HandleChannelMessage(client, (ChatChannelMsgData)data); break; case ChatMessageType.PrivateMessage: ChatSystemReceiver.HandlePrivateMessage(client, (ChatPrivateMsgData)data); break; case ChatMessageType.ConsoleMessage: ChatSystemReceiver.HandleConsoleMessage(client, (ChatConsoleMsgData)data); break; default: throw new ArgumentOutOfRangeException(); } }
public override void HandleMessage(ClientStructure client, IClientMessageBase message) { var messageData = message.Data as WarpBaseMsgData; switch (messageData?.WarpMessageType) { case WarpMessageType.NewSubspace: WarpReceiver.HandleNewSubspace(client, (WarpNewSubspaceMsgData)messageData); break; case WarpMessageType.ChangeSubspace: WarpReceiver.HandleChangeSubspace(client, (WarpChangeSubspaceMsgData)messageData); break; case WarpMessageType.SubspacesRequest: WarpSystemSender.SendAllSubspaces(client); //We don't use this message anymore so we can recycle it message.Recycle(); break; default: throw new NotImplementedException("Warp Type not implemented"); } }
public override void HandleMessage(ClientStructure client, IClientMessageBase message) { //We don't use this message anymore so we can recycle it message.Recycle(); var msgData = ServerContext.ServerMessageFactory.CreateNewMessageData <SettingsReplyMsgData>(); msgData.WarpMode = WarpSettings.SettingsStore.WarpMode; msgData.GameMode = GeneralSettings.SettingsStore.GameMode; msgData.TerrainQuality = GeneralSettings.SettingsStore.TerrainQuality; msgData.AllowCheats = GeneralSettings.SettingsStore.Cheats; msgData.AllowAdmin = !string.IsNullOrEmpty(GeneralSettings.SettingsStore.AdminPassword); msgData.AllowSackKerbals = GeneralSettings.SettingsStore.AllowSackKerbals; msgData.AllowQuicksaves = GeneralSettings.SettingsStore.AllowQuicksaves; msgData.MaxNumberOfAsteroids = GeneralSettings.SettingsStore.NumberOfAsteroids; msgData.ConsoleIdentifier = GeneralSettings.SettingsStore.ConsoleIdentifier; msgData.GameDifficulty = GeneralSettings.SettingsStore.GameDifficulty; msgData.SafetyBubbleDistance = GeneralSettings.SettingsStore.SafetyBubbleDistance; msgData.MaxVesselParts = GeneralSettings.SettingsStore.MaxVesselParts; msgData.VesselUpdatesMsInterval = IntervalSettings.SettingsStore.VesselUpdatesMsInterval; msgData.SecondaryVesselUpdatesMsInterval = IntervalSettings.SettingsStore.SecondaryVesselUpdatesMsInterval; msgData.MinScreenshotIntervalMs = ScreenshotSettings.SettingsStore.MinScreenshotIntervalMs; msgData.MaxScreenshotWidth = ScreenshotSettings.SettingsStore.MaxScreenshotWidth; msgData.MaxScreenshotHeight = ScreenshotSettings.SettingsStore.MaxScreenshotHeight; msgData.MinCraftLibraryRequestIntervalMs = CraftSettings.SettingsStore.MinCraftLibraryRequestIntervalMs; msgData.PrintMotdInChat = GeneralSettings.SettingsStore.PrintMotdInChat; if (GeneralSettings.SettingsStore.GameDifficulty == GameDifficulty.Custom && GameplaySettings.SettingsStore != null) { msgData.EnableCommNet = GameplaySettings.SettingsStore.CommNetwork; msgData.RespawnTimer = GameplaySettings.SettingsStore.RespawnTime; msgData.AllowOtherLaunchSites = GameplaySettings.SettingsStore.AllowOtherLaunchSites; msgData.AllowStockVessels = GameplaySettings.SettingsStore.AllowStockVessels; msgData.AutoHireCrews = GameplaySettings.SettingsStore.AutoHireCrews; msgData.BypassEntryPurchaseAfterResearch = GameplaySettings.SettingsStore.BypassEntryPurchaseAfterResearch; msgData.IndestructibleFacilities = GameplaySettings.SettingsStore.IndestructibleFacilities; msgData.MissingCrewsRespawn = GameplaySettings.SettingsStore.MissingCrewsRespawn; msgData.ReentryHeatScale = GameplaySettings.SettingsStore.ReentryHeatScale; msgData.ResourceAbundance = GameplaySettings.SettingsStore.ResourceAbundance; msgData.FundsGainMultiplier = GameplaySettings.SettingsStore.FundsGainMultiplier; msgData.CanRevert = GameplaySettings.SettingsStore.CanRevert; msgData.RepLossDeclined = GameplaySettings.SettingsStore.RepLossDeclined; msgData.FundsLossMultiplier = GameplaySettings.SettingsStore.FundsLossMultiplier; msgData.RepGainMultiplier = GameplaySettings.SettingsStore.RepGainMultiplier; msgData.RepLossMultiplier = GameplaySettings.SettingsStore.RepLossMultiplier; msgData.ScienceGainMultiplier = GameplaySettings.SettingsStore.ScienceGainMultiplier; msgData.StartingFunds = GameplaySettings.SettingsStore.StartingFunds; msgData.StartingReputation = GameplaySettings.SettingsStore.StartingReputation; msgData.StartingScience = GameplaySettings.SettingsStore.StartingScience; //Advanced msgData.ActionGroupsAlways = GameplaySettings.SettingsStore.ActionGroupsAlways; msgData.GKerbalLimits = GameplaySettings.SettingsStore.GKerbalLimits; msgData.GPartLimits = GameplaySettings.SettingsStore.GPartLimits; msgData.KerbalGToleranceMult = GameplaySettings.SettingsStore.KerbalGToleranceMult; msgData.PressurePartLimits = GameplaySettings.SettingsStore.PressurePartLimits; msgData.EnableKerbalExperience = GameplaySettings.SettingsStore.KerbalExp; msgData.ImmediateLevelUp = GameplaySettings.SettingsStore.ImmediateLevelUp; msgData.AllowNegativeCurrency = GameplaySettings.SettingsStore.AllowNegativeCurrency; msgData.ResourceTransferObeyCrossfeed = GameplaySettings.SettingsStore.ObeyCrossfeedRules; msgData.BuildingImpactDamageMult = GameplaySettings.SettingsStore.BuildingDamageMultiplier; msgData.PartUpgradesInCareerAndSandbox = GameplaySettings.SettingsStore.PartUpgrades; //Commnet msgData.RequireSignalForControl = GameplaySettings.SettingsStore.RequireSignalForControl; msgData.DsnModifier = GameplaySettings.SettingsStore.DsnModifier; msgData.RangeModifier = GameplaySettings.SettingsStore.RangeModifier; msgData.OcclusionMultiplierVac = GameplaySettings.SettingsStore.OcclusionModifierVac; msgData.OcclusionMultiplierAtm = GameplaySettings.SettingsStore.OcclusionModifierAtm; msgData.EnableGroundStations = GameplaySettings.SettingsStore.ExtraGroundstations; msgData.PlasmaBlackout = GameplaySettings.SettingsStore.ReentryBlackout; } MessageQueuer.SendToClient <SetingsSrvMsg>(client, msgData); }
public override void HandleMessage(ClientStructure client, IClientMessageBase message) { var messageData = message.Data as VesselBaseMsgData; switch (messageData?.VesselMessageType) { case VesselMessageType.Sync: HandleVesselsSync(client, messageData); message.Recycle(); break; case VesselMessageType.Proto: HandleVesselProto(client, messageData); break; case VesselMessageType.Remove: HandleVesselRemove(client, messageData); break; case VesselMessageType.Position: MessageQueuer.RelayMessage <VesselSrvMsg>(client, messageData); if (client.Subspace == WarpContext.LatestSubspace.Id) { VesselDataUpdater.WritePositionDataToFile(messageData); } break; case VesselMessageType.Flightstate: MessageQueuer.RelayMessage <VesselSrvMsg>(client, messageData); VesselDataUpdater.WriteFlightstateDataToFile(messageData); break; case VesselMessageType.Update: VesselDataUpdater.WriteUpdateDataToFile(messageData); MessageQueuer.RelayMessage <VesselSrvMsg>(client, messageData); break; case VesselMessageType.Resource: VesselDataUpdater.WriteResourceDataToFile(messageData); MessageQueuer.RelayMessage <VesselSrvMsg>(client, messageData); break; case VesselMessageType.PartSyncField: VesselDataUpdater.WritePartSyncFieldDataToFile(messageData); MessageQueuer.RelayMessage <VesselSrvMsg>(client, messageData); break; case VesselMessageType.PartSyncUiField: VesselDataUpdater.WritePartSyncUiFieldDataToFile(messageData); MessageQueuer.RelayMessage <VesselSrvMsg>(client, messageData); break; case VesselMessageType.PartSyncCall: MessageQueuer.RelayMessage <VesselSrvMsg>(client, messageData); break; case VesselMessageType.ActionGroup: VesselDataUpdater.WriteActionGroupDataToFile(messageData); MessageQueuer.RelayMessage <VesselSrvMsg>(client, messageData); break; case VesselMessageType.Fairing: VesselDataUpdater.WriteFairingDataToFile(messageData); MessageQueuer.RelayMessage <VesselSrvMsg>(client, messageData); break; case VesselMessageType.Decouple: MessageQueuer.RelayMessage <VesselSrvMsg>(client, messageData); break; case VesselMessageType.Couple: HandleVesselCouple(client, messageData); break; case VesselMessageType.Undock: MessageQueuer.RelayMessage <VesselSrvMsg>(client, messageData); break; default: throw new NotImplementedException("Vessel message type not implemented"); } }