Exemple #1
0
        internal static void PerformRoomAndParticipantCallback(string callbackName,
                                                               IntPtr room, IntPtr participant, IntPtr data)
        {
            Logger.d("Entering " + callbackName);

            try
            {
                // This is a workaround to the fact that we're lacking proper copy constructors -
                // see comment below.
                var nativeRoom = NativeRealTimeRoom.FromPointer(room);
                using (var nativeParticipant = MultiplayerParticipant.FromPointer(participant))
                {
                    var callback = Callbacks.IntPtrToPermanentCallback
                                   <Action <NativeRealTimeRoom, MultiplayerParticipant> >(data);
                    if (callback != null)
                    {
                        callback(nativeRoom, nativeParticipant);
                    }
                }
            }
            catch (Exception e)
            {
                Logger.e("Error encountered executing " + callbackName + ". " +
                         "Smothering to avoid passing exception into Native: " + e);
            }
        }
Exemple #2
0
        internal static void InternalOnDataReceived(
            IntPtr room, IntPtr participant, IntPtr data, UIntPtr dataLength, bool isReliable,
            IntPtr userData)
        {
            Logger.d("Entering InternalOnDataReceived: " + userData.ToInt64());

            var callback = Callbacks.IntPtrToPermanentCallback
                           <Action <NativeRealTimeRoom, MultiplayerParticipant, byte[], bool> >(userData);

            using (var nativeRoom = NativeRealTimeRoom.FromPointer(room)) {
                using (var nativeParticipant = MultiplayerParticipant.FromPointer(participant)) {
                    if (callback == null)
                    {
                        return;
                    }

                    byte[] convertedData = null;

                    if (dataLength.ToUInt64() != 0)
                    {
                        convertedData = new byte[dataLength.ToUInt32()];
                        Marshal.Copy(data, convertedData, 0, (int)dataLength.ToUInt32());
                    }

                    try {
                        callback(nativeRoom, nativeParticipant, convertedData, isReliable);
                    } catch (Exception e) {
                        Logger.e("Error encountered executing InternalOnDataReceived. " +
                                 "Smothering to avoid passing exception into Native: " + e);
                    }
                }
            }
        }
Exemple #3
0
        private static void InternalAuthStartedCallback(Types.AuthOperation op, IntPtr data)
        {
            AuthStartedCallback authStartedCallback = Callbacks.IntPtrToPermanentCallback <AuthStartedCallback>(data);

            try
            {
                authStartedCallback?.Invoke(op);
            }
            catch (Exception arg)
            {
                Logger.e("Error encountered executing InternalAuthStartedCallback. Smothering to avoid passing exception into Native: " + arg);
            }
        }
Exemple #4
0
        internal static void InternalOnCaptureOverlayStateChangedCallback(Types.VideoCaptureOverlayState response, IntPtr data)
        {
            Action <Types.VideoCaptureOverlayState> action = Callbacks.IntPtrToPermanentCallback <Action <Types.VideoCaptureOverlayState> >(data);

            try
            {
                action(response);
            }
            catch (Exception arg)
            {
                Logger.e("Error encountered executing InternalOnCaptureOverlayStateChangedCallback. Smothering to avoid passing exception into Native: " + arg);
            }
        }
        private static void InternalAuthStartedCallback(Types.AuthOperation op, IntPtr data)
        {
            AuthStartedCallback callback =
                Callbacks.IntPtrToPermanentCallback <AuthStartedCallback>(data);

            try {
                if (callback != null)
                {
                    callback(op);
                }
            } catch (Exception e) {
                Logger.e("Error encountered executing InternalAuthStartedCallback. " +
                         "Smothering to avoid passing exception into Native: " + e);
            }
        }
Exemple #6
0
 private static void InternalAuthStartedCallback(Types.AuthOperation op, IntPtr data)
 {
     GameServicesBuilder.AuthStartedCallback permanentCallback = Callbacks.IntPtrToPermanentCallback <GameServicesBuilder.AuthStartedCallback>(data);
     try
     {
         if (permanentCallback == null)
         {
             return;
         }
         permanentCallback(op);
     }
     catch (Exception ex)
     {
         Logger.e("Error encountered executing InternalAuthStartedCallback. Smothering to avoid passing exception into Native: " + (object)ex);
     }
 }
Exemple #7
0
        private static void InternalOnTurnBasedMatchEventCallback(Types.MultiplayerEvent eventType, string matchId, IntPtr match, IntPtr userData)
        {
            Action <Types.MultiplayerEvent, string, NativeTurnBasedMatch> action = Callbacks.IntPtrToPermanentCallback <Action <Types.MultiplayerEvent, string, NativeTurnBasedMatch> >(userData);

            using (NativeTurnBasedMatch arg = NativeTurnBasedMatch.FromPointer(match))
            {
                try
                {
                    action?.Invoke(eventType, matchId, arg);
                }
                catch (Exception arg2)
                {
                    Logger.e("Error encountered executing InternalOnTurnBasedMatchEventCallback. Smothering to avoid passing exception into Native: " + arg2);
                }
            }
        }
Exemple #8
0
        private static void InternalAuthFinishedCallback(Types.AuthOperation op, CommonErrorStatus.AuthStatus status, IntPtr data)
        {
            AuthFinishedCallback authFinishedCallback = Callbacks.IntPtrToPermanentCallback <AuthFinishedCallback>(data);

            if (authFinishedCallback != null)
            {
                try
                {
                    authFinishedCallback(op, status);
                }
                catch (Exception arg)
                {
                    Logger.e("Error encountered executing InternalAuthFinishedCallback. Smothering to avoid passing exception into Native: " + arg);
                }
            }
        }
 internal static void PerformRoomAndParticipantCallback(string callbackName, IntPtr room, IntPtr participant, IntPtr data)
 {
     Logger.d("Entering " + callbackName);
     try
     {
         NativeRealTimeRoom arg = NativeRealTimeRoom.FromPointer(room);
         using (MultiplayerParticipant arg2 = MultiplayerParticipant.FromPointer(participant))
         {
             Callbacks.IntPtrToPermanentCallback <Action <NativeRealTimeRoom, MultiplayerParticipant> >(data)?.Invoke(arg, arg2);
         }
     }
     catch (Exception ex)
     {
         Logger.e("Error encountered executing " + callbackName + ". Smothering to avoid passing exception into Native: " + ex);
     }
 }
Exemple #10
0
        private static void InternalOnDisconnectedCallback(long id, string lostEndpointId, IntPtr userData)
        {
            Action <long, string> action = Callbacks.IntPtrToPermanentCallback <Action <long, string> >(userData);

            if (action != null)
            {
                try
                {
                    action(id, lostEndpointId);
                }
                catch (Exception exception)
                {
                    Logger.e("Error encountered executing NativeMessageListenerHelper#InternalOnDisconnectedCallback. Smothering to avoid passing exception into Native: " + exception);
                }
            }
        }
Exemple #11
0
        private static void InternalAuthFinishedCallback(Types.AuthOperation op, GooglePlayGames.Native.Cwrapper.CommonErrorStatus.AuthStatus status, IntPtr data)
        {
            AuthFinishedCallback callback = Callbacks.IntPtrToPermanentCallback <AuthFinishedCallback>(data);

            if (callback != null)
            {
                try
                {
                    callback(op, status);
                }
                catch (Exception exception)
                {
                    Logger.e("Error encountered executing InternalAuthFinishedCallback. Smothering to avoid passing exception into Native: " + exception);
                }
            }
        }
Exemple #12
0
        private static void InternalOnMessageReceivedCallback(long id, string name, IntPtr data, UIntPtr dataLength, bool isReliable, IntPtr userData)
        {
            OnMessageReceived received = Callbacks.IntPtrToPermanentCallback <OnMessageReceived>(userData);

            if (received != null)
            {
                try
                {
                    received(id, name, Callbacks.IntPtrAndSizeToByteArray(data, dataLength), isReliable);
                }
                catch (Exception exception)
                {
                    Logger.e("Error encountered executing NativeMessageListenerHelper#InternalOnMessageReceivedCallback. Smothering to avoid passing exception into Native: " + exception);
                }
            }
        }
Exemple #13
0
        private static void InternalOnEndpointLostCallback(long id, string lostEndpointId, IntPtr userData)
        {
            Action <long, string> permanentCallback = Callbacks.IntPtrToPermanentCallback <Action <long, string> >(userData);

            if (permanentCallback == null)
            {
                return;
            }
            try
            {
                permanentCallback(id, lostEndpointId);
            }
            catch (Exception ex)
            {
                Logger.e("Error encountered executing NativeEndpointDiscoveryListenerHelper#InternalOnEndpointLostCallback. Smothering to avoid passing exception into Native: " + (object)ex);
            }
        }
        private static void InternalOnTurnBasedMatchEventCallback(Types.MultiplayerEvent eventType,
                                                                  string matchId, IntPtr match, IntPtr userData)
        {
            var callback = Callbacks.IntPtrToPermanentCallback
                           <Action <Types.MultiplayerEvent, string, NativeTurnBasedMatch> >(userData);

            using (var nativeMatch = NativeTurnBasedMatch.FromPointer(match)) {
                try {
                    if (callback != null)
                    {
                        callback(eventType, matchId, nativeMatch);
                    }
                } catch (Exception e) {
                    Logger.e("Error encountered executing InternalOnTurnBasedMatchEventCallback. " +
                             "Smothering to avoid passing exception into Native: " + e);
                }
            }
        }
        private static void InternalAuthFinishedCallback(Types.AuthOperation op,
                                                         Status.AuthStatus status, IntPtr data)
        {
            AuthFinishedCallback callback =
                Callbacks.IntPtrToPermanentCallback <AuthFinishedCallback>(data);

            if (callback == null)
            {
                return;
            }

            try {
                callback(op, status);
            } catch (Exception e) {
                Logger.e("Error encountered executing InternalAuthFinishedCallback. " +
                         "Smothering to avoid passing exception into Native: " + e);
            }
        }
 internal static void PerformRoomAndParticipantCallback(string callbackName, IntPtr room, IntPtr participant, IntPtr data)
 {
     Logger.d("Entering " + callbackName);
     try
     {
         NativeRealTimeRoom room2 = NativeRealTimeRoom.FromPointer(room);
         using (MultiplayerParticipant participant2 = MultiplayerParticipant.FromPointer(participant))
         {
             Action <NativeRealTimeRoom, MultiplayerParticipant> action = Callbacks.IntPtrToPermanentCallback <Action <NativeRealTimeRoom, 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 }));
     }
 }
Exemple #17
0
        private static void InternalOnInitializationFinishedCallback(NearbyConnectionsStatus.InitializationStatus status, IntPtr userData)
        {
            Action <NearbyConnectionsStatus.InitializationStatus> action = Callbacks.IntPtrToPermanentCallback <Action <NearbyConnectionsStatus.InitializationStatus> >(userData);

            if (action != null)
            {
                try
                {
                    action(status);
                }
                catch (Exception arg)
                {
                    Logger.e("Error encountered executing NearbyConnectionsManagerBuilder#InternalOnInitializationFinishedCallback. Smothering exception: " + arg);
                }
            }
            else
            {
                Logger.w("Callback for Initialization is null. Received status: " + status);
            }
        }
        private static void InternalOnDisconnectedCallback(long id, string lostEndpointId,
                                                           IntPtr userData)
        {
            var userCallback = Callbacks.IntPtrToPermanentCallback <Action <long, string> >(userData);

            if (userCallback == null)
            {
                return;
            }

            try
            {
                userCallback(id, lostEndpointId);
            }
            catch (Exception e)
            {
                Logger.e("Error encountered executing " +
                         "NativeMessageListenerHelper#InternalOnDisconnectedCallback. " +
                         "Smothering to avoid passing exception into Native: " + e);
            }
        }
        private static void InternalOnInitializationFinishedCallback(S.InitializationStatus status,
                                                                     IntPtr userData)
        {
            var callback =
                Callbacks.IntPtrToPermanentCallback <Action <S.InitializationStatus> >(userData);

            if (callback == null)
            {
                Logger.w("Callback for Initialization is null. Received status: " + status);
                return;
            }

            try
            {
                callback(status);
            }
            catch (Exception e)
            {
                Logger.e("Error encountered executing " +
                         "NearbyConnectionsManagerBuilder#InternalOnInitializationFinishedCallback. " +
                         "Smothering exception: " + e);
            }
        }
        private static void InternalOnMultiplayerInvitationEventCallback(Types.MultiplayerEvent eventType, string matchId, IntPtr match, IntPtr userData)
        {
            Action <Types.MultiplayerEvent, string, MultiplayerInvitation> action = Callbacks.IntPtrToPermanentCallback <Action <Types.MultiplayerEvent, string, MultiplayerInvitation> >(userData);
            MultiplayerInvitation invitation = MultiplayerInvitation.FromPointer(match);

            try
            {
                if (action != null)
                {
                    action(eventType, matchId, invitation);
                }
            }
            catch (Exception exception)
            {
                Logger.e("Error encountered executing InternalOnMultiplayerInvitationEventCallback. Smothering to avoid passing exception into Native: " + exception);
            }
            finally
            {
                if (invitation != null)
                {
                    invitation.Dispose();
                }
            }
        }
Exemple #21
0
        private static void InternalOnTurnBasedMatchEventCallback(Types.MultiplayerEvent eventType, string matchId, IntPtr match, IntPtr userData)
        {
            Action <Types.MultiplayerEvent, string, NativeTurnBasedMatch> action = Callbacks.IntPtrToPermanentCallback <Action <Types.MultiplayerEvent, string, NativeTurnBasedMatch> >(userData);
            NativeTurnBasedMatch match2 = NativeTurnBasedMatch.FromPointer(match);

            try
            {
                if (action != null)
                {
                    action(eventType, matchId, match2);
                }
            }
            catch (Exception exception)
            {
                Logger.e("Error encountered executing InternalOnTurnBasedMatchEventCallback. Smothering to avoid passing exception into Native: " + exception);
            }
            finally
            {
                if (match2 != null)
                {
                    match2.Dispose();
                }
            }
        }
Exemple #22
0
        private static void InternalOnTurnBasedMatchEventCallback(Types.MultiplayerEvent eventType, string matchId, IntPtr match, IntPtr userData)
        {
            Action <Types.MultiplayerEvent, string, NativeTurnBasedMatch> permanentCallback = Callbacks.IntPtrToPermanentCallback <Action <Types.MultiplayerEvent, string, NativeTurnBasedMatch> >(userData);

            using (NativeTurnBasedMatch nativeTurnBasedMatch = NativeTurnBasedMatch.FromPointer(match))
            {
                try
                {
                    if (permanentCallback == null)
                    {
                        return;
                    }
                    permanentCallback(eventType, matchId, nativeTurnBasedMatch);
                }
                catch (Exception ex)
                {
                    Logger.e("Error encountered executing InternalOnTurnBasedMatchEventCallback. Smothering to avoid passing exception into Native: " + (object)ex);
                }
            }
        }
        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);
                        }
                    }
                }
            }
        }
Exemple #24
0
        internal static void PerformInternalCallback(string callbackName, Callbacks.Type callbackType, IntPtr response, IntPtr userData)
        {
            Logger.d("Entering internal callback for " + callbackName);
            Action <IntPtr> action = callbackType != Callbacks.Type.Permanent ? Callbacks.IntPtrToTempCallback <Action <IntPtr> >(userData) : Callbacks.IntPtrToPermanentCallback <Action <IntPtr> >(userData);

            if (action == null)
            {
                return;
            }
            try
            {
                action(response);
            }
            catch (Exception ex)
            {
                Logger.e("Error encountered executing " + callbackName + ". Smothering to avoid passing exception into Native: " + (object)ex);
            }
        }
Exemple #25
0
        internal static void PerformInternalCallback <T>(string callbackName, Callbacks.Type callbackType, T param1, IntPtr param2, IntPtr userData)
        {
            Logger.d("Entering internal callback for " + callbackName);
            Action <T, IntPtr> action;

            try
            {
                action = callbackType != Callbacks.Type.Permanent ? Callbacks.IntPtrToTempCallback <Action <T, IntPtr> >(userData) : Callbacks.IntPtrToPermanentCallback <Action <T, IntPtr> >(userData);
            }
            catch (Exception ex)
            {
                Logger.e("Error encountered converting " + callbackName + ". Smothering to avoid passing exception into Native: " + (object)ex);
                return;
            }
            Logger.d("Internal Callback converted to action");
            if (action == null)
            {
                return;
            }
            try
            {
                action(param1, param2);
            }
            catch (Exception ex)
            {
                Logger.e("Error encountered executing " + callbackName + ". Smothering to avoid passing exception into Native: " + (object)ex);
            }
        }
        internal static void InternalOnDataReceived(IntPtr room, IntPtr participant, IntPtr data, UIntPtr dataLength, bool isReliable, IntPtr userData)
        {
            Logger.d("Entering InternalOnDataReceived: " + userData.ToInt64());
            Action <NativeRealTimeRoom, MultiplayerParticipant, byte[], bool> action = Callbacks.IntPtrToPermanentCallback <Action <NativeRealTimeRoom, MultiplayerParticipant, byte[], bool> >(userData);

            using (NativeRealTimeRoom arg = NativeRealTimeRoom.FromPointer(room))
            {
                using (MultiplayerParticipant arg2 = MultiplayerParticipant.FromPointer(participant))
                {
                    if (action != null)
                    {
                        byte[] array = null;
                        if (dataLength.ToUInt64() != 0L)
                        {
                            array = new byte[dataLength.ToUInt32()];
                            Marshal.Copy(data, array, 0, (int)dataLength.ToUInt32());
                        }
                        try
                        {
                            action(arg, arg2, array, isReliable);
                        }
                        catch (Exception arg3)
                        {
                            Logger.e("Error encountered executing InternalOnDataReceived. Smothering to avoid passing exception into Native: " + arg3);
                        }
                    }
                }
            }
        }
 internal static void PerformRoomAndParticipantCallback(string callbackName, IntPtr room, IntPtr participant, IntPtr data)
 {
     Logger.d("Entering " + callbackName);
     try
     {
         NativeRealTimeRoom nativeRealTimeRoom = NativeRealTimeRoom.FromPointer(room);
         using (MultiplayerParticipant multiplayerParticipant = MultiplayerParticipant.FromPointer(participant))
         {
             Action <NativeRealTimeRoom, MultiplayerParticipant> permanentCallback = Callbacks.IntPtrToPermanentCallback <Action <NativeRealTimeRoom, MultiplayerParticipant> >(data);
             if (permanentCallback == null)
             {
                 return;
             }
             permanentCallback(nativeRealTimeRoom, multiplayerParticipant);
         }
     }
     catch (Exception ex)
     {
         Logger.e("Error encountered executing " + callbackName + ". Smothering to avoid passing exception into Native: " + (object)ex);
     }
 }
        internal static void InternalOnDataReceived(IntPtr room, IntPtr participant, IntPtr data, UIntPtr dataLength, bool isReliable, IntPtr userData)
        {
            Logger.d("Entering InternalOnDataReceived: " + (object)userData.ToInt64());
            Action <NativeRealTimeRoom, MultiplayerParticipant, byte[], bool> permanentCallback = Callbacks.IntPtrToPermanentCallback <Action <NativeRealTimeRoom, MultiplayerParticipant, byte[], bool> >(userData);

            using (NativeRealTimeRoom nativeRealTimeRoom = NativeRealTimeRoom.FromPointer(room))
            {
                using (MultiplayerParticipant multiplayerParticipant = MultiplayerParticipant.FromPointer(participant))
                {
                    if (permanentCallback == null)
                    {
                        return;
                    }
                    byte[] destination = (byte[])null;
                    if ((long)dataLength.ToUInt64() != 0L)
                    {
                        destination = new byte[(IntPtr)dataLength.ToUInt32()];
                        Marshal.Copy(data, destination, 0, (int)dataLength.ToUInt32());
                    }
                    try
                    {
                        permanentCallback(nativeRealTimeRoom, multiplayerParticipant, destination, isReliable);
                    }
                    catch (Exception ex)
                    {
                        Logger.e("Error encountered executing InternalOnDataReceived. Smothering to avoid passing exception into Native: " + (object)ex);
                    }
                }
            }
        }