Java Code Examples for org.jivesoftware.smack.packet.Message#setProperty()
The following examples show how to use
org.jivesoftware.smack.packet.Message#setProperty() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ChatManagerController.java From olat with Apache License 2.0 | 6 votes |
/** * @param initialMessages * @return */ private Message extractMessages(final List<Message> initialMessages) { if (initialMessages == null) { return null; } if (initialMessages.size() > 1) { final Message msg = initialMessages.get(0); final StringBuilder sb = new StringBuilder(); final String from = msg.getFrom(); for (final Iterator<Message> iterator = initialMessages.iterator(); iterator.hasNext();) { final Message message = iterator.next(); if (message.getFrom().equals(from)) { sb.append(message.getBody()).append("<br/>\n"); } } final Message newMsg = new Message(); newMsg.setBody(sb.toString()); newMsg.setFrom(from); newMsg.setProperty("receiveTime", new Long(new Date().getTime())); return newMsg; } else { return initialMessages.get(0); } }
Example 2
Source File: ClientManagerImpl.java From olat with Apache License 2.0 | 6 votes |
/** * @param username */ @Override public void addMessageListener(final String username) { final PacketListener packetListener = new PacketListener() { @Override public void processPacket(final Packet packet) { final Message jabbmessage = (Message) packet; // TODO:gs:b see issue: http://bugs.olat.org/jira/browse/OLAT-2966 // filter <script> msg. out - security risk of cross site scripting! // or may user ext.util.strip script tag method on client side jabbmessage.setProperty("receiveTime", new Long(new Date().getTime())); final GenericEventListener listener = listeners.get(username); if (listener != null) { listener.event(new InstantMessagingEvent(packet, "message")); if (log.isDebugEnabled()) { log.debug("routing message event to controller of: " + packet.getTo()); } } else { log.warn("could not find listener for IM message for username: " + username, null); } } }; getInstantMessagingClient(username).getConnection().addPacketListener(packetListener, new PacketTypeFilter(Message.class)); }
Example 3
Source File: GroupChatJoinTask.java From olat with Apache License 2.0 | 6 votes |
/** * listens to new messages for this chatroom */ void addMessageListener() { messageListener = new PacketListener() { @Override public void processPacket(final Packet packet) { final Message jabbmessage = (Message) packet; if (log.isDebugEnabled()) { log.debug("processPacket Msg: to=" + jabbmessage.getTo()); } jabbmessage.setProperty("receiveTime", new Long(new Date().getTime())); if ((jabbmessage.getType() == Message.Type.groupchat) && jabbmessage.getBody() != null) { listeningController.event(new InstantMessagingEvent(jabbmessage, "groupchat")); } } }; muc.addMessageListener(messageListener); }
Example 4
Source File: ChatManagerController.java From olat with Apache License 2.0 | 6 votes |
/** * @param initialMessages * @return */ private Message extractMessages(final List<Message> initialMessages) { if (initialMessages == null) { return null; } if (initialMessages.size() > 1) { final Message msg = initialMessages.get(0); final StringBuilder sb = new StringBuilder(); final String from = msg.getFrom(); for (final Iterator<Message> iterator = initialMessages.iterator(); iterator.hasNext();) { final Message message = iterator.next(); if (message.getFrom().equals(from)) { sb.append(message.getBody()).append("<br/>\n"); } } final Message newMsg = new Message(); newMsg.setBody(sb.toString()); newMsg.setFrom(from); newMsg.setProperty("receiveTime", new Long(new Date().getTime())); return newMsg; } else { return initialMessages.get(0); } }
Example 5
Source File: ClientManagerImpl.java From olat with Apache License 2.0 | 6 votes |
/** * @param username */ @Override public void addMessageListener(final String username) { final PacketListener packetListener = new PacketListener() { @Override public void processPacket(final Packet packet) { final Message jabbmessage = (Message) packet; // TODO:gs:b see issue: http://bugs.olat.org/jira/browse/OLAT-2966 // filter <script> msg. out - security risk of cross site scripting! // or may user ext.util.strip script tag method on client side jabbmessage.setProperty("receiveTime", new Long(new Date().getTime())); final GenericEventListener listener = listeners.get(username); if (listener != null) { listener.event(new InstantMessagingEvent(packet, "message")); if (log.isDebugEnabled()) { log.debug("routing message event to controller of: " + packet.getTo()); } } else { log.warn("could not find listener for IM message for username: " + username, null); } } }; getInstantMessagingClient(username).getConnection().addPacketListener(packetListener, new PacketTypeFilter(Message.class)); }
Example 6
Source File: GroupChatJoinTask.java From olat with Apache License 2.0 | 6 votes |
/** * listens to new messages for this chatroom */ void addMessageListener() { messageListener = new PacketListener() { @Override public void processPacket(final Packet packet) { final Message jabbmessage = (Message) packet; if (log.isDebugEnabled()) { log.debug("processPacket Msg: to=" + jabbmessage.getTo()); } jabbmessage.setProperty("receiveTime", new Long(new Date().getTime())); if ((jabbmessage.getType() == Message.Type.groupchat) && jabbmessage.getBody() != null) { listeningController.event(new InstantMessagingEvent(jabbmessage, "groupchat")); } } }; muc.addMessageListener(messageListener); }
Example 7
Source File: XSCHelper.java From PracticeCode with Apache License 2.0 | 5 votes |
/** * 发送信息到云同步室 * * @param room 云同步室 * @param msg 将要发送的信息 */ public void sendProjChromMsg(MultiUserChat room, Object msg) { if (!room.isJoined()) return; try { Message message = new Message(room.getRoom(), Message.Type.groupchat); message.setBody(SysUtil.getInstance().getDateAndTimeFormated()); message.setProperty(MSGCLOUD, msg); room.sendMessage(message); } catch (XMPPException e) { e.printStackTrace(); } }
Example 8
Source File: InstantMessagingGroupChatController.java From olat with Apache License 2.0 | 5 votes |
private Message createMessage(final String from, final String msgBody) { final Message msg = new Message(); msg.setBody(msgBody); msg.setFrom(from); msg.setProperty("receiveTime", new Long(new Date().getTime())); return msg; }
Example 9
Source File: ChatController.java From olat with Apache License 2.0 | 5 votes |
/** * @param body * - any text * @param from * must be a valid jid * @return */ private Message createInstantMessage(final String body, final String from) { final Message message = new Message(); message.setBody(body); message.setFrom(from); message.setProperty("receiveTime", new Long(new Date().getTime())); return message; }
Example 10
Source File: InstantMessagingGroupChatController.java From olat with Apache License 2.0 | 5 votes |
private Message createMessage(final String from, final String msgBody) { final Message msg = new Message(); msg.setBody(msgBody); msg.setFrom(from); msg.setProperty("receiveTime", new Long(new Date().getTime())); return msg; }
Example 11
Source File: ChatController.java From olat with Apache License 2.0 | 5 votes |
/** * @param body * - any text * @param from * must be a valid jid * @return */ private Message createInstantMessage(final String body, final String from) { final Message message = new Message(); message.setBody(body); message.setFrom(from); message.setProperty("receiveTime", new Long(new Date().getTime())); return message; }
Example 12
Source File: XMPPPeerInterface.java From hypergraphdb with Apache License 2.0 | 4 votes |
public PeerRelatedActivityFactory newSendActivityFactory() { return new PeerRelatedActivityFactory() { public PeerRelatedActivity createActivity() { return new PeerRelatedActivity() { public Boolean call() throws Exception { Json msg = getMessage(); if (!msg.has(Messages.REPLY_TO)) { msg.set(Messages.REPLY_TO, connection.getUser()); } String msgAsString = msg.toString(); if (msgAsString.length() > fileTransferThreshold) { OutgoingFileTransfer outFile = fileTransfer.createOutgoingFileTransfer((String)getTarget()); byte [] B = msgAsString.getBytes(); outFile.sendStream(new ByteArrayInputStream(B), "", B.length, ""); return true; } else { try { Message xmpp = new Message((String)getTarget()); xmpp.setBody(msgAsString); xmpp.setProperty("hypergraphdb", Boolean.TRUE); connection.sendPacket(xmpp); return true; } catch (Throwable t) { t.printStackTrace(System.err); return false; } } } }; } }; }