本文整理汇总了Java中org.red5.server.plugin.PluginRegistry类的典型用法代码示例。如果您正苦于以下问题:Java PluginRegistry类的具体用法?Java PluginRegistry怎么用?Java PluginRegistry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PluginRegistry类属于org.red5.server.plugin包,在下文中一共展示了PluginRegistry类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: onWSMessage
import org.red5.server.plugin.PluginRegistry; //导入依赖的package包/类
@Override
public void onWSMessage(WSMessage message) {
// assume we have text
String msg = new String(message.getPayload().array());
log.info("onWSMessage: {}", msg);
// get the path
String path = message.getPath();
// just echo back the message
WebSocketScopeManager manager = ((WebSocketPlugin) PluginRegistry.getPlugin("WebSocketPlugin")).getManager(path);
if (manager != null) {
// get the ws scope
WebSocketScope wsScope = manager.getScope(path);
Set<WebSocketConnection> conns = wsScope.getConns();
for (WebSocketConnection conn : conns) {
log.debug("Echoing to {}", conn);
try {
conn.send(msg);
} catch (UnsupportedEncodingException e) {
log.warn("Encoding issue with the message data: {}", message, e);
}
}
} else {
log.info("No manager found for path: {}", path);
}
}
开发者ID:Red5,项目名称:red5-websocket,代码行数:26,代码来源:DefaultWebSocketDataListener.java
示例2: sessionClosed
import org.red5.server.plugin.PluginRegistry; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void sessionClosed(IoSession session) throws Exception {
log.trace("Session closed");
// remove connection from scope
WebSocketConnection conn = (WebSocketConnection) session.removeAttribute(Constants.CONNECTION);
if (conn != null) {
// remove from the manager
WebSocketPlugin plugin = (WebSocketPlugin) PluginRegistry.getPlugin("WebSocketPlugin");
if (plugin != null) {
String path = conn.getPath();
if (path != null) {
WebSocketScopeManager manager = (WebSocketScopeManager) session.removeAttribute(Constants.MANAGER);
if (manager == null) {
manager = plugin.getManager(path);
}
if (manager != null) {
manager.removeConnection(conn);
} else {
log.debug("WebSocket manager was not found");
}
} else {
log.debug("WebSocket connection path was null");
}
} else {
log.debug("WebSocket plugin was not found");
}
} else {
log.debug("WebSocket connection was null");
}
super.sessionClosed(session);
}
开发者ID:Red5,项目名称:red5-websocket,代码行数:35,代码来源:WebSocketHandler.java
示例3: receive
import org.red5.server.plugin.PluginRegistry; //导入依赖的package包/类
/**
* Receive data from a client.
*
* @param message
*/
public void receive(WSMessage message) {
log.trace("receive message");
if (isConnected()) {
WebSocketScopeManager manager = (WebSocketScopeManager) session.getAttribute(Constants.MANAGER);
if (manager == null) {
WebSocketPlugin plugin = (WebSocketPlugin) PluginRegistry.getPlugin("WebSocketPlugin");
manager = plugin.getManager(path);
}
WebSocketScope scope = manager.getScope(path);
scope.onMessage(message);
} else {
log.warn("Not connected");
}
}
开发者ID:Red5,项目名称:red5-websocket,代码行数:20,代码来源:WebSocketConnection.java
示例4: register
import org.red5.server.plugin.PluginRegistry; //导入依赖的package包/类
/**
* Registers with the WebSocketScopeManager.
*/
public void register() {
log.info("Application scope: {}", scope);
// set the logger to the app scope
//log = Red5LoggerFactory.getLogger(WebSocketScope.class, scope.getName());
WebSocketScopeManager manager = ((WebSocketPlugin) PluginRegistry.getPlugin("WebSocketPlugin")).getManager(scope);
manager.setApplication(scope);
log.info("WebSocket app added: {}", scope.getName());
manager.addWebSocketScope(this);
log.info("WebSocket scope added");
}
开发者ID:Red5,项目名称:red5-websocket,代码行数:14,代码来源:WebSocketScope.java
示例5: testUriWithParams
import org.red5.server.plugin.PluginRegistry; //导入依赖的package包/类
@Test
public void testUriWithParams() throws Throwable {
log.info("\ntestUriWithParams enter");
// create the server instance
Thread server = new Thread() {
@Override
public void run() {
log.debug("Server thread run");
try {
WSServer.main(null);
} catch (IOException e) {
log.error("Error in server thread", e);
}
log.debug("Server thread exit");
}
};
server.setDaemon(true);
server.start();
// add plugin to the registry
WebSocketPlugin plugin = new WebSocketPlugin();
PluginRegistry.register(plugin);
// start plugin
plugin.doStart();
// create a scope for the manager
IScope appScope = new GlobalScope();
// create an app
MultiThreadedApplicationAdapter app = new MultiThreadedApplicationAdapter();
app.setScope(appScope);
// add the app
plugin.setApplication(app);
// get the manager
WebSocketScopeManager manager = plugin.getManager(appScope);
manager.setApplication(appScope);
// wait for server
while (!WSServer.isListening()) {
Thread.sleep(10L);
}
// create the client
final TyrusWSClient client = new TyrusWSClient();
//final TyrusWSClient client = new TyrusWSClient(8192 * 10);
Thread t = new Thread(new Runnable() {
public void run() {
client.start();
}
}, "tyrus");
t.start();
t.join(5000);
// send a message
//client.sendMessage("This is a test");
// terminate client
client.terminate();
// stop server
server.interrupt();
WSServer.stop();
// stop plugin
PluginRegistry.shutdown();
log.info("testUriWithParams exit");
}
开发者ID:Red5,项目名称:red5-websocket,代码行数:59,代码来源:WebSocketServerTest.java
示例6: appStart
import org.red5.server.plugin.PluginRegistry; //导入依赖的package包/类
@Override
public boolean appStart(IScope scope) {
WebSocketScopeManager manager = ((WebSocketPlugin) PluginRegistry.getPlugin("WebSocketPlugin")).getManager();
manager.addApplication(scope);
return super.appStart(scope);
}
开发者ID:rajdeeprath,项目名称:red5-server-apps,代码行数:7,代码来源:Application.java
示例7: appStop
import org.red5.server.plugin.PluginRegistry; //导入依赖的package包/类
@Override
public void appStop(IScope scope) {
WebSocketScopeManager manager = ((WebSocketPlugin) PluginRegistry.getPlugin("WebSocketPlugin")).getManager();
manager.removeApplication(scope);
super.appStop(scope);
}
开发者ID:rajdeeprath,项目名称:red5-server-apps,代码行数:7,代码来源:Application.java
注:本文中的org.red5.server.plugin.PluginRegistry类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论