コード例 #1
0
        /// <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}");
                    }
                }
            }
        }
コード例 #2
0
        /// <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);
        }
コード例 #3
0
        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)));
        }
コード例 #4
0
        /// <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);
        }
コード例 #5
0
        /// <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);
        }
コード例 #6
0
        /// <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}");
            }
        }
コード例 #7
0
 public static void SendWarpSubspacesRequest()
 {
     SystemBase.TaskFactory.StartNew(() => NetworkSender.QueueOutgoingMessage(NetworkMain.CliMsgFactory.CreateNew <WarpCliMsg, WarpSubspacesRequestMsgData>()));
 }
コード例 #8
0
 public static void SendCraftLibraryRequest()
 {
     SystemBase.TaskFactory.StartNew(() => NetworkSender.QueueOutgoingMessage(NetworkMain.CliMsgFactory.CreateNew <CraftLibraryCliMsg>(new CraftLibraryListRequestMsgData {
         PlayerName = SettingsSystem.CurrentSettings.PlayerName
     })));
 }
コード例 #9
0
 public static void SendScenariosRequest()
 {
     NetworkSender.QueueOutgoingMessage(NetworkMain.CliMsgFactory.CreateNew <ScenarioCliMsg>(new ScenarioRequestMsgData()));
 }
コード例 #10
0
 public static void SendPlayersRequest()
 {
     NetworkSender.QueueOutgoingMessage(NetworkMain.CliMsgFactory.CreateNew <PlayerStatusCliMsg>(new PlayerStatusRequestMsgData()));
 }
コード例 #11
0
 public static void SendWarpSubspacesRequest()
 {
     NetworkSender.QueueOutgoingMessage(NetworkMain.CliMsgFactory.CreateNew <WarpCliMsg>(new WarpSubspacesRequestMsgData()));
 }
コード例 #12
0
 public static void SendVesselListRequest()
 {
     NetworkSender.QueueOutgoingMessage(NetworkMain.CliMsgFactory.CreateNew <VesselCliMsg>(new VesselListRequestMsgData()));
 }
コード例 #13
0
 public static void SendKerbalsRequest()
 {
     NetworkSender.QueueOutgoingMessage(NetworkMain.CliMsgFactory.CreateNew <KerbalCliMsg>(new KerbalsRequestMsgData()));
 }
コード例 #14
0
 public static void SendMotdRequest()
 {
     NetworkSender.QueueOutgoingMessage(NetworkMain.CliMsgFactory.CreateNew <MotdCliMsg>(new MotdRequestMsgData()));
 }
コード例 #15
0
 public static void SendAdminsRequest()
 {
     SystemBase.TaskFactory.StartNew(() => NetworkSender.QueueOutgoingMessage(NetworkMain.CliMsgFactory.CreateNew <AdminCliMsg>(new AdminListRequestMsgData())));
 }
コード例 #16
0
 public static void SendPlayersRequest()
 {
     SystemBase.TaskFactory.StartNew(() => NetworkSender.QueueOutgoingMessage(NetworkMain.CliMsgFactory.CreateNew <PlayerStatusCliMsg, PlayerStatusRequestMsgData>()));
 }
コード例 #17
0
 public static void SendScenariosRequest()
 {
     SystemBase.TaskFactory.StartNew(() => NetworkSender.QueueOutgoingMessage(NetworkMain.CliMsgFactory.CreateNew <ScenarioCliMsg, ScenarioRequestMsgData>()));
 }
コード例 #18
0
 public static void SendChatRequest()
 {
     NetworkSender.QueueOutgoingMessage(NetworkMain.CliMsgFactory.CreateNew <ChatCliMsg>(new ChatListRequestMsgData {
         From = SettingsSystem.CurrentSettings.PlayerName
     }));
 }
コード例 #19
0
 public static void SendGroupListRequest()
 {
     SystemBase.TaskFactory.StartNew(() => NetworkSender.QueueOutgoingMessage(NetworkMain.CliMsgFactory.CreateNew <GroupCliMsg, GroupListRequestMsgData>()));
 }
コード例 #20
0
 public static void SendLocksRequest()
 {
     NetworkSender.QueueOutgoingMessage(NetworkMain.CliMsgFactory.CreateNew <LockCliMsg>(new LockListRequestMsgData()));
 }
コード例 #21
0
 public static void SendAdminsRequest()
 {
     NetworkSender.QueueOutgoingMessage(NetworkMain.CliMsgFactory.CreateNew <AdminCliMsg>(new AdminListRequestMsgData()));
 }
コード例 #22
0
 public static void SendColorsRequest()
 {
     SystemBase.TaskFactory.StartNew(() => NetworkSender.QueueOutgoingMessage(NetworkMain.CliMsgFactory.CreateNew <PlayerColorCliMsg>(new PlayerColorRequestMsgData())));
 }