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


Java IConnection.setAttribute方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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;
	File workingDir = null;
	
	File templateFile = new File(ctx.getTemplateDirectory() + File.separator + this.request.getTemplateFileName());
	if(!templateFile.exists()) throw new IOException("Template not found");
	
	if(this.request.getWorkingDirectory() != null) {
	workingDir = new File(this.request.getWorkingDirectory());
	if(!workingDir.exists()) throw new IOException("Working directory not found");
	}
	
	IOUtils.IdentifyInput(input);
	String stream = input.getMediaName();
	
	TranscodeSessionPool pool =  ctx.getPool();
	
	ISession session = pool.checkOut(input, request);
	session.setWorkingDirectoryPath(workingDir.getAbsolutePath());
	
	IConnection connnection = Red5.getConnectionLocal();
	connnection.setAttribute(Constants.TRANSCODER_SESSION_ATTR, pool.getSignature(session));
			
	session.start();
	
	return true;
}
 
开发者ID:rajdeeprath,项目名称:poor-man-transcoder,代码行数:30,代码来源:DoTranscodeCommand.java

示例4: setPermissions

import org.red5.server.api.IConnection; //导入方法依赖的package包/类
/** {@inheritDoc} */
public void setPermissions(IConnection conn, Collection<String> permissions) {
    if (permissions == null) {
        conn.removeAttribute(PERMISSIONS);
    } else {
        conn.setAttribute(PERMISSIONS, permissions);
    }
}
 
开发者ID:Red5,项目名称:red5-server-common,代码行数:9,代码来源:Client.java

示例5: calculateClientBw

import org.red5.server.api.IConnection; //导入方法依赖的package包/类
public void calculateClientBw(IConnection p_client) {

		for (int i = 0; i < 1200; i++) {
			payload[i] = Math.random();
		}

		p_client.setAttribute("payload", payload);

		for (int i = 0; i < 12000; i++) {
			payload_1[i] = Math.random();
		}

		p_client.setAttribute("payload_1", payload_1);

		for (int i = 0; i < 12000; i++) {
			payload_2[i] = Math.random();
		}

		p_client.setAttribute("payload_2", payload_2);

		final IStreamCapableConnection beginningStats = this.getStats();
		final Long start = new Long(System.nanoTime() / 1000000); 

		this.client = p_client;
		beginningValues = new HashMap<String, Long>();
		beginningValues.put("b_down", beginningStats.getWrittenBytes());
		beginningValues.put("time", start);

		this.pakSent.add(start);
		this.sent++;
		log.info("Starting bandwidth check {} ", new Object[]{start});
        
		this.callBWCheck("");

	}
 
开发者ID:Red5,项目名称:red5-examples,代码行数:36,代码来源:ServerClientDetection.java

示例6: appConnect

import org.red5.server.api.IConnection; //导入方法依赖的package包/类
public boolean appConnect(IConnection conn, Object[] params) {
	Map<String, Object> connectionParams = conn.getConnectParams();
	UrlQueryStringMap<String, String> queryString;
	log.info("connection params: " + connectionParams);

	if (connectionParams.containsKey("queryString")) {
		String rawQueryString = (String) connectionParams.get("queryString");
		//log.info("queryString: " + rawQueryString);

		// Parse into a usable query string.
		try {
			queryString = UrlQueryStringMap.parse(rawQueryString);
		} catch (ArrayIndexOutOfBoundsException e) {
			return true;
		}

		String userName = queryString.get("u");
		String password = queryString.get("p");

		if (userName != null && password != null) {
			int userIndex = dbManager.getUserIndex(userName);
			if (userIndex < 0) {
				userName.replace("_at_", "@");
				userIndex = dbManager.getUserIndex(userName);
			}
			conn.setAttribute("userName", userName);
			conn.setAttribute("userIndex", userIndex);

			if (dbManager.isUserAuthorized(userName, password)) {
				conn.setAttribute("userAuthorized", true);
				conn.setAttribute("publishAllowed", dbManager.isPublishAllowedForUser(userIndex));
				conn.setAttribute("multipleInstancesAllowed", dbManager.isMultipleInstancesAllowedForUser(userIndex));

				String publicStream = queryString.get("pub");
				if (publicStream != null)
					conn.setAttribute("publicStream", publicStream.equals("1"));
			}
		}
	}

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

示例7: appConnect

import org.red5.server.api.IConnection; //导入方法依赖的package包/类
@Override
public boolean appConnect(IConnection conn, Object[] arg1) {
	
	String username;
	String roomname;
	
	try
	{
		if(arg1.length < 2){
			throw new Exception("Missing parameters");
		}
		
		username = String.valueOf(arg1[0]);
		roomname = String.valueOf(arg1[1]);
		
		if(username == null || roomname == null){
			throw new Exception("Invalid value or one or more parameters!");
		}
		
		
		if(this.hasUser(username, roomname))
		{
			throw new Exception("User by name " + username + " exists in the room defined by name " + roomname);
		}
		else
		{
			boolean added = addUser(username, roomname);
			if(!added) {
				throw new Exception("Unable to add user to room!");
			}
		}
		
		conn.setAttribute("username", username);
		conn.setAttribute("roomname", roomname);
	}
	catch(Exception e)
	{
		throw new ClientRejectedException(e.getMessage());
	}	
	
	
	return super.appConnect(conn, arg1);
}
 
开发者ID:rajdeeprath,项目名称:red5-server-apps,代码行数:44,代码来源:Application.java


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