Java Code Examples for org.jivesoftware.smackx.xevent.MessageEventManager#addNotificationsRequests()

The following examples show how to use org.jivesoftware.smackx.xevent.MessageEventManager#addNotificationsRequests() . 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: ChatRoomImpl.java    From Spark with Apache License 2.0 5 votes vote down vote up
/**
    * Sends a message to the appropriate jid. The message is automatically added to the transcript.
    *
    * @param message the message to send.
    */
   @Override
public void sendMessage(Message message) {
       //Before sending message, let's add our full jid for full verification
       //Set message attributes before insertMessage is called - this is useful when transcript window is extended
       //more information will be available to be displayed for the chat area Document
       message.setType(Message.Type.chat);
       message.setTo(participantJID);
       message.setFrom(SparkManager.getSessionManager().getJID());

       displaySendMessage( message );

       // No need to request displayed or delivered as we aren't doing anything with this
       // information.
       MessageEventManager.addNotificationsRequests(message, true, false, false, true);

       // Set chat state to 'active'
       message.addExtension( new ChatStateExtension( ChatState.active ) );

       // Send the message that contains the notifications request
       try {
           fireOutgoingMessageSending(message);
           SparkManager.getConnection().sendStanza(message);
       }
       catch (Exception ex) {
           Log.error("Error sending message", ex);
       }
   }
 
Example 2
Source File: GroupChatRoom.java    From Spark with Apache License 2.0 5 votes vote down vote up
/**
 * Sends a message.
 *
 * @param message - the message to send.
 */
@Override
public void sendMessage( Message message )
{
    try
    {
        message.setTo( chat.getRoom() );
        message.setType( Message.Type.groupchat );
        MessageEventManager.addNotificationsRequests( message, true, true, true, true );
        addPacketID( message.getStanzaId() );

        SparkManager.getChatManager().filterOutgoingMessage( this, message );
        SparkManager.getChatManager().fireGlobalMessageSentListeners( this, message );

        chat.sendMessage( message );
    }
    catch ( SmackException | InterruptedException ex )
    {
        Log.error( "Unable to send message in conference chat.", ex );
    }

    // Notify users that message has been sent.
    fireMessageSent( message );

    addToTranscript( message, false );

    getChatInputEditor().clear();
    getTranscriptWindow().validate();
    getTranscriptWindow().repaint();

    getChatInputEditor().setCaretPosition( 0 );
    getChatInputEditor().requestFocusInWindow();
    scrollToBottom();

    lastActivity = System.currentTimeMillis();
}
 
Example 3
Source File: CoBrowser.java    From Spark with Apache License 2.0 5 votes vote down vote up
private void send(Message message) {
    GroupChatRoom groupChatRoom = (GroupChatRoom)chatRoom;
    try {
        message.setTo(groupChatRoom.getRoomname());
        message.setType(Message.Type.groupchat);
        MessageEventManager.addNotificationsRequests(message, true, true, true, true);


        groupChatRoom.getMultiUserChat().sendMessage(message);
    }
    catch (SmackException | InterruptedException ex) {
        Log.error("Unable to send message in conference chat.", ex);
    }

}