/// <summary> /// Send a request to the master server to introduce us and do the nat punchtrough to the selected server /// </summary> public static void IntroduceToServer(long serverId) { if (Servers.TryGetValue(serverId, out var serverInfo)) { var serverEndpoint = Common.CreateEndpointFromString(serverInfo.ExternalEndpoint); if (ServerIsInLocalLan(serverEndpoint)) { LunaLog.Log("Server is in LAN. Skipping NAT punch"); NetworkConnection.ConnectToServer(serverEndpoint.Address.ToString(), serverEndpoint.Port, Password); } else { try { var token = RandomString(10); var ownEndpoint = new IPEndPoint(LunaNetUtils.GetMyAddress(), NetworkMain.Config.Port); var msgData = NetworkMain.CliMsgFactory.CreateNewMessageData <MsIntroductionMsgData>(); msgData.Id = serverId; msgData.Token = token; msgData.InternalEndpoint = Common.StringFromEndpoint(ownEndpoint); var introduceMsg = NetworkMain.MstSrvMsgFactory.CreateNew <MainMstSrvMsg>(msgData); LunaLog.Log($"[LMP]: Sending NAT introduction to server. Token: {token}"); NetworkSender.QueueOutgoingMessage(introduceMsg); } catch (Exception e) { LunaLog.LogError($"[LMP]: Error connecting to server: {e}"); } } } }
/// <summary> /// Sends a request servers to the master servers /// </summary> public static void RequestServers() { var msgData = NetworkMain.CliMsgFactory.CreateNewMessageData <MsRequestServersMsgData>(); var requestMsg = NetworkMain.MstSrvMsgFactory.CreateNew <MainMstSrvMsg>(msgData); NetworkSender.QueueOutgoingMessage(requestMsg); }
public static void SendChatRequest() { var msgData = NetworkMain.CliMsgFactory.CreateNewMessageData <ChatListRequestMsgData>(); msgData.From = SettingsSystem.CurrentSettings.PlayerName; SystemBase.TaskFactory.StartNew(() => NetworkSender.QueueOutgoingMessage(NetworkMain.CliMsgFactory.CreateNew <ChatCliMsg>(msgData))); }
/// <summary> /// Sends a request servers to the master servers /// </summary> public static void RequestServers() { var requestMsg = NetworkMain.MstSrvMsgFactory.CreateNew <MainMstSrvMsg>(new MsRequestServersMsgData { CurrentVersion = VersionInfo.VersionNumber }); NetworkSender.QueueOutgoingMessage(requestMsg); }
/// <summary> /// Send a request to the master server to introduce us and do the nat punchtrough to the selected server /// </summary> public static void IntroduceToServer(long currentEntryId) { var token = RandomString(10); var ownEndpoint = new IPEndPoint(NetUtility.GetMyAddress(out var _), NetworkMain.Config.Port); var introduceMsg = NetworkMain.MstSrvMsgFactory.CreateNew <MainMstSrvMsg>(new MsIntroductionMsgData { Id = currentEntryId, Token = token, InternalEndpoint = Common.StringFromEndpoint(ownEndpoint) }); LunaLog.Log($"[LMP]: Sending NAT introduction to server. Token: {token}"); NetworkSender.QueueOutgoingMessage(introduceMsg); }
/// <summary> /// Send a request to the master server to introduce us and do the nat punchtrough to the selected server /// </summary> public static void IntroduceToServer(long currentEntryId) { try { var token = RandomString(10); var ownEndpoint = new IPEndPoint(LunaNetUtils.GetMyAddress(), NetworkMain.Config.Port); var msgData = NetworkMain.CliMsgFactory.CreateNewMessageData <MsIntroductionMsgData>(); msgData.Id = currentEntryId; msgData.Token = token; msgData.InternalEndpoint = Common.StringFromEndpoint(ownEndpoint); var introduceMsg = NetworkMain.MstSrvMsgFactory.CreateNew <MainMstSrvMsg>(msgData); LunaLog.Log($"[LMP]: Sending NAT introduction to server. Token: {token}"); NetworkSender.QueueOutgoingMessage(introduceMsg); } catch (Exception e) { LunaLog.LogError($"[LMP]: Error connecting to server: {e}"); } }
public static void SendWarpSubspacesRequest() { SystemBase.TaskFactory.StartNew(() => NetworkSender.QueueOutgoingMessage(NetworkMain.CliMsgFactory.CreateNew <WarpCliMsg, WarpSubspacesRequestMsgData>())); }
public static void SendCraftLibraryRequest() { SystemBase.TaskFactory.StartNew(() => NetworkSender.QueueOutgoingMessage(NetworkMain.CliMsgFactory.CreateNew <CraftLibraryCliMsg>(new CraftLibraryListRequestMsgData { PlayerName = SettingsSystem.CurrentSettings.PlayerName }))); }
public static void SendScenariosRequest() { NetworkSender.QueueOutgoingMessage(NetworkMain.CliMsgFactory.CreateNew <ScenarioCliMsg>(new ScenarioRequestMsgData())); }
public static void SendPlayersRequest() { NetworkSender.QueueOutgoingMessage(NetworkMain.CliMsgFactory.CreateNew <PlayerStatusCliMsg>(new PlayerStatusRequestMsgData())); }
public static void SendWarpSubspacesRequest() { NetworkSender.QueueOutgoingMessage(NetworkMain.CliMsgFactory.CreateNew <WarpCliMsg>(new WarpSubspacesRequestMsgData())); }
public static void SendVesselListRequest() { NetworkSender.QueueOutgoingMessage(NetworkMain.CliMsgFactory.CreateNew <VesselCliMsg>(new VesselListRequestMsgData())); }
public static void SendKerbalsRequest() { NetworkSender.QueueOutgoingMessage(NetworkMain.CliMsgFactory.CreateNew <KerbalCliMsg>(new KerbalsRequestMsgData())); }
public static void SendMotdRequest() { NetworkSender.QueueOutgoingMessage(NetworkMain.CliMsgFactory.CreateNew <MotdCliMsg>(new MotdRequestMsgData())); }
public static void SendAdminsRequest() { SystemBase.TaskFactory.StartNew(() => NetworkSender.QueueOutgoingMessage(NetworkMain.CliMsgFactory.CreateNew <AdminCliMsg>(new AdminListRequestMsgData()))); }
public static void SendPlayersRequest() { SystemBase.TaskFactory.StartNew(() => NetworkSender.QueueOutgoingMessage(NetworkMain.CliMsgFactory.CreateNew <PlayerStatusCliMsg, PlayerStatusRequestMsgData>())); }
public static void SendScenariosRequest() { SystemBase.TaskFactory.StartNew(() => NetworkSender.QueueOutgoingMessage(NetworkMain.CliMsgFactory.CreateNew <ScenarioCliMsg, ScenarioRequestMsgData>())); }
public static void SendChatRequest() { NetworkSender.QueueOutgoingMessage(NetworkMain.CliMsgFactory.CreateNew <ChatCliMsg>(new ChatListRequestMsgData { From = SettingsSystem.CurrentSettings.PlayerName })); }
public static void SendGroupListRequest() { SystemBase.TaskFactory.StartNew(() => NetworkSender.QueueOutgoingMessage(NetworkMain.CliMsgFactory.CreateNew <GroupCliMsg, GroupListRequestMsgData>())); }
public static void SendLocksRequest() { NetworkSender.QueueOutgoingMessage(NetworkMain.CliMsgFactory.CreateNew <LockCliMsg>(new LockListRequestMsgData())); }
public static void SendAdminsRequest() { NetworkSender.QueueOutgoingMessage(NetworkMain.CliMsgFactory.CreateNew <AdminCliMsg>(new AdminListRequestMsgData())); }
public static void SendColorsRequest() { SystemBase.TaskFactory.StartNew(() => NetworkSender.QueueOutgoingMessage(NetworkMain.CliMsgFactory.CreateNew <PlayerColorCliMsg>(new PlayerColorRequestMsgData()))); }