Esempio n. 1
0
        public JsonResult PostSDP(string sdp, string roomToken, string userToken)
        {
            var sdpmessage = new WebRTCSDPMessage
            {
                SDP         = sdp,
                IsProcessed = false,
                RoomToken   = roomToken,
                Sender      = userToken
            };

            _sdpMessageRepository.Save(sdpmessage);

            return(Json(true, JsonRequestBehavior.AllowGet));
        }
Esempio n. 2
0
        public JsonResult PostSDP(string sdp, string roomToken, string userToken)
        {
            WebRTCSDPMessage sdpmessage = new WebRTCSDPMessage()
            {
                ID          = Guid.NewGuid().ToString(),
                SDP         = sdp,
                IsProcessed = false,
                RoomToken   = roomToken,
                Sender      = userToken,
                CreateOn    = DateTime.Now,
            };

            entities.WebRTCSDPMessage.Add(sdpmessage);
            entities.SaveChanges();

            return(Json(true, JsonRequestBehavior.AllowGet));
        }
Esempio n. 3
0
        public JsonResult GetSDP()
        {
            string roomToken = Request["roomToken"];
            string userToken = Request["userToken"];

            WebRTCSDPMessage sdpMessage = entities.WebRTCSDPMessage.FirstOrDefault(t => t.RoomToken == roomToken && t.Sender != userToken && t.IsProcessed == false);

            if (sdpMessage == null)
            {
                return(Json(false, JsonRequestBehavior.AllowGet));
            }

            sdpMessage.IsProcessed = true;
            entities.Entry(sdpMessage).CurrentValues.SetValues(sdpMessage);
            entities.SaveChanges();

            Users user = entities.Users.FirstOrDefault(t => t.Id == sdpMessage.Sender);

            return(Json(new { sdp = sdpMessage.SDP, partUserName = user.UserName, partPhoto = user.Photo }, JsonRequestBehavior.AllowGet));
        }