Example #1
0
 internal void OnParticipantStatusChanged(NativeRealTimeRoom room,
                                          MultiplayerParticipant participant)
 {
     lock (mLifecycleLock) {
         mState.OnParticipantStatusChanged(room, participant);
     }
 }
Example #2
0
        private void FindEqualVersionMatchWithParticipant(TurnBasedMatch match,
                                                          string participantId, Action <bool> onFailure,
                                                          Action <MultiplayerParticipant, NativeTurnBasedMatch> onFoundParticipantAndMatch)
        {
            FindEqualVersionMatch(match, onFailure, foundMatch =>
            {
                // If we received a null participantId, we're using an automatching player instead -
                // issue the callback using that.
                if (participantId == null)
                {
                    using (var sentinelParticipant = MultiplayerParticipant.AutomatchingSentinel())
                    {
                        onFoundParticipantAndMatch(sentinelParticipant, foundMatch);
                        return;
                    }
                }

                using (var participant = foundMatch.ParticipantWithId(participantId))
                {
                    if (participant == null)
                    {
                        Logger.e(string.Format("Located match {0} but desired participant with ID " +
                                               "{1} could not be found", match.MatchId, participantId));
                        onFailure(false);
                        return;
                    }

                    onFoundParticipantAndMatch(participant, foundMatch);
                }
            });
        }
    internal MultiplayerParticipant Inviter() {
        MultiplayerParticipant participant =
            new MultiplayerParticipant(C.MultiplayerInvitation_InvitingParticipant(SelfPtr()));

        if (!participant.Valid()) {
            participant.Dispose();
            return null;
        }

        return participant;
    }
    internal MultiplayerParticipant PendingParticipant() {
        var participant = new MultiplayerParticipant(
            C.TurnBasedMatch_PendingParticipant(SelfPtr()));

        if (!participant.Valid()) {
            participant.Dispose();
            return null;
        }

        return participant;
    }
Example #5
0
            internal override void HandleParticipantStatusChanged(NativeRealTimeRoom room,
                                                                  MultiplayerParticipant participant)
            {
                if (!FailedStatuses.Contains(participant.Status()))
                {
                    return;
                }

                Logger.e(string.Format("Participant {0} changed to status {1}, room will never be" +
                                       "fully connected.", participant.Id(), participant.Status()));
                LeaveRoom();
            }
Example #6
0
 internal override void OnDataReceived(NativeRealTimeRoom room,
                                       MultiplayerParticipant sender, byte[] data, bool isReliable)
 {
     mSession.OnGameThreadListener().RealTimeMessageReceived(isReliable, sender.Id(), data);
 }
Example #7
0
 internal virtual void HandleParticipantStatusChanged(NativeRealTimeRoom room,
                                                      MultiplayerParticipant participant)
 {
     // noop
 }
Example #8
0
 internal sealed override void OnParticipantStatusChanged(NativeRealTimeRoom room,
                                                          MultiplayerParticipant participant)
 {
     HandleParticipantStatusChanged(room, participant);
     UpdateCurrentRoom(room);
 }
Example #9
0
 internal virtual void OnDataReceived(NativeRealTimeRoom room, MultiplayerParticipant sender,
                                      byte[] data, bool isReliable)
 {
     Logger.d(this.GetType().Name + ".OnDataReceived: Defaulting to no-op.");
 }
Example #10
0
 internal virtual void OnParticipantStatusChanged(NativeRealTimeRoom room,
                                                  MultiplayerParticipant participant)
 {
     Logger.d(this.GetType().Name + ".OnParticipantStatusChanged: Defaulting to no-op.");
 }
Example #11
0
 /**
  * Non-Lifecycle methods - these cannot cause state transitions, and thus we do not need to
  * hold any locks. We rely on only accessing volatile fields to ensure consistency instead.
  */
 internal void OnDataReceived(NativeRealTimeRoom room, MultiplayerParticipant sender,
                              byte[] data, bool isReliable)
 {
     mState.OnDataReceived(room, sender, data, isReliable);
 }
Example #12
0
 internal void TakeTurn(NativeTurnBasedMatch match, byte[] data,
                    MultiplayerParticipant nextParticipant, Action<TurnBasedMatchResponse> callback)
 {
     TurnBasedMultiplayerManager.TurnBasedMultiplayerManager_TakeMyTurn(
         mGameServices.AsHandle(),
         match.AsPointer(),
         data,
         new UIntPtr((uint)data.Length),
     // Just pass along the old results. Technically the API allows updates here, but
     // we never need them.
         match.Results().AsPointer(),
         nextParticipant.AsPointer(),
         InternalTurnBasedMatchCallback,
         ToCallbackPointer(callback));
 }
Example #13
0
 internal void LeaveDuringMyTurn(NativeTurnBasedMatch match,
                             MultiplayerParticipant nextParticipant, Action<MultiplayerStatus> callback)
 {
     TurnBasedMultiplayerManager.TurnBasedMultiplayerManager_LeaveMatchDuringMyTurn(
         mGameServices.AsHandle(),
         match.AsPointer(),
         nextParticipant.AsPointer(),
         InternalMultiplayerStatusCallback,
         Callbacks.ToIntPtr(callback)
     );
 }