コード例 #1
0
        public static void OnMessageReceivedCallback(IntPtr actionPtr,
                                                     string roomTopic, int roomType, string serializedMessage)
        {
#if DEVELOPMENT_BUILD
            UnityEngine.Debug.Log(string.Format("Received message, roomId: {0}, roomType: {1}, message: {2}",
                                                roomTopic, roomType, serializedMessage));
#endif
            if (actionPtr == IntPtr.Zero)
            {
                return;
            }

            var message = ChatJsonUtils.ParseChatMessage(serializedMessage);

            if (roomType == RoomTypePublic)
            {
                var room = new PublicChatRoomIOSImpl(roomTopic);
                actionPtr.Cast <Action <IPublicChatRoom, ChatMessage> >().Invoke(room, message);
            }
            else if (roomType == RoomTypePrivate)
            {
                var room = new PrivateChatRoomIOSImpl(roomTopic);
                actionPtr.Cast <Action <IPrivateChatRoom, ChatMessage> >().Invoke(room, message);
            }
            else
            {
                throw new InvalidOperationException("Unknown room type: " + roomType);
            }
        }
コード例 #2
0
        public static void OnRoomMessageCallback(IntPtr actionPtr, string serializedMessage)
        {
#if DEVELOPMENT_BUILD
            UnityEngine.Debug.Log(System.Reflection.MethodBase.GetCurrentMethod() + serializedMessage);
#endif
            if (actionPtr == IntPtr.Zero)
            {
                return;
            }

            var action = actionPtr.Cast <Action <ChatMessage> >();
            action(ChatJsonUtils.ParseChatMessage(serializedMessage));
        }