Ejemplo n.º 1
0
  @Override
  public void sendMessage(final FriendMessage message) {

    HashMap<String, Friend> friends = AccountManager.getInstance().getFriends();
    Friend friend = friends.get(message.getTo());
    Screenname buddy = new Screenname(friend.getUserName());
    Conversation c = (Conversation) friend.getUserInfo();
    if (c == null) {
      c = connection.getIcbmService().getImConversation(buddy);
      friend.setUserInfo(c);
    }
    Message oscarMessage =
        new Message() {

          public boolean isAutoResponse() {
            return false;
          }

          public String getMessageBody() {
            return message.getMessage();
          }
        };
    c.sendMessage(oscarMessage);
    Friend recipient = friends.get(message.getTo());
    accountListener.didReceiveMessageForFriend(message, recipient);
  }
Ejemplo n.º 2
0
 private void removeUnused() {
   Conversation[] cons = getArray();
   for (int i = 0; i < cons.length; i++) {
     Conversation c = cons[i];
     if (!c.isUsed()) {
       removeConversation(c.getRmt_ip(), c.getLcl_port(), c.getRmt_port());
     }
   }
 }
Ejemplo n.º 3
0
  public void readIn(DataInputStream din) throws IOException {
    Iterator it = allConversations.iterator();
    while (it.hasNext()) {
      Conversation conv = (Conversation) it.next();
      conv.setUsed(false);
    }

    int count = din.readInt();
    for (int i = 0; i < count; i++) {
      readConv.readIn(din);
      Conversation existing =
          findConversation(readConv.getRmt_ip(), readConv.getLcl_port(), readConv.getRmt_port());
      existing.setUsed(true);
      existing.setInfo(readConv);
    }
    removeUnused();
  }
Ejemplo n.º 4
0
  private void gc() {
    if (gcTime == -1) {
      return;
    }

    long curTime = System.currentTimeMillis();

    if ((curTime - lastTime) > gcTime) {
      int collected = 0;
      lastTime = curTime;

      Conversation[] cons = getArray();
      for (int i = 0; i < cons.length; i++) {
        Conversation c = cons[i];

        long l = c.getLastActive();
        if ((curTime - l) > convTime) {
          collected++;
          removeConversation(c.getRmt_ip(), c.getLcl_port(), c.getRmt_port());
        }
      }
    }
  }