public ConversationImageMessageReceivedEventArgs(HangoutsEvent imageMessage)
 {
     this.ImageMessage = imageMessage;
 }
        internal static HangoutsEvent ParseSingleHistory(string eventJson)
        {
            /*
             * { conversation_id: { id: 'UgxYDBnv4CKBX-lbkkh4AaABAagB9-mXBQ' },
                    sender_id:
                        { gaia_id: '107911499164111484101',
                          chat_id: '107911499164111484101' },
                          timestamp: 1447753554155276,
                          self_event_state:
                            { user_id:
                                { gaia_id: '107510317300187854172',
                                  chat_id: '107510317300187854172' },
                              client_generated_id: null,
                              notification_level: {} },
                   chat_message:
                        { annotation: [],
                          message_content: { segment: [Object], Attachment: [] } },
                   membership_change: { type: <type> , participants : [ {gaia_id: <gaia_id>, chat_id: <chat_id> }, ...] },
                   conversation_rename: { old_name : <old_name>, new_name : <new_name> },
                   hangout_event: null, //Don't know what is this
                   event_id: '86e6rTa7tHE86e6s0pvx-z',
                   advances_sort_timestamp: null, //Ignored
                   otr_modification: null,  //Ignored
                   event_otr: 'ON_THE_RECORD' //Not really useful for end users }
             */
            HangoutsEvent history = null;
            try
            {
                if (!Util.IsValidJsonObjectString(eventJson))
                {
                    return history;
                }
                JObject jObjEvent = JObject.Parse(eventJson);

                //chat message can be null when the action is renaming or membership change
                JObject jObjChatMessage = null;
                if (jObjEvent.GetValue("chat_message") != null && string.IsNullOrEmpty(jObjEvent.GetValue("chat_message").ToString()) == false)
                {
                    jObjChatMessage = (JObject)jObjEvent.GetValue("chat_message");
                }

                //rename will be null when current event is not renaming
                JObject jObjRenameEvent = null;
                if (jObjEvent.GetValue("conversation_rename") != null && jObjEvent.GetValue("conversation_rename").ToString() != string.Empty)
                {
                    jObjRenameEvent = (JObject)jObjEvent.GetValue("conversation_rename");
                }

                //membership change will be null when current event is not membership change
                JObject jObjMembershipChange = null;
                if (jObjEvent.GetValue("membership_change") != null && jObjEvent.GetValue("membership_change").ToString() != string.Empty)
                {
                    jObjMembershipChange = (JObject)jObjEvent.GetValue("membership_change");
                }

                //Check for both null then whether it is an JObject
                ChatMessage chatMessage = null;
                if (jObjChatMessage != null && Util.IsJsonObject(jObjChatMessage))
                {
                    chatMessage = ChatMessage.ParseSingleMessage(jObjEvent.GetValue("chat_message").ToString());
                }

                //Check for null then empty string
                RenameEvent renameEvent = null;
                if (jObjRenameEvent != null && Util.IsJsonObject(jObjRenameEvent))
                {
                    renameEvent = new RenameEvent(
                        jObjRenameEvent.GetValue("new_name").ToString(),
                        jObjRenameEvent.GetValue("old_name").ToString());
                }

                //Check for both null then empty string
                MembershipChangeEvent membershipChangeEvent = null;
                if (jObjMembershipChange != null && Util.IsJsonObject(jObjMembershipChange))
                {
                    //Further check participant ids whether is castable to JArray
                    if (Util.IsJsonArray(jObjMembershipChange.GetValue("participant_ids")))
                    {
                        JArray jArrayInvolvedParticipants = (JArray)jObjMembershipChange.GetValue("participant_ids");

                        List<Participant.ID> involvedParticipants = new List<Participant.ID>();
                        foreach (JObject jObj in jArrayInvolvedParticipants)
                        {
                            involvedParticipants.Add(new Participant.ID(jObj.GetValue("gaia_id").ToString(), jObj.GetValue("chat_id").ToString()));
                        }

                        membershipChangeEvent = new MembershipChangeEvent(
                            jObjMembershipChange.GetValue("type").ToString(),
                            involvedParticipants.ToArray<Participant.ID>());
                    }
                }

                history = new HangoutsEvent(
                    jObjEvent.GetValue("event_id").ToString(),
                    new Participant.ID(jObjEvent.SelectToken("sender_id.gaia_id").ToString(), jObjEvent.SelectToken("sender_id.chat_id").ToString()),
                    long.Parse(jObjEvent.GetValue("timestamp").ToString()),
                    chatMessage,
                    renameEvent,
                    membershipChangeEvent
                    );

                return history;
            }
            catch (Exception ex)
            {
                throw new HangoutsException("ParseSingleHistory : " + ex.Message + Environment.NewLine + ex.StackTrace);
            }
        }
 public ConversationChatMessageReceivedEventArgs(HangoutsEvent chatMessage)
 {
     this.ChatMessage = chatMessage;
 }