Exemplo n.º 1
0
  public void notifyQueueStatus(JID sender, JID receiver, UserRequest request, boolean isPolling) {
    Packet statusPacket;
    if (isPolling) {
      statusPacket = new IQ();
    } else {
      statusPacket = new Message();
    }
    statusPacket.setFrom(sender);
    statusPacket.setTo(receiver);

    // Add Queue Status Packet to IQ
    Element status =
        statusPacket
            .getElement()
            .addElement("queue-status", "http://jabber.org/protocol/workgroup");

    // Add Time Element
    Element time = status.addElement("time");
    time.setText(Integer.toString(request.getTimeStatus()));

    // Add Position Element
    Element position = status.addElement("position");
    position.setText(Integer.toString(request.getPosition() + 1));
    status.add(request.getSessionElement());

    // Send the queue status
    request.getWorkgroup().send(statusPacket);
  }
 private void sendPacket(Packet packet) throws ComponentException {
   packet.setFrom(localServer);
   component.sendPacket(packet.createCopy());
 }