当前位置: 首页>>代码示例>>Java>>正文


Java IConnection.getAttribute方法代码示例

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


在下文中一共展示了IConnection.getAttribute方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isPublicStream

import org.red5.server.api.IConnection; //导入方法依赖的package包/类
private boolean isPublicStream(String streamName) {
	Set<IConnection> connections = Red5.getConnectionLocal().getScope().getClientConnections();

	for (IConnection conn : connections) {
		Object connUserAuthorized = conn.getAttribute("userAuthorized");
		Object connIsPublishing = conn.getAttribute("userIsPublishing");
		Object connPublicStream = conn.getAttribute("publicStream");
		Object connStreamName = conn.getAttribute("streamName");

		if (connUserAuthorized != null && (boolean)connUserAuthorized == true &&
				connIsPublishing != null && (boolean)connIsPublishing == true &&
				connStreamName != null && connStreamName.equals(streamName) &&
				connPublicStream != null && (boolean)connPublicStream == true) {
			return true;
		}
	}
	return false;
}
 
开发者ID:nonoo,项目名称:kdrlivestream,代码行数:19,代码来源:AuthPlaySec.java

示例2: execute

import org.red5.server.api.IConnection; //导入方法依赖的package包/类
@Override
public void execute(ISchedulingService service)	throws CloneNotSupportedException {
	Set<IConnection> connections = scope.getClientConnections();
	DBManager dbManager = new DBManager();

	for (IConnection conn : connections) {
		Object connUserIndex = conn.getAttribute("userIndex");
		Object connStreamName = conn.getAttribute("streamName");
		Object connUserIsPublishing = conn.getAttribute("userIsPublishing");
		Object connPublicStream = conn.getAttribute("publicStream");

		if (connUserIsPublishing == null)
			connUserIsPublishing = false;

		if (!connUserIsPublishing.equals(true)) {
			connPublicStream = false; // A non-publisher's lastseen table entry can't contain true for public. 
		}

		if (connPublicStream == null)
			connPublicStream = false;
		
		if (connUserIndex != null && connStreamName != null)
			dbManager.updateLastSeenForUser((String)connStreamName, (int)connUserIndex, (boolean)connUserIsPublishing, (boolean)connPublicStream);
	}
}
 
开发者ID:nonoo,项目名称:kdrlivestream,代码行数:26,代码来源:PeriodicLastSeenUpdater.java

示例3: isPublishAllowed

import org.red5.server.api.IConnection; //导入方法依赖的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

示例4: closeAlreadyOpenedStreamsForUser

import org.red5.server.api.IConnection; //导入方法依赖的package包/类
private void closeAlreadyOpenedStreamsForUser(int userIndex, String streamName) {
	Set<IConnection> connections = Red5.getConnectionLocal().getScope().getClientConnections();

	for (IConnection conn : connections) {
		Object connUserIndex = conn.getAttribute("userIndex");
		Object connUserName = conn.getAttribute("userName");
		Object connStreamName = conn.getAttribute("streamName");
		
		if (connUserIndex != null && connUserIndex.equals(userIndex) &&
				connStreamName != null && connStreamName.equals(streamName)) {
			log.info("closing already opened stream for user " + connUserName);
			conn.close();
		}
	}
}
 
开发者ID:nonoo,项目名称:kdrlivestream,代码行数:16,代码来源:AuthPlaySec.java

示例5: isPlaybackAllowed

import org.red5.server.api.IConnection; //导入方法依赖的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

示例6: appDisconnect

import org.red5.server.api.IConnection; //导入方法依赖的package包/类
public void appDisconnect(IConnection conn) {
	String scheduledPeriodicUpdate = (String) conn.getAttribute("scheduledPeriodicUpdate");
	ISchedulingService scheduler = (ISchedulingService)conn.getScope().getContext().getBean(ISchedulingService.BEAN_NAME);

	if (scheduledPeriodicUpdate != null) {
		log.info("removing scheduled periodic update job from user with index " + conn.getAttribute("userIndex"));
		scheduler.removeScheduledJob(scheduledPeriodicUpdate);
	}
}
 
开发者ID:nonoo,项目名称:kdrlivestream,代码行数:10,代码来源:AuthenticationHandler.java

示例7: execute

import org.red5.server.api.IConnection; //导入方法依赖的package包/类
@Override
public boolean execute(Context context) throws Exception {
	// TODO Auto-generated method stub
	TranscoderContext ctx = (TranscoderContext) context;
	TranscodeSessionPool pool =  ctx.getPool();
	IConnection connnection = Red5.getConnectionLocal();
	
	String signature = (String) connnection.getAttribute(Constants.TRANSCODER_SESSION_ATTR);
	ISession session = pool.getSession(signature);
	session.stop();
	
	return true;
}
 
开发者ID:rajdeeprath,项目名称:poor-man-transcoder,代码行数:14,代码来源:AbortTranscodeCommand.java

示例8: getPermissions

import org.red5.server.api.IConnection; //导入方法依赖的package包/类
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
public Collection<String> getPermissions(IConnection conn) {
    Collection<String> result = (Collection<String>) conn.getAttribute(PERMISSIONS);
    if (result == null) {
        result = Collections.emptySet();
    }
    return result;
}
 
开发者ID:Red5,项目名称:red5-server-common,代码行数:10,代码来源:Client.java


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