public CreateSession ( string location = "", MediaMode mediaMode = MediaMode.RELAYED, ArchiveMode archiveMode = ArchiveMode.MANUAL ) : OpenTokSDK.Session | ||
location | string | |
mediaMode | MediaMode | |
archiveMode | ArchiveMode | |
Résultat | OpenTokSDK.Session |
public void CreateP2pSessionTest() { string sessionId = "SESSIONID"; string returnString = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><sessions><Session><" + "session_id>" + sessionId + "</session_id><partner_id>123456</partner_id><create_dt>" + "Mon Mar 17 00:41:31 PDT 2014</create_dt></Session></sessions>"; var expectedUrl = "session/create"; var mockClient = new Mock<HttpClient>(); mockClient.Setup(httpClient => httpClient.Post(It.IsAny<string>(), It.IsAny<Dictionary<string, string>>(), It.IsAny<Dictionary<string, object>>())).Returns(returnString); HttpClient client = mockClient.Object; OpenTok opentok = new OpenTok(apiKey, apiSecret); opentok.Client = client; Session session = opentok.CreateSession(p2p: true); Assert.NotNull(session); Assert.Equal(this.apiKey, session.ApiKey); Assert.Equal(sessionId, session.Id); Assert.True(session.P2p); Assert.Equal(session.Location, ""); mockClient.Verify(httpClient => httpClient.Post(It.Is<string>(url => url.Equals(expectedUrl)), It.IsAny<Dictionary<string, string>>(), It.IsAny<Dictionary<string, object>>()), Times.Once()); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); RouteConfig.RegisterRoutes(RouteTable.Routes); OpenTok opentok = new OpenTok(Convert.ToInt32(ConfigurationManager.AppSettings["opentok_key"]), ConfigurationManager.AppSettings["opentok_secret"]); Application["sessionId"] = opentok.CreateSession().Id; }
public void GenerateComplexTokenTest() { OpenTok opentok = new OpenTok(apiKey, apiSecret); Session session = opentok.CreateSession(); double expireTime = OpenTokUtils.GetCurrentUnixTimeStamp() + 10; string token = session.GenerateToken(role: Role.MODERATOR, expireTime: expireTime, data: "Connection data"); CheckToken(token, apiKey); }
public void CreateSessionWithLocationTest() { OpenTok opentok = new OpenTok(apiKey, apiSecret); Session session = opentok.CreateSession(location: "0.0.0.0"); Assert.NotNull(session); Assert.Equal(session.ApiKey, apiKey); Assert.Equal(session.ApiSecret, apiSecret); Assert.Equal(session.P2p, false); Assert.Equal(session.Location, "0.0.0.0"); Assert.True(ValidateSession(session.Id)); }
public void CreateP2pSessionTest() { OpenTok opentok = new OpenTok(apiKey, apiSecret); Session session = opentok.CreateSession(p2p: true); Assert.NotNull(session); Assert.Equal(session.ApiKey, apiKey); Assert.Equal(session.ApiSecret, apiSecret); Assert.Equal(session.P2p, true); Assert.Equal(session.Location, ""); Assert.True(ValidateSession(session.Id)); }
public void CreateLocationSessionTest() { OpenTok opentok = new OpenTok(apiKey, apiSecret); Session session; try { session = opentok.CreateSession(location: "A location"); Assert.True(false); } catch(OpenTokArgumentException) { Assert.True(true); } }
public void CreateInvalidSessionLocationTest() { var mockClient = new Mock<HttpClient>(); mockClient.Setup(httpClient => httpClient.Post(It.IsAny<string>(), It.IsAny<Dictionary<string, string>>(), It.IsAny<Dictionary<string, object>>())).Returns("This function should not return anything"); OpenTok opentok = new OpenTok(apiKey, apiSecret); Session session; try { session = opentok.CreateSession(location: "A location"); Assert.True(false); } catch (OpenTokArgumentException) { Assert.True(true); } }
public ActionResult Index() { var OpenTok = new OpenTok(ApiKey, ApiSecret); //// Create a session that will attempt to transmit streams directly between clients //var session = OpenTok.CreateSession(); //// Store this sessionId in the database for later use: //string sessionId = session.Id; // Create a session that uses the OpenTok Media Router (which is required for archiving) var session = OpenTok.CreateSession(mediaMode: MediaMode.ROUTED); // Store this sessionId in the database for later use: // string sessionId = session.Id; //// Create an automatically archived session: //var session = OpenTok.CreateSession(mediaMode: MediaMode.ROUTED, ArchiveMode.ALWAYS); // Store this sessionId in the database for later use: ViewBag.sessionId = session.Id; return View(); }
public void GenerateSubscriberTokenTest() { OpenTok opentok = new OpenTok(apiKey, apiSecret); Session session = opentok.CreateSession(p2p: true); string token = session.GenerateToken(role: Role.SUBSCRIBER); CheckToken(token, apiKey); }
public void GenerateTokenWithInvalidExpiryTimeTest() { OpenTok opentok = new OpenTok(apiKey, apiSecret); Session session = opentok.CreateSession(); double expireTime = OpenTokUtils.GetCurrentUnixTimeStamp() - 1; string token; try { token = session.GenerateToken(role: Role.MODERATOR, expireTime: expireTime, data: "Connection data"); Assert.False(true); } catch(OpenTokArgumentException) { Assert.True(true); } }
public void GenerateTokenWithExpireTimeTest() { OpenTok opentok = new OpenTok(apiKey, apiSecret); Session session = opentok.CreateSession(p2p: true); double expireTime = OpenTokUtils.GetCurrentUnixTimeStamp() + 10; string token = session.GenerateToken(expireTime: expireTime); CheckToken(token, apiKey); }
public void GenerateTokenWithDataTest() { OpenTok opentok = new OpenTok(apiKey, apiSecret); Session session = opentok.CreateSession(p2p: true); string token = session.GenerateToken(data: "This is some data"); CheckToken(token, apiKey); }
public void GenerateTokenTest() { OpenTok opentok = new OpenTok(apiKey, apiSecret); Session session = opentok.CreateSession(p2p: true); string token = session.GenerateToken(); CheckToken(token, apiKey); }
public void CreateInvalidAlwaysArchivedReplayedSessionTest() { var mockClient = new Mock<HttpClient>(); mockClient.Setup(httpClient => httpClient.Post(It.IsAny<string>(), It.IsAny<Dictionary<string, string>>(), It.IsAny<Dictionary<string, object>>())).Returns("This function should not return anything"); OpenTok opentok = new OpenTok(apiKey, apiSecret); Session session; try { session = opentok.CreateSession(mediaMode: MediaMode.RELAYED, archiveMode: ArchiveMode.ALWAYS); Assert.True(false); } catch (OpenTokArgumentException) { Assert.True(true); } }