/** * Resumes a scheduled job * * @param name * Scheduled job name */ public void resumeScheduledJob(String name) { ISchedulingService service = (ISchedulingService) ScopeUtils.getScopeService(scope, ISchedulingService.class, QuartzSchedulingService.class, false); service.resumeScheduledJob(name); }
/** * Disconnects client from scope. Can be applied to both application scope and scopes of lower level. This method calls * {@link ApplicationAdapter#appLeave(IClient, IScope)} or {@link ApplicationAdapter#roomLeave(IClient, IScope)} handlers respectively. * * @param client * Client object * @param scope * Scope object */ @Override public void leave(IClient client, IScope scope) { log.debug("leave: {} << {}", client, scope); if (ScopeUtils.isApp(scope)) { appLeave(client, scope); } else if (ScopeUtils.isRoom(scope)) { roomLeave(client, scope); } super.leave(client, scope); }
private IScope getScope(String path) throws ScopeNotFoundException { IScope scope; if (path != null && !path.equals("")) { scope = ScopeUtils.resolveScope(globalScope, path); } else { scope = globalScope; } if (scope == null) { throw new ScopeNotFoundException(globalScope, path); } return scope; }
public static File getRecordFile(IScope scope, String name, String extension) { // get stream filename generator IStreamFilenameGenerator generator = (IStreamFilenameGenerator) ScopeUtils.getScopeService(scope, IStreamFilenameGenerator.class, DefaultStreamFilenameGenerator.class); // generate filename String fileName = generator.generateFilename(scope, name, extension, GenerationType.RECORD); File file = null; if (generator.resolvesToAbsolutePath()) { file = new File(fileName); } else { Resource resource = scope.getContext().getResource(fileName); if (resource.exists()) { try { file = resource.getFile(); logger.debug("File exists: {} writable: {}", file.exists(), file.canWrite()); } catch (IOException ioe) { logger.error("File error: {}", ioe); } } else { String appScopeName = ScopeUtils.findApplication(scope).getName(); file = new File( String.format("%s/webapps/%s/%s", System.getProperty("red5.root"), appScopeName, fileName)); } } return file; }
/** * Creates RAM persistence object from scope * * @param scope * Scope */ public RamPersistence(IScope scope) { this((ResourcePatternResolver) ScopeUtils.findApplication(scope)); }
/** * Remove event listener from list of listeners * * @param listener * Listener to remove * @return true if listener is removed and false otherwise */ public boolean removeEventListener(IEventListener listener) { log.debug("removeEventListener - scope: {} {}", getName(), listener); if (log.isTraceEnabled()) { log.trace("Listeners - check #1: {}", listeners); } boolean removed = listeners.remove(listener); if (!keepOnDisconnect) { if (removed && keepAliveJobName == null) { if (ScopeUtils.isRoom(this) && listeners.isEmpty()) { // create job to kill the scope off if no listeners join within the delay ISchedulingService schedulingService = (ISchedulingService) parent.getContext().getBean(ISchedulingService.BEAN_NAME); // by default keep a scope around for a fraction of a second keepAliveJobName = schedulingService.addScheduledOnceJob((keepDelay > 0 ? keepDelay * 1000 : 100), new KeepAliveJob(this)); } } } else { log.trace("Scope: {} is exempt from removal when empty", getName()); } if (log.isTraceEnabled()) { log.trace("Listeners - check #2: {}", listeners); } return removed; }
IScope current = from; if (path.startsWith(SLASH)) { current = ScopeUtils.findRoot(current); path = path.substring(1, path.length());
/** * Returns the application scope for a given path. * * @param path * @return IScope */ public IScope getApplicationScope(String path) { // set a reference to the application scope so we can create room scopes String applicationScopeName = path.split("\\/")[1]; log.debug("Looking for application scope: {}", applicationScopeName); return managerMap.keySet().stream().filter(scope -> (ScopeUtils.isApp(scope) && scope.getName().equals(applicationScopeName))).findFirst().get(); }
IStreamFilenameGenerator generator = (IStreamFilenameGenerator) ScopeUtils.getScopeService(scope, IStreamFilenameGenerator.class, DefaultStreamFilenameGenerator.class); String appScopeName = ScopeUtils.findApplication(scope).getName(); file = new File(String.format("%s/webapps/%s/%s", System.getProperty("red5.root"), appScopeName, fileName));
/** * Creates RAM persistence object from scope * * @param scope * Scope */ public RamPersistence(IScope scope) { this((ResourcePatternResolver) ScopeUtils.findApplication(scope)); }
/** * Remove event listener from list of listeners * * @param listener * Listener to remove * @return true if listener is removed and false otherwise */ public boolean removeEventListener(IEventListener listener) { log.debug("removeEventListener - scope: {} {}", getName(), listener); if (log.isTraceEnabled()) { log.trace("Listeners - check #1: {}", listeners); } boolean removed = listeners.remove(listener); if (!keepOnDisconnect) { if (removed && keepAliveJobName == null) { if (ScopeUtils.isRoom(this) && listeners.isEmpty()) { // create job to kill the scope off if no listeners join within the delay ISchedulingService schedulingService = (ISchedulingService) parent.getContext().getBean(ISchedulingService.BEAN_NAME); // by default keep a scope around for a fraction of a second keepAliveJobName = schedulingService.addScheduledOnceJob((keepDelay > 0 ? keepDelay * 1000 : 100), new KeepAliveJob(this)); } } } else { log.trace("Scope: {} is exempt from removal when empty", getName()); } if (log.isTraceEnabled()) { log.trace("Listeners - check #2: {}", listeners); } return removed; }
IScope current = from; if (path.startsWith(SLASH)) { current = ScopeUtils.findRoot(current); path = path.substring(1, path.length());
/** * Returns available SharedObject names as List * * @param scope * Scope that SO belong to */ public Set<String> getSharedObjectNames(IScope scope) { ISharedObjectService service = (ISharedObjectService) ScopeUtils.getScopeService(scope, ISharedObjectService.class, SharedObjectService.class, false); return service.getSharedObjectNames(scope); }
/** * Adds client to scope. Scope can be both application or room. Can be applied to both application scope and scopes of lower level. This * method calls {@link ApplicationAdapter#appJoin(IClient, IScope)} or {@link ApplicationAdapter#roomJoin(IClient, IScope)} handlers * respectively. * * @param client * Client object * @param scope * Scope object */ @Override public boolean join(IClient client, IScope scope) { if (!super.join(client, scope)) { return false; } if (ScopeUtils.isApp(scope)) { return appJoin(client, scope); } else { return ScopeUtils.isRoom(scope) && roomJoin(client, scope); } }
IStreamFilenameGenerator generator = (IStreamFilenameGenerator) ScopeUtils.getScopeService(scope, IStreamFilenameGenerator.class, DefaultStreamFilenameGenerator.class); String appScopeName = ScopeUtils.findApplication(scope).getName(); file = new File(String.format("%s/webapps/%s/%s", System.getProperty("red5.root"), appScopeName, fileName));
public static File getPreviewFile(IScope scope, String name, String extension) { String appScopeName = ScopeUtils.findApplication(scope).getName(); File file = new File(String.format("%s/webapps/%s/%s", System.getProperty("red5.root"), appScopeName, "previews/" + name + extension)); return file; }
for (int i = 2; i < paths.length; i++) { roomScope = ScopeUtils.resolveScope(parentScope, paths[i]); roomScope = ScopeUtils.resolveScope(parentScope, paths[i]);
/** * Checks whether there's a SO with given scope and name * * @param scope * Scope that SO belong to * @param name * Name of SharedObject */ public boolean hasSharedObject(IScope scope, String name) { ISharedObjectService service = (ISharedObjectService) ScopeUtils.getScopeService(scope, ISharedObjectService.class, SharedObjectService.class, false); return service.hasSharedObject(scope, name); }
/** * Returns disconnection result for given scope and parameters. Whether the scope is room or app level scope, this method distinguishes * it and acts accordingly. * * @param conn * Connection object * @param scope * Scope */ @Override public void disconnect(IConnection conn, IScope scope) { log.debug("disconnect: {} < {}", conn, scope); if (log.isInfoEnabled() && ScopeUtils.isApp(scope)) { // log w3c connect event IClient client = conn.getClient(); if (client == null) { // log w3c connect event log.info("W3C x-category:session x-event:disconnect c-ip:{}", conn.getRemoteAddress()); } else { // log w3c connect event log.info("W3C x-category:session x-event:disconnect c-ip:{} c-client-id:{}", conn.getRemoteAddress(), client.getId()); } } if (ScopeUtils.isApp(scope)) { appDisconnect(conn); } else if (ScopeUtils.isRoom(scope)) { roomDisconnect(conn); } super.disconnect(conn, scope); }
public static File getUserRecordFile(IScope scope, String userVoDFolder, String name) { String appScopeName = ScopeUtils.findApplication(scope).getName(); File file = new File(String.format("%s/webapps/%s/%s", System.getProperty("red5.root"), appScopeName, "streams/" + userVoDFolder + "/" + name )); return file; }