本文整理汇总了Java中org.red5.server.api.scope.IScope类的典型用法代码示例。如果您正苦于以下问题:Java IScope类的具体用法?Java IScope怎么用?Java IScope使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IScope类属于org.red5.server.api.scope包,在下文中一共展示了IScope类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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;
}
示例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();
}
示例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);
}
}
示例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();
}
示例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;
}
示例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);
}
}
示例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;
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
}
示例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);
}
}
示例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;
}