public synchronized void sendMessageWithClientByPublicSIDOrUser(Object message, String publicSID, Long user_id) {
try {
//ApplicationContext appCtx = getContext().getApplicationContext();
IScope globalScope = getContext().getGlobalScope();
IScope webAppKeyScope = globalScope.getScope(ScopeApplicationAdapter.webAppRootKey);
//log.debug("webAppKeyScope "+webAppKeyScope);
//Get Room Id to send it to the correct Scope
RoomClient currentClient = this.clientListManager.getClientByPublicSID(publicSID);
if (currentClient == null) {
currentClient = this.clientListManager.getClientByUserId(user_id);
}
Collection<Set<IConnection>> conCollection = null;
if (currentClient == null) {
//Must be from a previous session, search for user in current scope
IConnection current = Red5.getConnectionLocal();
//Notify all Clients of that Scope (Room)
conCollection = current.getScope().getConnections();
} else {
//default Scope Name
String scopeName = "hibernate";
if (currentClient.getRoom_id() != null) {
scopeName = currentClient.getRoom_id().toString();
}
IScope scopeHibernate = webAppKeyScope.getScope(scopeName);
if (scopeHibernate!=null){
conCollection = webAppKeyScope.getScope(scopeName).getConnections();
}
}