示例#1
0
  /**
   * @see net.sf.kraken.session.TransportSession#sendChatState(org.xmpp.packet.JID,
   *     net.sf.kraken.type.ChatStateType)
   */
  @Override
  public void sendChatState(JID jid, ChatStateType chatState) {
    final Presence presence = conn.getRoster().getPresence(jid.toString());
    if (presence == null || presence.getType().equals(Presence.Type.unavailable)) {
      // don't send chat state to contacts that are offline.
      return;
    }
    Chat chat = conn.getChatManager().createChat(getTransport().convertJIDToID(jid), listener);
    try {
      ChatState state = ChatState.active;
      switch (chatState) {
        case active:
          state = ChatState.active;
          break;
        case composing:
          state = ChatState.composing;
          break;
        case paused:
          state = ChatState.paused;
          break;
        case inactive:
          state = ChatState.inactive;
          break;
        case gone:
          state = ChatState.gone;
          break;
      }

      Message message = new Message();
      message.addExtension(new ChatStateExtension(state));
      chat.sendMessage(message);
    } catch (XMPPException e) {
      // Ignore
    }
  }
示例#2
0
 /** @see net.sf.kraken.session.TransportSession#sendMessage(org.xmpp.packet.JID, String) */
 @Override
 public void sendMessage(JID jid, String message) {
   Chat chat = conn.getChatManager().createChat(getTransport().convertJIDToID(jid), listener);
   try {
     chat.sendMessage(message);
   } catch (XMPPException e) {
     // Ignore
   }
 }
示例#3
0
 /**
  * @see net.sf.kraken.session.TransportSession#sendBuzzNotification(org.xmpp.packet.JID, String)
  */
 @Override
 public void sendBuzzNotification(JID jid, String message) {
   Chat chat = conn.getChatManager().createChat(getTransport().convertJIDToID(jid), listener);
   try {
     Message m = new Message();
     m.setTo(getTransport().convertJIDToID(jid));
     m.addExtension(new BuzzExtension());
     chat.sendMessage(m);
   } catch (XMPPException e) {
     // Ignore
   }
 }