Пример #1
0
        public static ChatMessage ParseChatMessage(string serializedMessage)
        {
            if (string.IsNullOrEmpty(serializedMessage))
            {
                return(null);
            }

            var jsonMessage = new JSONObject(serializedMessage);

            var sender    = new User(jsonMessage[JsonPropertyUser]);
            var timestamp = ParseUtils.UnixTimeStampToDateTime(jsonMessage[JsonPropertyTimestamp].n);

            string guid = null;

            if (jsonMessage.HasField(JsonPropertyGuid))
            {
                guid = jsonMessage[JsonPropertyGuid].str;
            }
            else
            {
                Debug.LogError("Message GUID is not present in received message.");
            }

            var wasSentByMe = jsonMessage[JsonPropertyWasSentByMe].b;

            var text    = jsonMessage[JsonPropertyContent][JsonPropertyContentText].str;
            var content = new ChatMessageContent(text);

            return(new ChatMessage(sender, guid, timestamp, wasSentByMe, content));
        }
Пример #2
0
 public void SendMessage(ChatMessageContent messageContent, Action onSuccess, Action <string> onFailure)
 {
     // For now we support only sending text messages
     _sendUserMessage(roomTopic, messageContent.MessageText,
                      onSuccess.GetPointer(),
                      onFailure.GetPointer(),
                      GetSocialNativeBridgeIOS.CompleteCallback,
                      GetSocialNativeBridgeIOS.FailureCallback);
 }
Пример #3
0
 public void SendMessage(ChatMessageContent messageContent, Action onSuccess, Action <string> onFailure)
 {
     AndroidUtils.RunOnUiThread(() =>
     {
         chatRoomJavaObject.Call("sendMessage",
                                 AndroidChatUtils.CreateChatMessageContentAJO(messageContent.MessageText),
                                 new OperationVoidCallbackProxy(onSuccess, onFailure));
     });
 }
        public static ChatMessage ChatMessageFromJavaObject(AndroidJavaObject chatMessageAJO)
        {
            User     sender      = AndroidUtils.UserFromJavaObj(chatMessageAJO.Call <AndroidJavaObject>("getSender"));
            string   guid        = chatMessageAJO.Call <string>("getGuid");
            DateTime timestamp   = AndroidUtils.DateTimeFromJavaUtilDate(chatMessageAJO.Call <AndroidJavaObject>("getTimestamp"));
            bool     wasSentByMe = chatMessageAJO.Call <bool>("wasSentByMe");

            // For now - only text messges supproted
            var msgText = chatMessageAJO.Call <AndroidJavaObject>("getContent").Call <string>("getText");

            chatMessageAJO.Dispose();
            return(new ChatMessage(sender, guid, timestamp, wasSentByMe, ChatMessageContent.CreateWithText(msgText)));
        }
 internal ChatMessage(User sender, string guid, DateTime timestamp, bool wasSentByMe, ChatMessageContent content)
 {
     this.sender      = sender;
     this.guid        = guid;
     this.timestamp   = timestamp;
     this.wasSentByMe = wasSentByMe;
     this.content     = content;
 }