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


Java IConnection类代码示例

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


IConnection类属于org.red5.server.api包,在下文中一共展示了IConnection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: addListener

import org.red5.server.api.IConnection; //导入依赖的package包/类
/**
 * Start recording the published stream for the specified broadcast-Id
 *
 * @param conn
 * @param broadcastid
 * @param streamName
 * @param metaId
 * @param isScreenSharing
 * @param isInterview
 */
private void addListener(IConnection conn, String broadcastid, String streamName, Long metaId, boolean isScreenSharing, boolean isInterview) {
	log.debug("Recording show for: {}", conn.getScope().getContextPath());
	log.debug("Name of CLient and Stream to be recorded: {}", broadcastid);
	log.debug("Scope " + conn);
	log.debug("Scope " + conn.getScope());
	// Get a reference to the current broadcast stream.
	ClientBroadcastStream stream = (ClientBroadcastStream) scopeAdapter.getBroadcastStream(conn.getScope(), broadcastid);

	if (stream == null) {
		log.debug("Unable to get stream: {}", streamName);
		return;
	}
	// Save the stream to disk.
	log.debug("### stream: [{}, name: {}, scope: {}, metaId: {}, sharing ? {}, interview ? {}]"
			, stream, streamName, conn.getScope(), metaId, isScreenSharing, isInterview);
	StreamListener streamListener = new StreamListener(!isScreenSharing, streamName, conn.getScope(), metaId, isScreenSharing, isInterview);

	streamListeners.put(metaId, streamListener);
	stream.addStreamListener(streamListener);
}
 
开发者ID:apache,项目名称:openmeetings,代码行数:31,代码来源:RecordingService.java

示例5: dropSharing

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

import org.red5.server.api.IConnection; //导入依赖的package包/类
/**
 * wrapper method
 *
 * @param newMessage - message being sent
 * @param sync - send self
 * @return 1 in case of success, -1 otherwise
 */
public int sendMessageWithClientWithSyncObject(Object newMessage, boolean sync) {
	try {
		IConnection current = Red5.getConnectionLocal();
		StreamClient currentClient = sessionManager.get(IClientUtil.getId(current.getClient()));

		Map<String, Object> hsm = new HashMap<>();
		hsm.put("client", currentClient);
		hsm.put("message", newMessage);

		//Sync to all users of current scope
		sendMessageToCurrentScope("sendVarsToMessageWithClient", hsm, sync);

	} catch (Exception err) {
		_log.error("[sendMessageWithClient] ", err);
		return -1;
	}
	return 1;
}
 
开发者ID:apache,项目名称:openmeetings,代码行数:26,代码来源:ScopeApplicationAdapter.java

示例7: updateSipTransport

import org.red5.server.api.IConnection; //导入依赖的package包/类
public synchronized int updateSipTransport() {
	_log.debug("-----------  updateSipTransport");
	IConnection current = Red5.getConnectionLocal();
	StreamClient client = sessionManager.get(IClientUtil.getId(current.getClient()));
	Long roomId = client.getRoomId();
	Integer count = getSipConferenceMembersNumber(roomId);
	String newNumber = getSipTransportLastname(count);
	_log.debug("getSipConferenceMembersNumber: " + newNumber);
	if (!newNumber.equals(client.getLastname())) {
		Client cl = getApp().getOmClientBySid(client.getSid());
		cl.getUser().setLastname(newNumber);
		client.setLastname(newNumber);
		sessionManager.update(client);
		_log.debug("updateSipTransport: {}, {}, {}, {}, {}", new Object[] { client.getUid(), client.getRoomId(),
				client.getFirstname(), client.getLastname(), client.getAvsettings() });
		WebSocketHelper.sendRoom(new TextRoomMessage(client.getRoomId(), client, RoomMessage.Type.rightUpdated, client.getUid()));
		sendMessageWithClient(new String[] { "personal", client.getFirstname(), client.getLastname() });
	}
	return count != null && count > 0 ? count - 1 : 0;
}
 
开发者ID:apache,项目名称:openmeetings,代码行数:21,代码来源:ScopeApplicationAdapter.java

示例8: login

import org.red5.server.api.IConnection; //导入依赖的package包/类
private Map<String, Object> login(User u, Map<String, Object> result) {
	if (u != null) {
		IConnection conn = Red5.getConnectionLocal();
		Sessiondata sd = sessionDao.create(u.getId(), u.getLanguageId());
		StreamClient c = create(u, sd);
		c.setScope(conn.getScope().getName());
		sessionManager.add(c);
		IClientUtil.init(conn.getClient(), c.getUid(), false);

		add(result, "sid", sd.getSessionId());
		add(result, "publicSid", c.getUid());
		add(result, PARAM_STATUS, 0);
		add(result, PARAM_USER_ID, u.getId());
		add(result, "firstname", u.getFirstname());
		add(result, "lastname", u.getLastname());
		add(result, "login", u.getLogin());
		add(result, "email", u.getAddress() == null ? "" : u.getAddress().getEmail());
		add(result, "language", u.getLanguageId());
		add(result, "version", getVersion());
	}
	return result;
}
 
开发者ID:apache,项目名称:openmeetings,代码行数:23,代码来源:MobileService.java

示例9: updateAvMode

import org.red5.server.api.IConnection; //导入依赖的package包/类
public Map<String, Object> updateAvMode(String avMode, String width, String height, Integer interviewPodId) {
	IConnection current = Red5.getConnectionLocal();
	StreamClient c = sessionManager.get(IClientUtil.getId(current.getClient()));
	c.setAvsettings(avMode);
	if (!"n".equals(avMode)) {
		c.setBroadcastId(UUID.randomUUID().toString());
		c.setBroadcasting(true);
	}
	c.setWidth(Double.valueOf(width).intValue());
	c.setHeight(Double.valueOf(height).intValue());
	if (interviewPodId > 0) {
		c.setInterviewPodId(interviewPodId);
	}
	sessionManager.update(c);
	Map<String, Object> hsm = new HashMap<>();
	hsm.put("client", c);
	hsm.put("message", new String[]{"avsettings", "0", avMode});
	Map<String, Object> result = new HashMap<>();
	if (!"n".equals(avMode)) {
		result.put("broadcastId", c.getBroadcastId());
	}

	scopeAdapter.sendMessageToCurrentScope("sendVarsToMessageWithClient", hsm, true, false);
	return result;
}
 
开发者ID:apache,项目名称:openmeetings,代码行数:26,代码来源:MobileService.java

示例10: sendChatMessage

import org.red5.server.api.IConnection; //导入依赖的package包/类
public void sendChatMessage(String msg) {
	IConnection current = Red5.getConnectionLocal();
	StreamClient c = sessionManager.get(IClientUtil.getId(current.getClient()));

	ChatMessage m = new ChatMessage();
	m.setMessage(msg);
	m.setSent(new Date());
	User u = userDao.get(c.getUserId());
	m.setFromUser(u);
	Room r = roomDao.get(c.getRoomId());
	m.setToRoom(r);
	m.setNeedModeration(r.isChatModerated() && !isModerator(c));
	chatDao.update(m);
	FastDateFormat fmt = FormatHelper.getDateTimeFormat(u);
	sendChatMessage(c, m, fmt);
	WebSocketHelper.sendRoom(m, WebSocketHelper.getMessage(u, Arrays.asList(m), null));
}
 
开发者ID:apache,项目名称:openmeetings,代码行数:18,代码来源:MobileService.java

示例11: getRoomChatHistory

import org.red5.server.api.IConnection; //导入依赖的package包/类
public List<Map<String, Object>> getRoomChatHistory() {
	List<Map<String,Object>> myChatList = new ArrayList<>();
	try {
		IConnection current = Red5.getConnectionLocal();
		StreamClient c = sessionManager.get(IClientUtil.getId(current.getClient()));
		Long roomId = c.getRoomId();

		log.debug("GET CHATROOM: " + roomId);

		Room r = roomDao.get(roomId);
		User u = userDao.get(c.getUserId());
		FastDateFormat fmt = FormatHelper.getDateTimeFormat(u);
		for (ChatMessage m : chatDao.getRoom(roomId, 0, 30, !r.isChatModerated() || isModerator(c))) {
			myChatList.add(encodeChatMessage(m, fmt));
		}

	} catch (Exception err) {
		log.error("[getRoomChatHistory] ",err);
	}
	return myChatList;
}
 
开发者ID:apache,项目名称:openmeetings,代码行数:22,代码来源:MobileService.java

示例12: streamBroadcastClose

import org.red5.server.api.IConnection; //导入依赖的package包/类
@Override
public void streamBroadcastClose(IBroadcastStream stream) {
	// TODO Auto-generated method stub
	log.debug("Inside streamBroadcastClose");
	
	String streamFullName = DVRUtils.getStreamFullName(stream.getPublishedName());
	IDVRStream dvrStream = this.getStream(streamFullName, false);
	
	if(dvrStream != null)
	{
		IConnection conn = Red5.getConnectionLocal();
		dvrStream.unpublish(conn);
	}
	
	super.streamBroadcastClose(stream);
}
 
开发者ID:rajdeeprath,项目名称:red5-server-apps,代码行数:17,代码来源:Application.java

示例13: appDisconnect

import org.red5.server.api.IConnection; //导入依赖的package包/类
@Override
public void appDisconnect(IConnection conn) 
{
	String username;
	String roomname;
	
	try
	{
		if(conn.hasAttribute("username")){
			username = conn.getStringAttribute("username");
			roomname = conn.getStringAttribute("roomname");
			this.removeUser(username, roomname);
		}
	}
	catch(Exception e)
	{
		log.error("Error removing user : ", e);
	}
	
	super.appDisconnect(conn);
}
 
开发者ID:rajdeeprath,项目名称:red5-server-apps,代码行数:22,代码来源:Application.java

示例14: callBWCheck

import org.red5.server.api.IConnection; //导入依赖的package包/类
private void callBWCheck(Object payload) {
    if (log.isTraceEnabled()) {
        log.trace("callBWCheck: {}", payload);
    } else {
        log.debug("callBWCheck");
    }
    IConnection conn = Red5.getConnectionLocal();
    Map<String, Object> statsValues = new HashMap<String, Object>();
    statsValues.put("count", packetsReceived.get());
    statsValues.put("sent", packetsSent.get());
    statsValues.put("timePassed", timePassed);
    statsValues.put("latency", latency);
    statsValues.put("cumLatency", cumLatency);
    statsValues.put("payload", payload);
    if (conn instanceof IServiceCapableConnection) {
        log.debug("Invoking onBWCheck on the client");
        // increment sent counter
        packetsSent.incrementAndGet();
        // invoke on the client
        ((IServiceCapableConnection) conn).invoke("onBWCheck", new Object[] { statsValues }, this);
    }
}
 
开发者ID:Red5,项目名称:red5-server-common,代码行数:23,代码来源:ServerClientDetection.java

示例15: callBWDone

import org.red5.server.api.IConnection; //导入依赖的package包/类
private void callBWDone() {
    log.debug("callBWDone");
    IConnection conn = Red5.getConnectionLocal();
    Map<String, Object> statsValues = new HashMap<String, Object>();
    statsValues.put("kbitDown", kbitDown);
    statsValues.put("deltaDown", deltaDown);
    statsValues.put("deltaTime", deltaTime);
    statsValues.put("latency", latency);
    if (conn instanceof IServiceCapableConnection) {
        log.debug("Invoking onBWDone on the client");
        // invoke on the client
        ((IServiceCapableConnection) conn).invoke("onBWDone", new Object[] { statsValues });
        // adjust bandwidth to mbit/s
        int mbits = (int) ((kbitDown / 1000d) * 1000000);
        log.debug("Setting bandwidth to {} mbit/s", mbits);
        // tell the flash player how fast we want data and how fast we shall send it
        conn.setBandwidth(mbits);
    }
}
 
开发者ID:Red5,项目名称:red5-server-common,代码行数:20,代码来源:ServerClientDetection.java


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