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); } }
public static void OnRoomsReceivedCallback(IntPtr actionPtr, int roomType, string roomTopicsJsonArray) { #if DEVELOPMENT_BUILD UnityEngine.Debug.Log("Room topics callback: " + roomTopicsJsonArray + ", room type: " + roomType); #endif if (actionPtr == IntPtr.Zero) { return; } string[] roomTopics = ChatJsonUtils.ParseTopics(roomTopicsJsonArray); if (roomType == RoomTypePublic) { var action = actionPtr.Cast <Action <List <IPublicChatRoom> > >(); action(ConvertToPublicRooms(roomTopics)); } else if (roomType == RoomTypePrivate) { var action = actionPtr.Cast <Action <List <IPrivateChatRoom> > >(); action(ConvertToPrivateRooms(roomTopics)); } else { throw new InvalidOperationException("Unknown room type: " + roomType); } }
public static void OnRoomUserMessagesReceivedCallback(IntPtr actionPtr, string serializedMessages) { #if DEVELOPMENT_BUILD UnityEngine.Debug.Log(System.Reflection.MethodBase.GetCurrentMethod() + serializedMessages); #endif if (actionPtr == IntPtr.Zero) { return; } var action = actionPtr.Cast <Action <List <ChatMessage> > >(); action(ChatJsonUtils.ParseChatMessages(serializedMessages)); }