* @param newMessage
* @return
*/
public int sendMessageWithClient(Object newMessage) {
try {
IConnection current = Red5.getConnectionLocal();
RoomClient currentClient = this.clientListManager.getClientByStreamId(current.getClient().getId());
Long room_id = currentClient.getRoom_id();
log.debug("room_id: "+room_id);
log.debug("currentClient.getIsChatNotification(): "+currentClient.getIsChatNotification());
if (currentClient.getIsChatNotification()){
room_id = currentClient.getChatUserRoomId();
}
//log.error(newMessage.getClass().getName());
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()+" ";
//log.error("messageText"+messageText);
//add server time
messageMap.set(1,parseDateAsTimeString());
LinkedList<String[]> parsedStringObjects = ChatString.getInstance().parseChatString(messageText);
//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);
List<HashMap<String,Object>> myChatList = myChats.get(room_id);
if (myChatList==null) myChatList = new LinkedList<HashMap<String,Object>>();
if (myChatList.size()==chatRoomHistory) myChatList.remove(0);
myChatList.add(hsm);
myChats.put(room_id,myChatList);
log.debug("SET CHATROOM: "+room_id);
//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) {