Package org.red5.server.api

Examples of org.red5.server.api.IScope


   * @return <code>true</code> if the call was performed, otherwise
   *         <code>false</code>
   */
  private boolean invokeCall(RTMPConnection conn, IServiceCall call,
      Object service) {
    final IScope scope = conn.getScope();
    final IContext context = scope.getContext();
    log.debug("Scope: {}", scope);
    log.debug("Service: {}", service);
    log.debug("Context: {}", context);
    return context.getServiceInvoker().invoke(call, service);
  }
View Full Code Here


              }
              log.info("No application scope found for {} on host {}. Misspelled or missing application folder?", path, host);
              disconnectOnReturn = true;
            } else {
              final IContext context = global.getContext();
              IScope scope = null;
              try {
                scope = context.resolveScope(global, path);
              } catch (ScopeNotFoundException err) {
                call.setStatus(Call.STATUS_SERVICE_NOT_FOUND);
                if (call instanceof IPendingServiceCall) {
                  StatusObject status = getStatus(NC_CONNECT_REJECTED);
                  status.setDescription("No scope \"" + path
                      + "\" on this server.");
                  ((IPendingServiceCall) call)
                      .setResult(status);
                }
                log.info("Scope {} not found on {}", path, host);
                disconnectOnReturn = true;
              } catch (ScopeShuttingDownException err) {
                call.setStatus(Call.STATUS_APP_SHUTTING_DOWN);
                if (call instanceof IPendingServiceCall) {
                  StatusObject status = getStatus(NC_CONNECT_APPSHUTDOWN);
                  status.setDescription("Application at \""
                      + path
                      + "\" is currently shutting down.");
                  ((IPendingServiceCall) call)
                      .setResult(status);
                }
                log.info("Application at {} currently shutting down on {}", path, host);
                disconnectOnReturn = true;
              }
              if (scope != null) {
                log.info("Connecting to: {}", scope);
                // Setup application's classloader to be used for deserializing
                ClassLoader loader = scope.getClassLoader();
                if (loader == null) {
                  // Fallback, should never happen
                  loader = getClass().getClassLoader();
                }
                Thread.currentThread().setContextClassLoader(loader);
View Full Code Here

  protected void onSharedObject(RTMPConnection conn, Channel channel,
      Header source, SharedObjectMessage object) {
    final ISharedObject so;
    final String name = object.getName();
    final boolean persistent = object.isPersistent();
    final IScope scope = conn.getScope();
    if (scope == null) {
      // The scope already has been deleted.
      sendSOCreationFailed(conn, name, persistent);
      return;
    }
View Full Code Here

     * @param path        Scope path
     * @return            Scope object
     */
  public IScope resolveScope(IScope root, String path) {
        // Start from root scope
        IScope scope = root;
        // If there's no path return root scope (e.i. root path scope)
        if (path == null) {
      return scope;
    }
        // Split path to parts
        final String[] parts = path.split("/");
        // Iterate thru them, skip empty parts
    for (String room : parts) {
      if (room.equals("")) {
        // Skip empty path elements
        continue;
      }

      if (scope.hasChildScope(room)) {
        scope = scope.getScope(room);
      } else if (!scope.equals(root)) {
        // Synchronizing to make sure a subscope with the same name
        // is not created multiple times.
        synchronized (scope) {
          // Check again as a different thread might have created the
          // child while we waited for the synchronized block.
          if (scope.hasChildScope(room)) {
            scope = scope.getScope(room);
          } else if (scope.createChildScope(room)) {
            scope = scope.getScope(room);
          } else {
            throw new ScopeNotFoundException(scope, room);
          }
        }
      } else {
View Full Code Here

        // Get session id
        String id = conn.getSessionId();
        //log.debug("Session id: {}", id);

    // Use client registry from scope the client connected to.
    IScope connectionScope = Red5.getConnectionLocal().getScope();
    log.debug("Connection scope: {}", (connectionScope == null ? "is null" : "not null"));

        // when the scope is null bad things seem to happen, if a null scope is OK then
        // this block will need to be removed - Paul
        if (connectionScope == null) {
            return false;
        }

        // Get client registry for connection scope
        IClientRegistry clientRegistry = connectionScope.getContext().getClientRegistry();
    log.debug("Client registry: {}", (clientRegistry == null ? "is null" : "not null"));

        // Get client from registry by id or create a new one
        IClient client = clientRegistry.hasClient(id) ? clientRegistry.lookupClient(id) : clientRegistry.newClient(params);
View Full Code Here

   * Getter for property 'listOfAvailableFLVs'.
   *
   * @return Value for property 'listOfAvailableFLVs'.
   */
  public Map<String, Map<String, Object>> getListOfAvailableFLVs() {
    IScope scope = Red5.getConnectionLocal().getScope();
    Map<String, Map<String, Object>> filesMap = new HashMap<String, Map<String, Object>>();
    try {
      log.debug("getting the FLV files");
      Resource[] flvs = scope.getResources("streams/*.flv");
      addToMap(filesMap, flvs);
    } catch (IOException e) {
      log.error("{}", e);
    }
    return filesMap;
View Full Code Here

   * @return    The scope for the given path
   *
   * @throws ScopeNotFoundException  Thrown when scope with given path can't be resolved
   */
  private IScope getScope(String path) throws ScopeNotFoundException {
    IScope scope;
    if (path != null && !path.equals("")) {
      scope = ScopeUtils.resolveScope(globalScope, path);
    } else {
      scope = globalScope;
    }
View Full Code Here

   *
   * @param path  Path of scope to return subscopes of
   * @return    List of subscope names
   */
  public String[] getScopes(String path) {
    IScope scope = getScope(path);
    List<String> result = new ArrayList<String>();
    Iterator<String> iter = scope.getScopeNames();
    while (iter.hasNext()) {
      String name = iter.next();
      result.add(name.substring(name.indexOf(IScope.SEPARATOR) + 1));
    }

View Full Code Here

   *
   * @param path  Path of scope to return attributes of
   * @return    The scope's attributes
   */
  public Map<String, Object> getScopeAttributes(String path) {
    IScope scope = getScope(path);
    Map<String, Object> result = new Hashtable<String, Object>();
    for (String name : scope.getAttributeNames()) {
      Object value = scope.getAttribute(name);
      try {
        result.put(name, getXMLRPCValue(value));
      } catch (RuntimeException err) {
        // Could not convert attribute for XML-RPC serialization.
      }
View Full Code Here

   *
   * @param path  Path of scope to return shared objects for
   * @return    A mapping containing the shared object name -> (persistent, data)
   */
  public Map<String, Object> getSharedObjects(String path) {
    IScope scope = getScope(path);
    ISharedObjectService service = (ISharedObjectService) ScopeUtils
        .getScopeService(scope,
            ISharedObjectService.class, false);
    if (service == null) {
      return new Hashtable<String, Object>();
View Full Code Here

TOP

Related Classes of org.red5.server.api.IScope

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.