/** * Disconnects client from scope. Can be applied to both application scope and scopes of lower level. This method calls * {@link ApplicationAdapter#appLeave(IClient, IScope)} or {@link ApplicationAdapter#roomLeave(IClient, IScope)} handlers respectively. * * @param client * Client object * @param scope * Scope object */ @Override public void leave(IClient client, IScope scope) { log.debug("leave: {} << {}", client, scope); if (ScopeUtils.isApp(scope)) { appLeave(client, scope); } else if (ScopeUtils.isRoom(scope)) { roomLeave(client, scope); } super.leave(client, scope); }
/** * Returns disconnection result for given scope and parameters. Whether the scope is room or app level scope, this method distinguishes * it and acts accordingly. * * @param conn * Connection object * @param scope * Scope */ @Override public void disconnect(IConnection conn, IScope scope) { log.debug("disconnect: {} < {}", conn, scope); if (log.isInfoEnabled() && ScopeUtils.isApp(scope)) { // log w3c connect event IClient client = conn.getClient(); if (client == null) { // log w3c connect event log.info("W3C x-category:session x-event:disconnect c-ip:{}", conn.getRemoteAddress()); } else { // log w3c connect event log.info("W3C x-category:session x-event:disconnect c-ip:{} c-client-id:{}", conn.getRemoteAddress(), client.getId()); } } if (ScopeUtils.isApp(scope)) { appDisconnect(conn); } else if (ScopeUtils.isRoom(scope)) { roomDisconnect(conn); } super.disconnect(conn, scope); }
/** * Adds client to scope. Scope can be both application or room. Can be applied to both application scope and scopes of lower level. This * method calls {@link ApplicationAdapter#appJoin(IClient, IScope)} or {@link ApplicationAdapter#roomJoin(IClient, IScope)} handlers * respectively. * * @param client * Client object * @param scope * Scope object */ @Override public boolean join(IClient client, IScope scope) { if (!super.join(client, scope)) { return false; } if (ScopeUtils.isApp(scope)) { return appJoin(client, scope); } else { return ScopeUtils.isRoom(scope) && roomJoin(client, scope); } }
if (ScopeUtils.isApp(scope)) { started = appStart(scope); } else if (ScopeUtils.isRoom(scope)) {
/** * Stops scope handling (that is, stops application if given scope is app level scope and stops room handling if given scope has lower * scope level). This method calls {@link ApplicationAdapter#appStop(IScope)} or {@link ApplicationAdapter#roomStop(IScope)} handlers * respectively. * * @param scope * Scope to stop */ @Override public void stop(IScope scope) { log.debug("stop: {}", scope.getName()); // stop the app / room / etc if (ScopeUtils.isApp(scope)) { // we don't allow connections after we stop super.setCanConnect(false); // we also don't allow service calls super.setCanCallService(false); // stop the app appStop(scope); } else if (ScopeUtils.isRoom(scope)) { roomStop(scope); } super.stop(scope); }
/** * Returns the application scope for a given path. * * @param path * @return IScope */ public IScope getApplicationScope(String path) { // set a reference to the application scope so we can create room scopes String applicationScopeName = path.split("\\/")[1]; log.debug("Looking for application scope: {}", applicationScopeName); return managerMap.keySet().stream().filter(scope -> (ScopeUtils.isApp(scope) && scope.getName().equals(applicationScopeName))).findFirst().get(); }