internal static void InternalOnDataReceived(IntPtr room, IntPtr participant, IntPtr data, UIntPtr dataLength, bool isReliable, IntPtr userData) { Logger.d("Entering InternalOnDataReceived: " + userData.ToInt64()); Action <NativeRealTimeRoom, GooglePlayGames.Native.PInvoke.MultiplayerParticipant, byte[], bool> action = Callbacks.IntPtrToPermanentCallback <Action <NativeRealTimeRoom, GooglePlayGames.Native.PInvoke.MultiplayerParticipant, byte[], bool> >(userData); using (NativeRealTimeRoom room2 = NativeRealTimeRoom.FromPointer(room)) { using (GooglePlayGames.Native.PInvoke.MultiplayerParticipant participant2 = GooglePlayGames.Native.PInvoke.MultiplayerParticipant.FromPointer(participant)) { if (action != null) { byte[] destination = null; if (dataLength.ToUInt64() != 0L) { destination = new byte[dataLength.ToUInt32()]; Marshal.Copy(data, destination, 0, (int)dataLength.ToUInt32()); } try { action(room2, participant2, destination, isReliable); } catch (Exception exception) { Logger.e("Error encountered executing InternalOnDataReceived. Smothering to avoid passing exception into Native: " + exception); } } } } }
internal GooglePlayGames.Native.PInvoke.MultiplayerParticipant ParticipantWithId(string participantId) { IEnumerator <GooglePlayGames.Native.PInvoke.MultiplayerParticipant> enumerator = this.Participants().GetEnumerator(); try { while (enumerator.MoveNext()) { GooglePlayGames.Native.PInvoke.MultiplayerParticipant current = enumerator.Current; if (current.Id().Equals(participantId)) { return(current); } current.Dispose(); } } finally { if (enumerator == null) { } enumerator.Dispose(); } return(null); }
internal GooglePlayGames.BasicApi.Multiplayer.TurnBasedMatch AsTurnBasedMatch(string selfPlayerId) { List <Participant> participants = new List <Participant>(); string selfParticipantId = null; string pendingParticipantId = null; using (GooglePlayGames.Native.PInvoke.MultiplayerParticipant participant = this.PendingParticipant()) { if (participant != null) { pendingParticipantId = participant.Id(); } } foreach (GooglePlayGames.Native.PInvoke.MultiplayerParticipant participant2 in this.Participants()) { using (participant2) { using (NativePlayer player = participant2.Player()) { if ((player != null) && player.Id().Equals(selfPlayerId)) { selfParticipantId = participant2.Id(); } } participants.Add(participant2.AsParticipant()); } } return(new GooglePlayGames.BasicApi.Multiplayer.TurnBasedMatch(this.Id(), this.Data(), (this.MatchStatus() == GooglePlayGames.Native.Cwrapper.Types.MatchStatus.COMPLETED) && !this.HasRematchId(), selfParticipantId, participants, this.AvailableAutomatchSlots(), pendingParticipantId, ToTurnStatus(this.MatchStatus()), ToMatchStatus(pendingParticipantId, this.MatchStatus()), this.Variant(), this.Version())); }
internal GooglePlayGames.Native.PInvoke.MultiplayerParticipant Inviter() { GooglePlayGames.Native.PInvoke.MultiplayerParticipant participant = new GooglePlayGames.Native.PInvoke.MultiplayerParticipant(GooglePlayGames.Native.Cwrapper.MultiplayerInvitation.MultiplayerInvitation_InvitingParticipant(base.SelfPtr())); if (!participant.Valid()) { participant.Dispose(); return(null); } return(participant); }
internal GooglePlayGames.Native.PInvoke.MultiplayerParticipant PendingParticipant() { GooglePlayGames.Native.PInvoke.MultiplayerParticipant participant = new GooglePlayGames.Native.PInvoke.MultiplayerParticipant(GooglePlayGames.Native.Cwrapper.TurnBasedMatch.TurnBasedMatch_PendingParticipant(base.SelfPtr())); if (!participant.Valid()) { participant.Dispose(); return(null); } return(participant); }
internal Invitation AsInvitation() { Participant participant; Invitation.InvType invType = ToInvType(this.Type()); string invId = this.Id(); int variant = (int)this.Variant(); using (GooglePlayGames.Native.PInvoke.MultiplayerParticipant participant2 = this.Inviter()) { participant = (participant2 != null) ? participant2.AsParticipant() : null; } return(new Invitation(invType, invId, participant, variant)); }
internal GooglePlayGames.BasicApi.Multiplayer.TurnBasedMatch AsTurnBasedMatch(string selfPlayerId) { List <Participant> participants = new List <Participant>(); string selfParticipantId = null; string pendingParticipantId = null; using (GooglePlayGames.Native.PInvoke.MultiplayerParticipant participant = this.PendingParticipant()) { if (participant != null) { pendingParticipantId = participant.Id(); } } IEnumerator <GooglePlayGames.Native.PInvoke.MultiplayerParticipant> enumerator = this.Participants().GetEnumerator(); try { while (enumerator.MoveNext()) { GooglePlayGames.Native.PInvoke.MultiplayerParticipant current = enumerator.Current; using (current) { using (NativePlayer player = current.Player()) { if ((player != null) && player.Id().Equals(selfPlayerId)) { selfParticipantId = current.Id(); } } participants.Add(current.AsParticipant()); continue; } } } finally { if (enumerator == null) { } enumerator.Dispose(); } return(new GooglePlayGames.BasicApi.Multiplayer.TurnBasedMatch(this.Id(), this.Data(), (this.MatchStatus() == GooglePlayGames.Native.Cwrapper.Types.MatchStatus.COMPLETED) && !this.HasRematchId(), selfParticipantId, participants, this.AvailableAutomatchSlots(), pendingParticipantId, ToTurnStatus(this.MatchStatus()), ToMatchStatus(pendingParticipantId, this.MatchStatus()), this.Variant(), this.Version())); }
internal static void PerformRoomAndParticipantCallback(string callbackName, IntPtr room, IntPtr participant, IntPtr data) { Logger.d("Entering " + callbackName); try { NativeRealTimeRoom room2 = NativeRealTimeRoom.FromPointer(room); using (GooglePlayGames.Native.PInvoke.MultiplayerParticipant participant2 = GooglePlayGames.Native.PInvoke.MultiplayerParticipant.FromPointer(participant)) { Action <NativeRealTimeRoom, GooglePlayGames.Native.PInvoke.MultiplayerParticipant> action = Callbacks.IntPtrToPermanentCallback <Action <NativeRealTimeRoom, GooglePlayGames.Native.PInvoke.MultiplayerParticipant> >(data); if (action != null) { action(room2, participant2); } } } catch (Exception exception) { Logger.e(string.Concat(new object[] { "Error encountered executing ", callbackName, ". Smothering to avoid passing exception into Native: ", exception })); } }
internal void SendReliableMessage(NativeRealTimeRoom room, GooglePlayGames.Native.PInvoke.MultiplayerParticipant participant, byte[] data, Action <GooglePlayGames.Native.Cwrapper.CommonErrorStatus.MultiplayerStatus> callback) { RealTimeMultiplayerManager.RealTimeMultiplayerManager_SendReliableMessage(this.mGameServices.AsHandle(), room.AsPointer(), participant.AsPointer(), data, PInvokeUtilities.ArrayToSizeT <byte>(data), new RealTimeMultiplayerManager.SendReliableMessageCallback(RealtimeManager.InternalSendReliableMessageCallback), Callbacks.ToIntPtr(callback)); }
internal void TakeTurn(NativeTurnBasedMatch match, byte[] data, GooglePlayGames.Native.PInvoke.MultiplayerParticipant nextParticipant, Action <TurnBasedMatchResponse> callback) { TurnBasedMultiplayerManager.TurnBasedMultiplayerManager_TakeMyTurn(this.mGameServices.AsHandle(), match.AsPointer(), data, new UIntPtr((uint)data.Length), match.Results().AsPointer(), nextParticipant.AsPointer(), new TurnBasedMultiplayerManager.TurnBasedMatchCallback(TurnBasedManager.InternalTurnBasedMatchCallback), ToCallbackPointer(callback)); }
internal void LeaveDuringMyTurn(NativeTurnBasedMatch match, GooglePlayGames.Native.PInvoke.MultiplayerParticipant nextParticipant, Action <GooglePlayGames.Native.Cwrapper.CommonErrorStatus.MultiplayerStatus> callback) { TurnBasedMultiplayerManager.TurnBasedMultiplayerManager_LeaveMatchDuringMyTurn(this.mGameServices.AsHandle(), match.AsPointer(), nextParticipant.AsPointer(), new TurnBasedMultiplayerManager.MultiplayerStatusCallback(TurnBasedManager.InternalMultiplayerStatusCallback), Callbacks.ToIntPtr(callback)); }