Example #1
0
        //roomName/groupName = string.Empty if ConversationType.OneToOne
        public async Task <string> CreateRoom(Constants.ConversationTypes conversationType, string userId, string groupName)
        {
            NewConversation nc = new NewConversation()
            {
                roomType = Convert.ToInt32(conversationType),
                invite   = userId,
                roomName = groupName
            };

            var jContent = JsonConvert.SerializeObject(nc);

            HttpResponseMessage response = await RequestsBL.POSTRequest("/room", jContent, Constants.BaseRequestStub);

            if (response != null)
            {
                string jResponse     = JsonConvert.SerializeXNode(XDocument.Parse(await response.Content.ReadAsStringAsync()));
                JToken documentToken = JToken.Parse(jResponse);

                var roomContainer = documentToken["ocs"]["data"]["token"].AsJEnumerable();

                if (roomContainer != null)
                {
                    return(roomContainer.ToString());
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
Example #2
0
        public async Task <Chat> SendChat(Room Room, Chat Chat)
        {
            Chat chat = new Chat();

            var jContent = JsonConvert.SerializeObject(Chat);

            HttpResponseMessage response = await RequestsBL.POSTRequest(string.Format
                                                                            ("/chat/{0}", Room.token), jContent, Constants.BaseRequestStub);

            if (response != null)
            {
                if (response.IsSuccessStatusCode)
                {
                    chat = RequestsBL.DeserializeObjects <Chat>(XDocument.Parse(await response.Content.ReadAsStringAsync()), dataPointer)[0];
                }
            }

            return(chat);
        }