コード例 #1
0
        /// <summary>
        /// Returns a List of <see cref="Archive"/> objects, representing archives that are both
        /// both completed and in-progress, for your API key.
        /// </summary>
        /// <param name="offset">
        /// The index offset of the first archive. 0 is offset of the most recently started archive.
        /// 1 is the offset of the archive that started prior to the most recent archive.
        /// </param>
        /// <param name="count">
        /// The number of archives to be returned. The maximum number of archives returned is 1000.
        /// </param>
        /// <returns>A List of <see cref="Archive"/> objects.</returns>
        public ArchiveList ListArchives(int offset = 0, int count = 0, string sessionId = "")
        {
            if (count < 0)
            {
                throw new OpenTokArgumentException("count cannot be smaller than 0");
            }
            string url = string.Format("v2/project/{0}/archive?offset={1}", this.ApiKey, offset);

            if (count > 0)
            {
                url = string.Format("{0}&count={1}", url, count);
            }
            if (!string.IsNullOrEmpty(sessionId))
            {
                if (!OpenTokUtils.ValidateSession(sessionId))
                {
                    throw new OpenTokArgumentException("Session Id is not valid");
                }
                url = $"{url}&sessionId={sessionId}";
            }
            string      response     = Client.Get(url);
            JObject     archives     = JObject.Parse(response);
            JArray      archiveArray = (JArray)archives["items"];
            ArchiveList archiveList  = new ArchiveList(archiveArray.ToObject <List <Archive> >(), (int)archives["count"]);

            return(archiveList);
        }
コード例 #2
0
ファイル: OpenTok.cs プロジェクト: vkyadav03/Opentok-.NET-SDK
        /**
         * Force disconnects a specific client connected to an OpenTok session.
         *
         * @param sessionId The session ID corresponding to the session.
         *
         * @param connectionId The connectionId of the connection in a session..
         */
        public void ForceDisconnect(string sessionId, string connectionId)
        {
            if (String.IsNullOrEmpty(sessionId) || String.IsNullOrEmpty(connectionId))
            {
                throw new OpenTokArgumentException("The sessionId or connectionId cannot be null or empty");
            }

            if (!OpenTokUtils.ValidateSession(sessionId))
            {
                throw new OpenTokArgumentException("Invalid session Id");
            }
            string url     = string.Format("v2/project/{0}/session/{1}/connection/{2}", this.ApiKey, sessionId, connectionId);
            var    headers = new Dictionary <string, string>();

            Client.Delete(url, headers);
        }
コード例 #3
0
ファイル: OpenTok.cs プロジェクト: vkyadav03/Opentok-.NET-SDK
        /**
         * Creates a token for connecting to an OpenTok session. In order to authenticate a user
         * connecting to an OpenTok session, the client passes a token when connecting to the
         * session.
         * <p>
         * For testing, you can also generate test tokens by logging in to your
         * <a href="https://tokbox.com/account">TokBox account</a>.
         *
         * @param sessionId The session ID corresponding to the session to which the user will
         * connect.
         *
         * @param role The role for the token. Valid values are defined in the Role enum:
         * <ul>
         *   <li> <code>Role.SUBSCRIBER</code> &mdash; A subscriber can only subscribe to
         *     streams.</li>
         *
         *   <li> <code>Role.PUBLISHER</code> &mdash; A publisher can publish streams, subscribe to
         *      streams, and signal. (This is the default value if you do not specify a role.)</li>
         *
         *   <li> <code>Role.MODERATOR</code> &mdash; In addition to the privileges granted to a
         *     publisher, in clients using the OpenTok.js library, a moderator can call the
         *     <code>forceUnpublish()</code> and <code>forceDisconnect()</code> method of the
         *     Session object.</li>
         * </ul>
         *
         * @param expireTime The expiration time of the token, in seconds since the UNIX epoch.
         * Pass in 0 to use the default expiration time of 24 hours after the token creation time.
         * The maximum expiration time is 30 days after the creation time.
         *
         * @param data A string containing connection metadata describing the end-user. For example,
         * you can pass the user ID, name, or other data describing the end-user. The length of the
         * string is limited to 1000 characters. This data cannot be updated once it is set.
         *
         * @param initialLayoutClassList A list of strings values containing the initial layout for the stream.
         *
         * @return The token string.
         */
        public string GenerateToken(string sessionId, Role role = Role.PUBLISHER, double expireTime = 0, string data = null, List <string> initialLayoutClassList = null)
        {
            if (String.IsNullOrEmpty(sessionId))
            {
                throw new OpenTokArgumentException("Session id cannot be empty or null");
            }

            if (!OpenTokUtils.ValidateSession(sessionId))
            {
                throw new OpenTokArgumentException("Invalid Session id " + sessionId);
            }

            Session session = new Session(sessionId, this.ApiKey, this.ApiSecret);

            return(session.GenerateToken(role, expireTime, data, initialLayoutClassList));
        }