void OnHostDirectIntroduction(ref MyEventDirectIntroductionResponse msg) { MyMultiplayerPeers.Static.NetworkClient.NatIntroductionSuccess = NetworkClient_NatIntroductionSuccess; MyEventGetPlayerList getPlayersMsg = new MyEventGetPlayerList(); SetCallback <MyEventGetPlayerListResponse>(OnGetPlayerListResponse); var hostRelayConnection = MyMultiplayerPeers.Static.NetworkClient.GetRelayedConnection(msg.EndPoint); MyMultiplayerPeers.Static.NetworkClient.Send(ref getPlayersMsg, hostRelayConnection, NetDeliveryMethod.ReliableOrdered, 0); MyMultiplayerGameplay.Log("JOIN 3. - Host NAT introduction failure, RELAYING, sending player list request"); }
void NetworkClient_NatIntroductionSuccessHost(IPEndPoint endpoint, string token) { int userId; if (!int.TryParse(token, out userId)) { return; } if (userId == MyMultiplayerPeers.Static.HostUserId) { // NAT intro from host received m_introductionTimer.Dispose(); MyMultiplayerPeers.Static.NetworkClient.NatIntroductionSuccess = NetworkClient_NatIntroductionSuccess; MyEventGetPlayerList msg = new MyEventGetPlayerList(); SetCallback <MyEventGetPlayerListResponse>(OnGetPlayerListResponse); MyMultiplayerPeers.Static.NetworkClient.Connect(endpoint, ref msg); MyMultiplayerGameplay.Log("JOIN 3. - Host NAT introduction success, sending player list request"); } }
// Client wants player list private void OnGetPlayerList(ref MyEventGetPlayerList msg) { SendPlayerList(msg.SenderConnection); }