Get your live session with token by live session id.

@param sessionId Live session id.
@param timeoutInMinute Timeout of token.
@return Your live session with token.
326026
public GetSessionResponse getSessionWithToken(String sessionId, Integer timeoutInMinute) {
        GetSessionResponse getSessionResponse = getSession(sessionId);
        if (timeoutInMinute == null) {
            return getSessionResponse;
        }
        DateTime dateTime = new DateTime(DateTimeZone.UTC);
        DateTime expireTime = dateTime.plusMinutes(timeoutInMinute);
        DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss'Z'");
        String expire = formatter.print(expireTime);

        GetSecurityPolicyResponse getSecurityPolicyResponse = getSecurityPolicy(getSessionResponse.getSecurityPolicy());
        Map<String, String> hlsUrls = new HashMap<String, String>();
        Map<String, String> rtmpUrls = new HashMap<String, String>();
        Map<String, String> flvUrls = new HashMap<String, String>();
        if (getSecurityPolicyResponse.getAuth().getPlay()) {
            if (getSessionResponse.getPlay().getHlsUrls() != null) {
                for (Map.Entry<String, String> entry : getSessionResponse.getPlay().getHlsUrls().entrySet()) {
                    String line = entry.getKey();
                    String hlsUrl = entry.getValue();
                    if (hlsUrl != null) {
                        String hlsToken = null;
                        if (line.equals("L0")) {
                            hlsToken = LssUtils.hmacSha256(
                                    String.format("/%s/live.m3u8;%s", sessionId, expire),
                                    getSecurityPolicyResponse.getAuth().getKey());
                        } else {
                            hlsToken = LssUtils.hmacSha256(
                                    String.format("/%s-%s/live.m3u8;%s", sessionId, line, expire),
                                    getSecurityPolicyResponse.getAuth().getKey());
                        }
                        if (hlsUrl.lastIndexOf('?') == -1) {
                            hlsUrl += String.format("?token=%s&expire=%s", hlsToken, expire);
                        } else {
                            hlsUrl += String.format("&token=%s&expire=%s", hlsToken, expire);
                        }
                        hlsUrls.put(line, hlsUrl);
                    }
                }

                getSessionResponse.getPlay().setHlsUrls(hlsUrls);
            } else if (getSessionResponse.getPlay().getHlsUrl() != null) {
                String hlsUrl = getSessionResponse.getPlay().getHlsUrl();
                String hlsToken = LssUtils.hmacSha256(
                        String.format("/%s/live.m3u8;%s", sessionId, expire),
                        getSecurityPolicyResponse.getAuth().getKey());
                if (hlsUrl.lastIndexOf('?') == -1) {
                    hlsUrl += String.format("?token=%s&expire=%s", hlsToken, expire);
                } else {
                    hlsUrl += String.format("&token=%s&expire=%s", hlsToken, expire);
                }

                getSessionResponse.getPlay().setHlsUrl(hlsUrl);
            }

            if (getSessionResponse.getPlay().getRtmpUrls() != null) {
                for (Map.Entry<String, String> entry : getSessionResponse.getPlay().getRtmpUrls().entrySet()) {
                    String line = entry.getKey();
                    String rtmpUrl = entry.getValue();
                    if (rtmpUrl != null) {
                        String rtmpToken = LssUtils.hmacSha256(
                                String.format("%s;%s", sessionId, expire),
                                getSecurityPolicyResponse.getAuth().getKey());
                        rtmpUrl += String.format("?token=%s&expire=%s", rtmpToken, expire);
                    }
                    rtmpUrls.put(line, rtmpUrl);
                }

                getSessionResponse.getPlay().setRtmpUrls(rtmpUrls);
            } else if (getSessionResponse.getPlay().getRtmpUrl() != null) {
                String rtmpUrl = getSessionResponse.getPlay().getRtmpUrl();
                String rtmpToken = LssUtils.hmacSha256(
                        String.format("%s;%s", sessionId, expire),
                        getSecurityPolicyResponse.getAuth().getKey());
                rtmpUrl += String.format("?token=%s&expire=%s", rtmpToken, expire);

                getSessionResponse.getPlay().setRtmpUrl(rtmpUrl);
            }

            if (getSessionResponse.getPlay().getFlvUrls() != null) {
                for (Map.Entry<String, String> entry : getSessionResponse.getPlay().getFlvUrls().entrySet()) {
                    String line = entry.getKey();
                    String flvUrl = entry.getValue();
                    if (flvUrl != null) {
                        String flvToken = LssUtils.hmacSha256(
                                String.format("%s;%s", flvUrl, expire),
                                getSecurityPolicyResponse.getAuth().getKey());
                        flvUrl += String.format("?token=%s&expire=%s", flvToken, expire);
                    }
                    flvUrls.put(line, flvUrl);
                }

                getSessionResponse.getPlay().setFlvUrls(flvUrls);
            } else if (getSessionResponse.getPlay().getFlvUrl() != null) {
                String flvUrl = getSessionResponse.getPlay().getFlvUrl();
                String flvToken = LssUtils.hmacSha256(
                        String.format("%s;%s", flvUrl, expire),
                        getSecurityPolicyResponse.getAuth().getKey());
                flvUrl += String.format("?token=%s&expire=%s", flvToken, expire);

                getSessionResponse.getPlay().setFlvUrl(flvUrl);

            }
        }

        if (getSecurityPolicyResponse.getAuth().getPush()) {
            String pushUrl = getSessionResponse.getPublish().getPushUrl();
            String pushToken = LssUtils.hmacSha256(
                    String.format("%s;%s", getSessionResponse.getPublish().getPushStream(), expire),
                    getSecurityPolicyResponse.getAuth().getKey());
            pushUrl += String.format("?token=%s&expire=%s", pushToken, expire);
            getSessionResponse.getPublish().setPushUrl(pushUrl);
        }

        return getSessionResponse;
    }
422369
public Long getSessionTimeout() {
        //  look in the login result...if it is success
        DefaultLoginResult loginResult;
        if ( loginContext != null && (loginResult = loginContext.getLoginResult()) != null) {
            Long sessionTimeout = loginResult.getSessionTimeout();
            if ( sessionTimeout != null && sessionTimeout > 0 ) {
                return sessionTimeout;
            }
        }
        return null;
    }
144365
public Duration getNextRetryInterval(String clientId, Exception lastException, Duration remainingTime) {
        int baseWaitTime = 0;
        synchronized (this.serverBusySync) {
            if (lastException != null
                    && (lastException instanceof ServerBusyException || (lastException.getCause() != null && lastException.getCause() instanceof ServerBusyException))) {
                baseWaitTime += ClientConstants.SERVER_BUSY_BASE_SLEEP_TIME_IN_SECS;
            }
        }

        return this.onGetNextRetryInterval(clientId, lastException, remainingTime, baseWaitTime);
    }
1343306
public function get_session_lock($rowid, $timeout) {
        parent::get_session_lock($rowid, $timeout);

        $fullname = $this->dbname.'-'.$this->prefix.'-session-'.$rowid;
        $sql = 'SELECT MOODLELIB.GET_LOCK(:lockname, :locktimeout) FROM DUAL';
        $params = array('lockname' => $fullname , 'locktimeout' => $timeout);
        $this->query_start($sql, $params, SQL_QUERY_AUX);
        $stmt = $this->parse_query($sql);
        $this->bind_params($stmt, $params);
        $result = oci_execute($stmt, $this->commit_status);
        if ($result === false) { // Any failure in get_lock() raises error, causing return of bool false
            throw new dml_sessionwait_exception();
        }
        $this->query_end($result, $stmt);
        oci_free_statement($stmt);
    }
330027
public RefreshSessionResponse refreshSession(RefreshSessionRequest request) {
        checkNotNull(request, "The parameter request should NOT be null.");
        checkStringNotEmpty(request.getSessionId(), "The parameter sessionId should NOT be null or empty string.");
        InternalRequest internalRequest = createRequest(HttpMethodName.PUT, request, LIVE_SESSION,
                request.getSessionId());
        internalRequest.addParameter(REFRESH, null);
        return invokeHttpClient(internalRequest, RefreshSessionResponse.class);
    }
1119462
public EmbeddedGobblin setShutdownTimeout(String timeout) {
    return setShutdownTimeout(Period.parse(timeout).getSeconds(), TimeUnit.SECONDS);
  }
1264509
public ServerBuilder idleTimeout(Duration idleTimeout) {
        requireNonNull(idleTimeout, "idleTimeout");
        idleTimeoutMillis = ServerConfig.validateIdleTimeoutMillis(idleTimeout.toMillis());
        return this;
    }
388479
public synchronized JsMessage get(short sessionId)
      throws SIResourceException, SIConnectionDroppedException, SIConnectionLostException
   {
      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "get", sessionId);

      JsMessage retValue = null;

      QueueData rhData = removeLastIfAvailable(sessionId);
      while (rhData != null) 
      {
                 
         retValue = (JsMessage) rhData.getMessage();

         // Now we need to decide whether the message has expired or not. We do this by comparing
         // the message arrival time + message TTL and the current time. If we find the message
         // has expired we need to unlock it at the server, and discard it from our queue without
         // giving it to the caller.
         // NOTE: We want to avoid the situation where we unlock an expired message but it gets to
         // the server at the exact time it did expire. As such, we give each message an extra
         // 500ms to live. This way we absolutely guarentee that when we unlock on the server the
         // message will not be redelivered.
         boolean messageHasExpired = false;
         long msgTTL = retValue.getRemainingTimeToLive();

         if (msgTTL != -1)
         {
            long currentTime = approxTimeThread.getApproxTime();
            long msgArrivalTime = rhData.getArrivalTime();

            // Compensate the TTL by 500 ms
            msgTTL += 500;

            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(tc, "Arrived: " + new Date(msgArrivalTime) +
                                                     ", Now: " + new Date(currentTime) +
                                                     ", Expires: " + new Date(msgArrivalTime + msgTTL));

            if (currentTime > (msgArrivalTime + msgTTL))
            {
               if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "Message has expired: " +
                                                    retValue.getMessageHandle());
               messageHasExpired = true;
            }
         }

         // Now we need to update our counters and decide whether we request more messages.
         // We do this whether the message will expire or not - as either way the message is
         // coming of the queue.
         if (trackBytes)
         {
            bytesGivenToUserSinceLastRequestForMsgs += rhData.getMessageLength();
         }

         totalBytesGiven += bytesGivenToUserSinceLastRequestForMsgs;
         currentBytesOnQueue -= rhData.getMessageLength();

         if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
         {
            SibTr.debug(this, tc, "Current bytes on the queue", ""+currentBytesOnQueue);
            SibTr.debug(this, tc, "Bytes given since last request", ""+bytesGivenToUserSinceLastRequestForMsgs);
         }

         // Now check and see if we need more messags. If we have gone below the lower watermark
         // of bytes cached by us (rather - if we have given the user more than HIGH - LOW messages),
         // and if the server has stopped sending us messages (coz we have received more than the
         // high watermark) then request some more messages.
         if (trackBytes &&
             (bytesGivenToUserSinceLastRequestForMsgs >= (HIGH_QUEUE_BYTES - LOW_QUEUE_BYTES)))
         {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "Need more messages: " +
                                                 bytesGivenToUserSinceLastRequestForMsgs + " >= " + (HIGH_QUEUE_BYTES - LOW_QUEUE_BYTES));

            // Are there new values waiting to be set? If so, set them now
            if (NEW_HIGH_QUEUE_BYTES != 0)
            {
               HIGH_QUEUE_BYTES = NEW_HIGH_QUEUE_BYTES;
               LOW_QUEUE_BYTES = NEW_LOW_QUEUE_BYTES;
            }

            convHelper.requestMoreMessages(bytesReceivedSinceLastRequestForMsgs, HIGH_QUEUE_BYTES);   // d172528
            bytesGivenToUserSinceLastRequestForMsgs = 0;
            bytesReceivedSinceLastRequestForMsgs = 0;
            totalRequests++;

            lastRequestForMessagesTime = System.currentTimeMillis();


            synchronized(queue)
            {
         	   if (queue.isEmpty()) goneEmptyCount++;
            }

            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "Queue is now: ", this);
         }

         // If the message has not expired, break out of this loop and deliver the message
         if (!messageHasExpired)
         {
            break;
         }

         // Otherwise, unlock him if he was a recoverable message
         if (CommsUtils.isRecoverable(retValue, unrecoverableReliability))
         {
            try
            {
               convHelper.unlockSet(new SIMessageHandle[] {retValue.getMessageHandle()});
            }
            catch (SIException e)
            {
               FFDCFilter.processException(e, CLASS_NAME + ".get",
                                           CommsConstants.RHPQ_GET_01, this);

               if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(tc, "Unable to unlock expired message", e);

               // Not a lot else we can do that
            }
         }

         // And null out the message so we don't accidentally return him
         retValue = null;
         rhData = removeLastIfAvailable(sessionId);
      }

      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "get", retValue);
      return retValue;
   }
644600
public SleepBuilder<T> withTimeout(long timeout, TimeUnit timeUnit) {
        this.timeout = timeUnit.toMillis(timeout);
        return this;
    }
495694
public boolean connect(long timeout) {
    if (this.wmi.connect(timeout)) {
      this.wmi.setStayConnected(true);
//      this.isReady = true;
      return true;
    }
    return false;
  }
1360463
public JmxServerBuilder timeout(long timeout) {
        endpoint.setDefaultTimeout(timeout);
        endpoint.getEndpointConfiguration().setTimeout(timeout);
        return this;
    }
699900
public void processTimeout(final TimeoutEvent timeoutEvent) {
		Transaction eventTransaction = null;
		if(timeoutEvent.isServerTransaction()) {
			eventTransaction = timeoutEvent.getServerTransaction();
		} else {
			eventTransaction = timeoutEvent.getClientTransaction();
		}
		final Transaction transaction = eventTransaction;
		if(logger.isDebugEnabled()) {
			logger.debug("transaction " + transaction + " timed out => " + transaction.getRequest().toString());
		}

		final TransactionApplicationData tad = (TransactionApplicationData) transaction.getApplicationData();
		if(tad != null && tad.getSipServletMessage() != null) {
			// https://github.com/RestComm/sip-servlets/issues/107 guard against NPEon concurrent cleanup
			final SipServletMessageImpl sipServletMessage = tad.getSipServletMessage();
			final MobicentsSipSessionKey sipSessionKey = sipServletMessage.getSipSessionKey();
			final MobicentsSipSession sipSession = sipServletMessage.getSipSession();
			getAsynchronousExecutor().execute(new Runnable() {
				public void run() {
					try {
						if(logger.isDebugEnabled()) {
							logger.debug("transaction " + transaction + " timed out => " + transaction.getRequest().toString());
						}
						boolean appNotifiedOfPrackNotReceived = false;
						// session can be null if a message was sent outside of the container by the container itself during Initial request dispatching
						// but the external host doesn't send any response so we call out to the application only if the session is not null
						if(logger.isDebugEnabled()) {
                            logger.debug("time out happened on sipSession " + sipSession);
                        }
						if(sipSession != null) {
							SipContext sipContext = findSipApplication(sipSessionKey.getApplicationName());
							//the context can be null if the server is being shutdown
							if(sipContext != null) {
								MobicentsSipApplicationSession sipApplicationSession = sipSession.getSipApplicationSession();
								try {
									sipContext.enterSipApp(sipApplicationSession, sipSession, false, true);
									MobicentsB2BUAHelper b2buaHelperImpl = sipSession.getB2buaHelper();

									if(b2buaHelperImpl != null && tad.getSipServletMessage() instanceof SipServletRequestImpl) {
										b2buaHelperImpl.unlinkRequestInternal((SipServletRequestImpl)tad.getSipServletMessage(), false);
									}
									// naoki : Fix for Issue 1618 http://code.google.com/p/mobicents/issues/detail?id=1618 on Timeout don't do the 408 processing for Server Transactions
									if(logger.isDebugEnabled()) {
			                            logger.debug("time out happened on server tx ? " + timeoutEvent.isServerTransaction() + " and message " + sipServletMessage);
			                        }
									if(sipServletMessage instanceof SipServletRequestImpl && !timeoutEvent.isServerTransaction()) {
										try {
											ProxyBranchImpl proxyBranchImpl = tad.getProxyBranch();
											if(proxyBranchImpl != null) {
												ProxyImpl proxy = (ProxyImpl) proxyBranchImpl.getProxy();
												if(proxy.getFinalBranchForSubsequentRequests() != null) {
													tad.cleanUp();
													transaction.setApplicationData(null);
													return;
												}
											}
											SipServletRequestImpl sipServletRequestImpl = (SipServletRequestImpl) sipServletMessage;
											if(sipServletRequestImpl.visitNextHop()) {
												return;
											}
											sipServletMessage.setTransaction(transaction);
											SipServletResponseImpl response = (SipServletResponseImpl) sipServletRequestImpl.createResponse(408, null, false, true);
											// Fix for Issue 1734
											sipServletRequestImpl.setResponse(response);
											MessageDispatcher.callServlet(response);
											if(tad.getProxyBranch() != null) {
												tad.getProxyBranch().setResponse(response);
												tad.getProxyBranch().onResponse(response, response.getStatus());
											}
											sipSession.updateStateOnResponse(response, true);
										} catch (Throwable t) {
											logger.error("Failed to deliver 408 response on transaction timeout" + transaction, t);
										}
									}
									// Guard only invite tx should check that, otherwise proxy might become null http://code.google.com/p/mobicents/issues/detail?id=2350
									// Should check only Server Tx for ack or prack not received http://code.google.com/p/mobicents/issues/detail?id=2525
									if(Request.INVITE.equals(sipServletMessage.getMethod()) && timeoutEvent.isServerTransaction()) {
										checkForAckNotReceived(sipServletMessage);
										appNotifiedOfPrackNotReceived = checkForPrackNotReceived(sipServletMessage);
									}
								} finally {
									sipSession.removeOngoingTransaction(transaction);
									sipSession.setRequestsPending(0);
									sipContext.exitSipApp(sipApplicationSession, sipSession);
								}
								// don't invalidate here because if the application sends a final response on the noPrack received
								// the ACK to this final response won't be able to get routed since the sip session would have been invalidated
								if(!appNotifiedOfPrackNotReceived) {
									tryToInvalidateSession(sipSessionKey, false);
								}
							}
						}
						// don't clean up for the same reason we don't invalidate the sip session right above
						tad.cleanUp();
						transaction.setApplicationData(null);
					} catch (Exception e) {
						logger.error("Problem handling timeout", e);
					}
				}
			});
		}
	}
1362585
function(callback, timeInMs) {
    var timeout = makeTimeout(function() {
      setTriggerTime(timeout, timeout.timeInMs);
      s_timeoutsToInsert.push(timeout);
      callback();
    });
    timeout.timeInMs = timeInMs;
    s_timeoutsToInsert.push(timeout);
    return timeout.id;
  }
1016956
public AndroidInstallApplicationOptions withTimeout(Duration timeout) {
        checkArgument(!checkNotNull(timeout).isNegative(), "The timeout value cannot be negative");
        this.timeout = timeout;
        return this;
    }
241935
public SdkClientBuilder connectionCheckoutTimeout(long timeout, TimeUnit unit)
    {
        this.connectionCheckoutTimeoutMs = (int) TimeUnit.MILLISECONDS.convert(timeout, unit);
        return this;
    }
1008393
public GetSessionTokenResponse getSessionToken(GetSessionTokenRequest request) {
        checkNotNull(request, "The parameter request should NOT be null.");
        checkIsTrue(request.getDurationSeconds() > 0, "the durationSeconds parameter should be greater than zero");

        InternalRequest internalRequest = new InternalRequest(HttpMethodName.POST,
                HttpUtils.appendUri(this.getEndpoint(), URL_PREFIX, GET_SESSION_TOKEN_PATH));
        if (request.getDurationSeconds() != null) {
            internalRequest.addParameter("durationSeconds", String.valueOf(request.getDurationSeconds()));
        }
        internalRequest.setCredentials(request.getRequestCredentials());
        internalRequest.addHeader(Headers.CONTENT_LENGTH,
                String.valueOf(request.getAcl() == null ? 0 : request.getAcl().length()));
        internalRequest.addHeader(Headers.CONTENT_TYPE, "application/json");
        if (request.getAcl() != null) {
            internalRequest.setContent(RestartableInputStream.wrap(request.getAcl().getBytes()));
        }
        return this.invokeHttpClient(internalRequest, GetSessionTokenResponse.class);
    }
549784
@Deprecated
  public AtomixClusterBuilder withReachabilityTimeout(Duration timeout) {
    GroupMembershipProtocolConfig protocolConfig = config.getProtocolConfig();
    if (protocolConfig instanceof HeartbeatMembershipProtocolConfig) {
      ((HeartbeatMembershipProtocolConfig) protocolConfig).setFailureTimeout(timeout);
    }
    return this;
  }