org.jivesoftware.smackx.xevent.MessageEventManager Java Examples

The following examples show how to use org.jivesoftware.smackx.xevent.MessageEventManager. 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: OperationSetTypingNotificationsJabberImpl.java    From jitsi with Apache License 2.0 5 votes vote down vote up
@Override
public void deliveredNotificationRequested(Jid from, String packetID,
    MessageEventManager messageEventManager)
    throws NotConnectedException, InterruptedException
{
    messageEventManager.sendDeliveredNotification(from, packetID);
}
 
Example #2
Source File: OperationSetTypingNotificationsJabberImpl.java    From jitsi with Apache License 2.0 5 votes vote down vote up
@Override
public void displayedNotificationRequested(Jid from, String packetID,
                                           MessageEventManager messageEventManager)
{
    try
    {
        messageEventManager.sendDisplayedNotification(from, packetID);
    }
    catch (NotConnectedException | InterruptedException e)
    {
        logger.error("Could not send displayed notification", e);
    }
}
 
Example #3
Source File: OperationSetTypingNotificationsJabberImpl.java    From jitsi with Apache License 2.0 5 votes vote down vote up
@Override
        public void composingNotificationRequested(Jid from, String packetID,
            MessageEventManager messageEventManager)
        {
//            if(packetID != null)
//            {
//                String fromID = StringUtils.parseBareAddress(from);
//                packetIDsTable.put(fromID, packetID);
//            }
        }
 
Example #4
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 #5
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 #6
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);
    }

}
 
Example #7
Source File: OperationSetTypingNotificationsJabberImpl.java    From jitsi with Apache License 2.0 4 votes vote down vote up
/**
 * The method is called by a ProtocolProvider implementation whenver
 * a change in the registration state of the corresponding provider had
 * occurred.
 * @param evt ProviderStatusChangeEvent the event describing the status
 * change.
 */
public void registrationStateChanged(RegistrationStateChangeEvent evt)
{
    if (logger.isDebugEnabled())
        logger.debug("The provider changed state from: "
                 + evt.getOldState()
                 + " to: " + evt.getNewState());
    if (evt.getNewState() == RegistrationState.REGISTERED)
    {
        opSetPersPresence =
            (OperationSetPersistentPresenceJabberImpl) parentProvider
                .getOperationSet(OperationSetPersistentPresence.class);

        opSetBasicIM =
            (OperationSetBasicInstantMessagingJabberImpl)parentProvider
                .getOperationSet(
                    OperationSetBasicInstantMessaging.class);

        messageEventManager = MessageEventManager.getInstanceFor(
            parentProvider.getConnection());

        messageEventManager.addMessageEventRequestListener(
            new JabberMessageEventRequestListener());
        messageEventManager.addMessageEventNotificationListener(
            new IncomingMessageEventsListener());


        if(smackChatStateListener == null)
            smackChatStateListener = new SmackChatStateListener();

        parentProvider.getConnection().addAsyncStanzaListener(
            smackChatStateListener,
            new StanzaTypeFilter(Message.class));

    }
    else if(evt.getNewState() == RegistrationState.UNREGISTERED
         || evt.getNewState() == RegistrationState.AUTHENTICATION_FAILED
         || evt.getNewState() == RegistrationState.CONNECTION_FAILED)
    {
        if(parentProvider.getConnection() != null)
        {
            parentProvider.getConnection()
                .removeAsyncStanzaListener(smackChatStateListener);
        }

        smackChatStateListener = null;
        messageEventManager = null;
    }
}
 
Example #8
Source File: OperationSetTypingNotificationsJabberImpl.java    From jitsi with Apache License 2.0 4 votes vote down vote up
@Override
public void offlineNotificationRequested(Jid from, String packetID,
                                         MessageEventManager
                                         messageEventManager)
{}
 
Example #9
Source File: SparkManager.java    From Spark with Apache License 2.0 3 votes vote down vote up
/**
 * Returns the <code>MessageEventManager</code> used in Spark. The MessageEventManager is responsible
 * for XMPP specific operations such as notifying users that you have received their message or
 * inform a users that you are typing a message to them.
 *
 * @return the MessageEventManager used in Spark.
 */
public static MessageEventManager getMessageEventManager() {
    if (messageEventManager == null) {
        messageEventManager = MessageEventManager.getInstanceFor( getConnection() );
    }
    return messageEventManager;
}