Ejemplo n.º 1
0
 public void interceptPacket(Packet packet) {
   Message message = (Message) packet;
   Chat chat = connection.getChatManager().getThreadChat(message.getThread());
   if (chat == null) {
     return;
   }
   if (updateChatState(chat, ChatState.active)) {
     message.addExtension(new ChatStateExtension(ChatState.active));
   }
 }
Ejemplo n.º 2
0
  /**
   * Sets the current state of the provided chat. This method will send an empty bodied Message
   * packet with the state attached as a {@link z.org.jivesoftware.smack.packet.PacketExtension}, if
   * and only if the new chat state is different than the last state.
   *
   * @param newState the new state of the chat
   * @param chat the chat.
   * @throws z.org.jivesoftware.smack.XMPPException when there is an error sending the message
   *     packet.
   */
  public void setCurrentState(ChatState newState, Chat chat) throws XMPPException {
    if (chat == null || newState == null) {
      throw new IllegalArgumentException("Arguments cannot be null.");
    }
    if (!updateChatState(chat, newState)) {
      return;
    }
    Message message = new Message();
    ChatStateExtension extension = new ChatStateExtension(newState);
    message.addExtension(extension);

    chat.sendMessage(message);
  }