• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java IScope类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.red5.server.api.scope.IScope的典型用法代码示例。如果您正苦于以下问题:Java IScope类的具体用法?Java IScope怎么用?Java IScope使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IScope类属于org.red5.server.api.scope包,在下文中一共展示了IScope类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: isPublishAllowed

import org.red5.server.api.scope.IScope; //导入依赖的package包/类
@Override
public boolean isPublishAllowed(IScope scope, String name, String mode) {
	IConnection conn = Red5.getConnectionLocal();
	Object userAuthorized = conn.getAttribute("userAuthorized");
	Object publishAllowed = conn.getAttribute("publishAllowed");
	Object userName = conn.getAttribute("userName");

	if (userAuthorized == null || (boolean)userAuthorized != true) {
		log.info("user is not authorized at all, not allowing to publish, closing connection");
		return false;
	}
	
	if (publishAllowed == null || (boolean)publishAllowed != true)
		return false;

	// Now we know what stream the client wants to access, so storing it as a connection attribute.
	conn.setAttribute("streamName", name);

	if (userName != null)
		log.info("user " + (String)userName + " authorized to publish stream " + name + ": " + (publishAllowed.equals(true) ? "yes" : "no"));

	conn.setAttribute("userIsPublishing", true);
	
	return publishAllowed.equals(true);
}
 
开发者ID:nonoo,项目名称:kdrlivestream,代码行数:26,代码来源:AuthPubSec.java


示例2: kickUsersByRoomId

import org.red5.server.api.scope.IScope; //导入依赖的package包/类
/**
 * @param roomId - id of the room user should be kicked from
 * @return <code>true</code> if there were no errors
 */
@Override
public boolean kickUsersByRoomId(Long roomId) {
	try {
		sessionDao.clearSessionByRoomId(roomId);

		for (StreamClient rcl : sessionManager.listByRoom(roomId)) {
			if (rcl == null) {
				return true;
			}
			String scopeName = rcl.getRoomId() == null ? HIBERNATE : rcl.getRoomId().toString();
			IScope currentScope = scopeAdapter.getChildScope(scopeName);
			scopeAdapter.roomLeaveByScope(rcl, currentScope);

			Map<Integer, String> messageObj = new HashMap<>();
			messageObj.put(0, "kick");
			scopeAdapter.sendMessageById(messageObj, rcl.getUid(), currentScope);
		}
		return true;
	} catch (Exception err) {
		log.error("[kickUsersByRoomId]", err);
	}
	return false;
}
 
开发者ID:apache,项目名称:openmeetings,代码行数:28,代码来源:UserManager.java


示例3: BaseStreamWriter

import org.red5.server.api.scope.IScope; //导入依赖的package包/类
public BaseStreamWriter(String streamName, IScope scope, Long metaDataId, boolean isScreenData) {
	startedSessionTimeDate = new Date();
	this.isScreenData = isScreenData;
	this.streamName = streamName;
	this.metaDataId = metaDataId;
	this.metaDataDao = getApp().getOmBean(RecordingMetaDataDao.class);
	this.scope = scope;
	try {
		init();
	} catch (IOException ex) {
		log.error("##REC:: [BaseStreamWriter] Could not init Thread", ex);
	}
	RecordingMetaData metaData = metaDataDao.get(metaDataId);
	metaData.setStreamStatus(Status.STARTED);
	metaDataDao.update(metaData);

	open();
}
 
开发者ID:apache,项目名称:openmeetings,代码行数:19,代码来源:BaseStreamWriter.java


示例4: roomLeave

import org.red5.server.api.scope.IScope; //导入依赖的package包/类
/**
 * Logic must be before roomDisconnect cause otherwise you cannot throw a
 * message to each one
 *
 */
@Override
public void roomLeave(IClient client, IScope room) {
	try {
		_log.debug("[roomLeave] {} {} {} {}", client.getId(), room.getClients().size(), room.getContextPath(), room.getName());

		StreamClient rcl = sessionManager.get(IClientUtil.getId(client));

		// The Room Client can be null if the Client left the room by using
		// logicalRoomLeave
		if (rcl != null) {
			_log.debug("currentClient IS NOT NULL");
			roomLeaveByScope(rcl, room);
		}
	} catch (Exception err) {
		_log.error("[roomLeave]", err);
	}
}
 
开发者ID:apache,项目名称:openmeetings,代码行数:23,代码来源:ScopeApplicationAdapter.java


示例5: dropSharing

import org.red5.server.api.scope.IScope; //导入依赖的package包/类
public void dropSharing(org.apache.openmeetings.db.entity.basic.IClient c, Long roomId) {
	IScope scope = null;
	try {
		scope = getChildScope(String.valueOf(roomId));
	} catch (Exception e) {
		//no-op, scope doesn't exist while testing
	}
	//Elvis has left the building
	new MessageSender(scope, "stopStream", new Object(), this) {
		@Override
		public boolean filter(IConnection conn) {
			StreamClient rcl = sessionManager.get(IClientUtil.getId(conn.getClient()));
			return rcl == null
					|| Client.Type.sharing != rcl.getType()
					|| !c.getSid().equals(rcl.getSid());
		}
	}.start();
}
 
开发者ID:apache,项目名称:openmeetings,代码行数:19,代码来源:ScopeApplicationAdapter.java


示例6: getManager

import org.red5.server.api.scope.IScope; //导入依赖的package包/类
/**
 * Returns a WebSocketScopeManager for a given path.
 * 
 * @param path
 * @return WebSocketScopeManager if registered for the given path and null otherwise
 */
public WebSocketScopeManager getManager(String path) {
    log.debug("getManager: {}", path);
    // determine what the app scope name is
    String[] parts = path.split("\\/");
    if (log.isTraceEnabled()) {
        log.trace("Path parts: {}", Arrays.toString(parts));
    }
    if (parts.length > 1) {
        // skip default in a path if it exists in slot #1
        String name = !"default".equals(parts[1]) ? parts[1] : ((parts.length >= 3) ? parts[2] : parts[1]);
        if (log.isDebugEnabled()) {
            log.debug("Managers: {}", managerMap.entrySet());
        }
        for (Entry<IScope, WebSocketScopeManager> entry : managerMap.entrySet()) {
            IScope appScope = entry.getKey();
            if (appScope.getName().equals(name)) {
                log.debug("Application scope name matches path: {}", name);
                return entry.getValue();
            } else if (log.isTraceEnabled()) {
                log.trace("Application scope name: {} didnt match path: {}", appScope.getName(), name);
            }
        }
    }
    return null;
}
 
开发者ID:Red5,项目名称:red5-websocket,代码行数:32,代码来源:WebSocketPlugin.java


示例7: makeScope

import org.red5.server.api.scope.IScope; //导入依赖的package包/类
/**
 * Create a web socket scope from a server IScope. Use the IWebSocketScopeListener interface to configure the created scope.
 * 
 * @param scope
 */
public void makeScope(IScope scope) {
    log.debug("makeScope: {}", scope);
    String path = scope.getContextPath();
    WebSocketScope wsScope = null;
    if (!scopes.containsKey(path)) {
        // add the name to the collection (no '/' prefix)
        activeRooms.add(scope.getName());
        // new websocket scope for the server scope
        wsScope = new WebSocketScope();
        wsScope.setPath(path);
        wsScope.setScope(scope);
        notifyListeners(WebSocketEvent.SCOPE_CREATED, wsScope);
        addWebSocketScope(wsScope);
        log.debug("Use the IWebSocketScopeListener interface to be notified of new scopes");
    } else {
        log.debug("Scope already exists: {}", path);
    }
}
 
开发者ID:Red5,项目名称:red5-websocket,代码行数:24,代码来源:WebSocketScopeManager.java


示例8: connect

import org.red5.server.api.scope.IScope; //导入依赖的package包/类
@Override
public boolean connect(IScope newScope, Object[] params) {
    if (log.isDebugEnabled()) {
        log.debug("Connect scope: {}", newScope);
    }
    try {
        boolean success = super.connect(newScope, params);
        if (success) {
            stopWaitForHandshake();
            // once the handshake has completed, start needed jobs start the ping / pong keep-alive
            startRoundTripMeasurement();
        } else if (log.isDebugEnabled()) {
            log.debug("Connect failed");
        }
        return success;
    } catch (ClientRejectedException e) {
        String reason = (String) e.getReason();
        log.info("Client rejected, reason: " + ((reason != null) ? reason : "None"));
        stopWaitForHandshake();
        throw e;
    }
}
 
开发者ID:Red5,项目名称:red5-server-common,代码行数:23,代码来源:RTMPConnection.java


示例9: isScopeAllowed

import org.red5.server.api.scope.IScope; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
public boolean isScopeAllowed(IScope scope) {
    if (log.isDebugEnabled()) {
        log.debug("isScopeAllowed: {}", scope);
    }
    if (securityHandlers != null) {
        // loop through the handlers
        for (IScopeSecurityHandler handler : securityHandlers) {
            // if allowed continue to the next handler
            if (handler.allowed(scope)) {
                continue;
            } else {
                // if any handlers deny we return false
                return false;
            }
        }
    }
    // default is to allow
    return true;
}
 
开发者ID:Red5,项目名称:red5-server-common,代码行数:23,代码来源:BasicScope.java


示例10: getRecordFile

import org.red5.server.api.scope.IScope; //导入依赖的package包/类
/**
 * Get the file we'd be recording to based on scope and given name.
 *
 * @param scope
 *            scope
 * @param name
 *            name
 * @return file
 */
public static File getRecordFile(IScope scope, String name) {
    // get stream filename generator
    IStreamFilenameGenerator generator = (IStreamFilenameGenerator) ScopeUtils.getScopeService(scope, IStreamFilenameGenerator.class, DefaultStreamFilenameGenerator.class);
    // generate filename
    String fileName = generator.generateFilename(scope, name, ".flv", 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();
                log.debug("File exists: {} writable: {}", file.exists(), file.canWrite());
            } catch (IOException ioe) {
                log.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;
}
 
开发者ID:Red5,项目名称:red5-server-common,代码行数:34,代码来源:RecordingListener.java


示例11: getScopeService

import org.red5.server.api.scope.IScope; //导入依赖的package包/类
/**
 * Returns scope services (e.g. SharedObject, etc) for the scope. Method uses either bean name passes as a string or class object.
 *
 * @param scope
 *            The scope service belongs to
 * @param name
 *            Bean name
 * @param defaultClass
 *            Class of service
 * @return Service object
 */
protected static Object getScopeService(IScope scope, String name, Class<?> defaultClass) {
    if (scope != null) {
        final IContext context = scope.getContext();
        ApplicationContext appCtx = context.getApplicationContext();
        Object result;
        if (!appCtx.containsBean(name)) {
            if (defaultClass == null) {
                return null;
            }
            try {
                result = defaultClass.newInstance();
            } catch (Exception e) {
                log.error("{}", e);
                return null;
            }
        } else {
            result = appCtx.getBean(name);
        }
        return result;
    }
    return null;
}
 
开发者ID:Red5,项目名称:red5-server-common,代码行数:34,代码来源:ScopeUtils.java


示例12: connect

import org.red5.server.api.scope.IScope; //导入依赖的package包/类
@SuppressWarnings("cast")
@Override
public boolean connect(IScope newScope, Object[] params) {
    log.debug("Connect scope: {}", newScope);
    boolean success = super.connect(newScope, params);
    if (success) {
        final Channel two = getChannel(2);
        // tell the flash player how fast we want data and how fast we shall send it
        two.write(new ServerBW(defaultServerBandwidth));
        // second param is the limit type (0=hard,1=soft,2=dynamic)
        two.write(new ClientBW(defaultClientBandwidth, (byte) limitType));
        // if the client is null for some reason, skip the jmx registration
        if (client != null) {
            // perform bandwidth detection
            if (bandwidthDetection && !client.isBandwidthChecked()) {
                client.checkBandwidth();
            }
        } else {
            log.warn("Client was null");
        }
        registerJMX();
    } else {
        log.debug("Connect failed");
    }
    return success;
}
 
开发者ID:Red5,项目名称:red5-server-common,代码行数:27,代码来源:RTMPMinaConnection.java


示例13: setConnectionLocal

import org.red5.server.api.scope.IScope; //导入依赖的package包/类
/**
 * Setter for connection
 *
 * @param connection
 *            Thread local connection
 */
public static void setConnectionLocal(IConnection connection) {
    if (log.isDebugEnabled()) {
        log.debug("Set connection: {} with thread: {}", (connection != null ? connection.getSessionId() : null), Thread.currentThread().getName());
        try {
            StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
            StackTraceElement stackTraceElement = stackTraceElements[2];
            log.debug("Caller: {}.{} #{}", stackTraceElement.getClassName(), stackTraceElement.getMethodName(), stackTraceElement.getLineNumber());
        } catch (Exception e) {
        }
    }
    if (connection != null) {
        connThreadLocal.set(new WeakReference<IConnection>(connection));
        IScope scope = connection.getScope();
        if (scope != null) {
            Thread.currentThread().setContextClassLoader(scope.getClassLoader());
        }
    } else {
        // use null to clear the value
        connThreadLocal.remove();
    }
}
 
开发者ID:Red5,项目名称:red5-server-common,代码行数:28,代码来源:Red5.java


示例14: register

import org.red5.server.api.scope.IScope; //导入依赖的package包/类
/**
 * Associate connection with client
 * 
 * @param conn
 *            Connection object
 */
protected void register(IConnection conn) {
    if (log.isDebugEnabled()) {
        if (conn == null) {
            log.debug("Register null connection, client id: {}", id);
        } else {
            log.debug("Register connection ({}:{}) client id: {}", conn.getRemoteAddress(), conn.getRemotePort(), id);
        }
    }
    if (conn != null) {
        IScope scope = conn.getScope();
        if (scope != null) {
            log.debug("Registering for scope: {}", scope);
            connections.add(conn);
        } else {
            log.warn("Clients scope is null. Id: {}", id);
        }
    } else {
        log.warn("Clients connection is null. Id: {}", id);
    }
}
 
开发者ID:Red5,项目名称:red5-server-common,代码行数:27,代码来源:Client.java


示例15: createSharedObject

import org.red5.server.api.scope.IScope; //导入依赖的package包/类
/** {@inheritDoc} */
public boolean createSharedObject(IScope scope, String name, boolean persistent) {
    boolean added = hasSharedObject(scope, name);
    if (!added) {
        log.debug("Attempting to add shared object: {} to {}", name, scope.getName());
        added = scope.addChildScope(new SharedObjectScope(scope, name, persistent, getStore(scope, persistent)));
        if (!added) {
            added = hasSharedObject(scope, name);
            log.debug("Add failed on create, shared object already exists: {}", added);
        }
    } else {
        // the shared object already exists
        log.trace("Shared object ({}) already exists. Persistent: {}", name, persistent);
    }
    // added or already existing will be true
    return added;
}
 
开发者ID:Red5,项目名称:red5-server-common,代码行数:18,代码来源:SharedObjectService.java


示例16: SharedObjectScope

import org.red5.server.api.scope.IScope; //导入依赖的package包/类
/**
 * Creates shared object with given parent scope, name, persistence flag state and store object
 * 
 * @param parent
 *            Parent scope
 * @param name
 *            Name
 * @param persistent
 *            Persistence flag state
 * @param store
 *            Persistence store
 */
public SharedObjectScope(IScope parent, String name, boolean persistent, IPersistenceStore store) {
    super(parent, ScopeType.SHARED_OBJECT, name, persistent);
    // create shared object wrapper around the attributes
    String path = parent.getContextPath();
    if ("".equals(path) || path.charAt(0) != '/') {
        path = '/' + path;
    }
    log.trace("Path+name: {}/{}", path, name);
    // Load SO
    so = (SharedObject) store.load(ScopeType.SHARED_OBJECT + path + '/' + name);
    // Create if it doesn't exist
    if (so == null) {
        so = new SharedObject(name, path, persistent, store);
        // Save
        store.save(so);
    } else {
        // set path
        so.setPath(path);
    }
}
 
开发者ID:Red5,项目名称:red5-server-common,代码行数:33,代码来源:SharedObjectScope.java


示例17: getServiceHandler

import org.red5.server.api.scope.IScope; //导入依赖的package包/类
/**
 * Lookup a handler for the passed service name in the given scope.
 * 
 * @param scope
 *            Scope
 * @param serviceName
 *            Service name
 * @return Service handler
 */
private Object getServiceHandler(IScope scope, String serviceName) {
    // get application scope handler first
    Object service = scope.getHandler();
    if (serviceName == null || serviceName.equals("")) {
        // no service requested, return application scope handler
        log.trace("No service requested, return application scope handler: {}", service);
        return service;
    }
    // search service resolver that knows about service name
    for (IServiceResolver resolver : serviceResolvers) {
        service = resolver.resolveService(scope, serviceName);
        if (service != null) {
            return service;
        }
    }
    // requested service does not exist
    return null;
}
 
开发者ID:Red5,项目名称:red5-server-common,代码行数:28,代码来源:ServiceInvoker.java


示例18: invoke

import org.red5.server.api.scope.IScope; //导入依赖的package包/类
/** {@inheritDoc} */
public boolean invoke(IServiceCall call, IScope scope) {
    String serviceName = call.getServiceName();
    log.trace("Service name {}", serviceName);
    Object service = getServiceHandler(scope, serviceName);
    if (service == null) {
        // Exception must be thrown if service was not found
        call.setException(new ServiceNotFoundException(serviceName));
        // Set call status
        call.setStatus(Call.STATUS_SERVICE_NOT_FOUND);
        log.warn("Service not found: {}", serviceName);
        return false;
    } else {
        log.trace("Service found: {}", serviceName);
    }
    // Invoke if everything is ok
    return invoke(call, service);
}
 
开发者ID:Red5,项目名称:red5-server-common,代码行数:19,代码来源:ServiceInvoker.java


示例19: isPlaybackAllowed

import org.red5.server.api.scope.IScope; //导入依赖的package包/类
@Override
public boolean isPlaybackAllowed(IScope scope, String name, int start, int length, boolean flushPlaylist) {
	IConnection conn = Red5.getConnectionLocal();
	Object userAuthorized = conn.getAttribute("userAuthorized");
	Object userIndex = conn.getAttribute("userIndex");
	Object userName = conn.getAttribute("userName");
	Object userMultipleInstancesAllowed = conn.getAttribute("multipleInstancesAllowed");

	if (isPublicStream(name)) {
		log.info("stream " + name + " is public, allowing access");
		return true;
	}
	
	if (userIndex == null || userAuthorized == null || (boolean)userAuthorized != true) {
		log.info("user is not authorized and stream " + name + " is not public, closing connection");
		return false;
	}

	if (userMultipleInstancesAllowed == null || !userMultipleInstancesAllowed.equals(true))
		closeAlreadyOpenedStreamsForUser((int)userIndex, name);

	// Now we know what stream the client wants to access, so storing it as a connection attribute.
	conn.setAttribute("streamName", name);
	if (userName != null)
		log.info("user " + (String)userName + " is opening stream " + name);

	return true;
}
 
开发者ID:nonoo,项目名称:kdrlivestream,代码行数:29,代码来源:AuthPlaySec.java


示例20: kickById

import org.red5.server.api.scope.IScope; //导入依赖的package包/类
@Override
public boolean kickById(String uid) {
	try {
		StreamClient rcl = sessionManager.get(uid);

		if (rcl == null) {
			return true;
		}

		String scopeName = rcl.getScope() == null ? HIBERNATE : rcl.getScope();
		IScope scope = scopeAdapter.getChildScope(scopeName);
		if (scope == null) {
			log.warn("### kickById ### The scope is NULL");
			return false;
		}

		Map<Integer, String> messageObj = new HashMap<>();
		messageObj.put(0, "kick");
		scopeAdapter.sendMessageById(messageObj, uid, scope);

		scopeAdapter.roomLeaveByScope(rcl, scope);

		return true;
	} catch (Exception err) {
		log.error("[kickById]", err);
	}
	return false;
}
 
开发者ID:apache,项目名称:openmeetings,代码行数:29,代码来源:UserManager.java



注:本文中的org.red5.server.api.scope.IScope类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java XNamedValue类代码示例发布时间:2022-05-22
下一篇:
Java MapKey类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap