//FIXME copy/past need to be removed
@SuppressWarnings("unchecked")
public int sendMessageWithClientByPublicSID(Object newMessage, String publicSID) {
try {
IConnection current = Red5.getConnectionLocal();
Client currentClient = this.sessionManager.getClientByStreamId(current.getClient().getId(), null);
Long room_id = currentClient.getRoom_id();
Long user_level = userManager.getUserLevelByID(currentClient.getUser_id());
Room room = roomManager.getRoomById(user_level, room_id);
log.debug("room_id: " + room_id);
@SuppressWarnings("rawtypes")
ArrayList messageMap = (ArrayList) newMessage;
// adding delimiter space, cause otherwise an emoticon in the last
// string would not be found
String messageText = messageMap.get(4).toString() + " ";
// add server time
messageMap.set(1, parseDateAsTimeString());
LinkedList<String[]> parsedStringObjects = ChatString.parseChatString(messageText, emoticonsManager.getEmotfilesList(), room.getAllowFontStyles());
// log.error("parsedStringObjects"+parsedStringObjects.size());
log.debug("size:" + messageMap.size());
messageMap.add(parsedStringObjects);
newMessage = messageMap;
HashMap<String, Object> hsm = new HashMap<String, Object>();
hsm.put("client", currentClient);
hsm.put("message", newMessage);
// broadcast to everybody in the room/domain
Collection<Set<IConnection>> conCollection = current.getScope().getConnections();
for (Set<IConnection> conset : conCollection) {
for (IConnection conn : conset) {
if (conn != null) {
if (conn instanceof IServiceCapableConnection) {
IClient client = conn.getClient();
if (SessionVariablesUtil.isScreenClient(client)) {
// screen sharing clients do not receive events
continue;
} else if (SessionVariablesUtil.isAVClient(client)) {
// AVClients or potential AVClients do not receive events
continue;
}
if (SessionVariablesUtil.getPublicSID(client).equals(publicSID)
|| SessionVariablesUtil.getPublicSID(client).equals(
currentClient.getPublicSID())) {
((IServiceCapableConnection) conn).invoke(
"sendVarsToMessageWithClient",
new Object[] { hsm }, this);
}
}