// // GET: /Home/ public ActionResult Index() { NameValueCollection appSettings = ConfigurationManager.AppSettings; ViewBag.APIKey = appSettings["opentok_key"]; OpenTokSDK opentok = new OpenTokSDK(); string sessionId = opentok.CreateSession(Request.ServerVariables["REMOTE_ADDR"]); Dictionary <string, object> tokenOptions = new Dictionary <string, object>(); tokenOptions.Add(TokenPropertyConstants.ROLE, RoleConstants.MODERATOR); ViewBag.Token = opentok.GenerateToken(sessionId, tokenOptions); return(View()); }
//Connecting Video Chat for Both(patient and Doctor) public void VidoeChat() { lblPatientMobileNo.Text = string.Empty; if (Request.QueryString["session"] != null) { //sessionId = Request.QueryString["session"].ToString(); //token = opentok.GenerateToken(sessionId); hdsession.Value = Request.QueryString["session"].ToString(); hdtoken.Value = opentok.GenerateToken(hdsession.Value); try { Hashtable htSearch = new Hashtable(); DataSet dsList = new DataSet(); myonline.Biz.ADM.VideoChat objBiz = null; objBiz = new myonline.Biz.ADM.VideoChat(); htSearch.Add("flag", 7); htSearch.Add("Session", hdsession.Value); if (System.Web.HttpContext.Current.Session["TimeZone"] != null && Convert.ToString(Session["TimeZone"]) != "-") { htSearch.Add("Time", System.Web.HttpContext.Current.Session["TimeZone"]); } else { htSearch.Add("Time", "+5:30"); } dsList = objBiz.GetTrainerAndTranieeName(htSearch); if (dsList.Tables["ERR_TABLE"] == null || dsList.Tables["ERR_TABLE"].Rows.Count == 0) { string session_id = hdsession.Value; string token_id = hdtoken.Value; if (dsList.Tables[0] != null && dsList.Tables[0].Rows.Count > 0) { if (dsList.Tables[0].Rows[0][0].ToString() != "0") { //lbltrainer.Text = dsList.Tables[0].Rows[0]["DoctorName"].ToString(); //lbltrainee.Text = dsList.Tables[0].Rows[0]["PatientName"].ToString(); lbltrainer.Text = dsList.Tables[0].Rows[0]["PatientName"].ToString().ToLower(); lbltrainee.Text = dsList.Tables[0].Rows[0]["DoctorName"].ToString().ToLower(); hdnPatientName.Value = dsList.Tables[0].Rows[0]["PatientName"].ToString().ToLower(); PatientId = dsList.Tables[0].Rows[0][2].ToString(); DoctorId = dsList.Tables[0].Rows[0][3].ToString(); AppointMentId = dsList.Tables[0].Rows[0][4].ToString(); AppontMentId.Value = AppointMentId; } else { Response.Redirect(ResolveUrl("DoctorVideoChat.aspx?Request=false")); } } else if (dsList.Tables[0] == null || dsList.Tables[0].Rows.Count == 0) { } } } catch (Exception ex) { Response.Write(ex.InnerException); } //Gettime(); //Page.ClientScript.RegisterStartupScript(Page.GetType(), "onload", "StartVideo();", true); ScriptManager.RegisterStartupScript(this, this.GetType(), "onload", "StartVideo();", true); } else { string msg = string.Empty; string sessionId = string.Empty; string token = string.Empty; OpenTokSDK opentok = new OpenTokSDK(); Hashtable htSearch = new Hashtable(); DataSet dsList = new DataSet(); string ReturnStatusMsg = string.Empty; string sTransMsg = String.Empty; try { //sessionId = opentok.CreateSession("Global-Training"); //token = opentok.GenerateToken(sessionId); string abcdsession = opentok.CreateSession("Global-Training"); string abcdtoken = opentok.GenerateToken(abcdsession); hdsession.Value = abcdsession; hdtoken.Value = abcdtoken; myonline.Biz.ADM.VideoChat objBiz = null; objBiz = new myonline.Biz.ADM.VideoChat(); htSearch.Clear(); htSearch.Add("flag", 2); htSearch.Add("doctorId", HttpContext.Current.Session["USER_SEQ"]); htSearch.Add("Chat_Status", "Pending"); htSearch.Add("AppointMentId", Request.QueryString["AppointMentId"]); htSearch.Add("Session_Id", hdsession.Value); htSearch.Add("Generate_Date", DateTime.UtcNow.ToString()); htSearch.Add("Expire_Date", DateTime.UtcNow.AddMinutes(15)); if (System.Web.HttpContext.Current.Session["TimeZone"] != null && Convert.ToString(Session["TimeZone"]) != "-") { htSearch.Add("Time", System.Web.HttpContext.Current.Session["TimeZone"]); } else { htSearch.Add("Time", "+5:30"); } dsList = objBiz.Send_request(htSearch, ref ReturnStatusMsg); if (dsList.Tables["ERR_TABLE"] == null || dsList.Tables["ERR_TABLE"].Rows.Count == 0) { string session_id = hdsession.Value; string token_id = hdtoken.Value; if (dsList.Tables[0] != null && dsList.Tables[0].Rows.Count > 0) { if (dsList.Tables[0].Rows[0][0].ToString() != "0") { AppontMentId.Value = dsList.Tables[0].Rows[0][1].ToString(); lbltrainer.Text = dsList.Tables[0].Rows[0]["DoctorName"].ToString().ToLower(); lbltrainee.Text = dsList.Tables[0].Rows[0]["PatientName"].ToString().ToLower(); hdnDoctorName.Value = dsList.Tables[0].Rows[0]["DoctorName"].ToString().ToLower(); DoctorId = dsList.Tables[0].Rows[0][4].ToString(); PatientId = dsList.Tables[0].Rows[0][5].ToString(); AppointMentId = dsList.Tables[0].Rows[0][1].ToString(); lblPatientMobileNo.Text = dsList.Tables[0].Rows[0]["MobileNumber"].ToString(); //Page.ClientScript.RegisterStartupScript(Page.GetType(), "onload", "StartVideo();", true); ScriptManager.RegisterStartupScript(this, this.GetType(), "onload", "StartVideo();", true); } else { Response.Redirect(ResolveUrl("DoctorVideoChat.aspx?Request=false")); } } else if (dsList.Tables[0] == null || dsList.Tables[0].Rows.Count == 0) { } } else if (dsList.Tables["ERR_TABLE"] != null && dsList.Tables["ERR_TABLE"].Rows.Count != 0) { } } catch (Exception ex) { throw ex; } } }
protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["Transid"] != null) { Transid = AppSecurity.Decrypt(Request.QueryString["Transid"].ToString()); BECommon objBECommon = new BECommon(); objBECommon.strTransID = Transid; BCommon objBCommon = new BCommon(); objBCommon.BOpenTokGetArchiveID(objBECommon); ArchiveId = objBECommon.strArchiveId; if (ArchiveId.Trim().Length > 0) { SessionID = "2_MX4yODQ2NTExMn4xOTIuMTY4LjEuMX5TdW4gTWF5IDEyIDIzOjQyOjMyIFBEVCAyMDEzfjAuNjk0NzQ5OH4"; //SessionID = "2_MX4yODQ2NTExMn5-V2VkIE1heSAwOCAwMDoxODowNCBQRFQgMjAxM34wLjIxNTc2MDQxfg"; OpenTokSDK opentok = new OpenTokSDK(); Dictionary <string, object> options = new Dictionary <string, object>(); options.Add("role", "moderator"); TokenID = opentok.GenerateToken(SessionID, options); //Response.Clear(); System.Net.WebRequest request = System.Net.WebRequest.Create(@"https://api.opentok.com/hl/archive/getmanifest/" + ArchiveId.Trim()); request.Headers.Add("x-tb-token-auth", TokenID); //api key and secret key request.Headers.Add("X-TB-PARTNER-AUTH", "28465112:4ccafe5e867b5d99722c9b089593b9460bc02f1d"); System.Net.WebResponse response = request.GetResponse(); System.IO.StreamReader sr = new System.IO.StreamReader(response.GetResponseStream(), System.Text.Encoding.Default); string content = sr.ReadToEnd(); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(content); XmlNodeList elementList = xmlDoc.GetElementsByTagName("video"); for (int i = 0; i < elementList.Count; i++) { videoid = elementList[i].Attributes["id"].Value; } sr.Close(); request = System.Net.WebRequest.Create(@"https://api.opentok.com/hl/archive/url/" + ArchiveId.Trim() + "/" + videoid.Trim()); request.Headers.Add("x-tb-token-auth", TokenID); request.Headers.Add("X-TB-PARTNER-AUTH", "28465112:4ccafe5e867b5d99722c9b089593b9460bc02f1d"); response = request.GetResponse(); sr = new System.IO.StreamReader(response.GetResponseStream(), System.Text.Encoding.Default); content = sr.ReadToEnd(); sr.Close(); //Response.Redirect(content.ToString()); videosource = Server.UrlEncode(content.ToString()); //Response.Write(videosource); } } }