void PeerConnectRequestCallback(Message <NetworkingPeer> msg) { if (m_remotePlayers.ContainsKey(msg.Data.ID)) { Debug.LogFormat("P2P Accepting Connection request from {0}", msg.Data.ID); Net.Accept(msg.Data.ID); } else { Debug.LogFormat("P2P Ignoring unauthorized Connection request from {0}", msg.Data.ID); } }
void PeerConnectRequestCallback(Message <NetworkingPeer> msg) { PlatformManager.LogOutput("P2P request from " + msg.Data.ID); RemotePlayer remote = PlatformManager.GetRemoteUser(msg.Data.ID); if (remote != null) { PlatformManager.LogOutput("P2P request accepted from " + msg.Data.ID); Net.Accept(msg.Data.ID); } }
new void Update() { base.Update(); if (Input.GetKeyDown("space")) { Debug.Log("Forcing reconnect"); isConnected = false; RetryUntilConnectedToServer(); } if (state == InMatchmaking && timeMatchmakingStarted + 30.0 < renderTime) { Debug.Log("No result from matchmaker"); RetryUntilConnectedToServer(); return; } if (state == Connecting && !isConnectionAccepted && hostUserId != 0 && connections.Contains(hostUserId)) { Debug.Log("Accepting connection request from host"); Net.Accept(hostUserId); isConnectionAccepted = true; } if (state == Connected) { var data = context.GetClientData(); //apply guest avatar state at render time with interpolation int count; ushort resetId; if (data.jitterBuffer.GetInterpolatedAvatars(ref interpolatedAvatars, out count, out resetId) && resetId == context.resetId) { context.ApplyAvatarUpdates(count, ref interpolatedAvatars, 0, clientId); } context.GetClientData().jitterBuffer.AdvanceTime(Time.deltaTime); //advance jitter buffer time } if (state == WaitingForRetry && timeRetryStarted + RetryTime < renderTime) { StartMatchmaking(); return; } CheckForTimeouts(); }
void OnConnectRequestCallback(Message <NetworkingPeer> msg) { if (msg.IsError) { Debug.LogError("Net connecton error - " + msg.GetError().Message); } else { var peer = msg.GetNetworkingPeer(); if (!remoteConnectionStates.ContainsKey(peer.ID)) { remoteConnectionStates.Add(peer.ID, new ConnectionStates()); } UnityUserReporting.CurrentClient.LogEvent(UserReportEventLevel.Info, "Net accept of " + peer.ID.ToString() + ". State was " + remoteConnectionStates[peer.ID].networkState.ToString()); Net.Accept(peer.ID); remoteConnectionStates[peer.ID].networkState = ConnectionState.Connecting; remoteConnectionStates[peer.ID].netTimeouts = 0; } }
new void Update() { base.Update(); if (Input.GetKeyDown("space")) { Debug.Log("Forcing reconnect"); successfullyConnected = false; RetryUntilConnectedToServer(); } if (state == GuestState.Matchmaking && timeMatchmakingStarted + 30.0 < renderTime) { Debug.Log("No result from matchmaker"); RetryUntilConnectedToServer(); return; } if (state == GuestState.Connecting && !acceptedConnectionRequest) { if (hostUserId != 0 && connectionRequests.Contains(hostUserId)) { Debug.Log("Accepting connection request from host"); Net.Accept(hostUserId); acceptedConnectionRequest = true; } } if (state == GuestState.Connected) { // apply guest avatar state at render time with interpolation Context.ConnectionData connectionData = context.GetClientConnectionData(); int numInterpolatedAvatarStates; ushort avatarResetSequence; if (connectionData.jitterBuffer.GetInterpolatedAvatarState(ref interpolatedAvatarState, out numInterpolatedAvatarStates, out avatarResetSequence)) { if (avatarResetSequence == context.GetResetSequence()) { context.ApplyAvatarStateUpdates(numInterpolatedAvatarStates, ref interpolatedAvatarState, 0, clientIndex); } } // advance jitter buffer time context.GetClientConnectionData().jitterBuffer.AdvanceTime(Time.deltaTime); } if (state == GuestState.WaitingForRetry && timeRetryStarted + RetryTime < renderTime) { StartMatchmaking(); return; } CheckForTimeouts(); }