コード例 #1
0
  /**
   * Method retrieves {@link BoshSession} related to the particular user address
   *
   * @param jid address for which {@link BoshSession} should be returned
   * @return a value of {@link BoshSession}
   */
  protected BoshSession getBoshSession(JID jid) {
    String res = jid.getResource();

    if (res != null) {
      UUID sid = UUID.fromString(res);

      return sessions.get(sid);
    }

    return null;
  }
コード例 #2
0
 /**
  * Method description
  *
  * @param jid
  * @return a value of <code>String</code>
  */
 protected String getServiceId(JID jid) {
   return jid.getResource();
 }
コード例 #3
0
  protected Map<String, String> preBindSession(Map<String, String> attr) {
    String hostname = attr.get(TO_ATTR);

    Queue<Packet> out_results = new ArrayDeque<Packet>(2);

    BoshSession bs =
        new BoshSession(
            getDefVHostItem().getDomain(),
            JID.jidInstanceNS(routings.computeRouting(hostname)),
            this,
            sendNodeHostname ? getDefHostName().getDomain() : null,
            maxSessionWaitingPackets);

    String jid = attr.get(FROM_ATTR);
    String uuid = UUID.randomUUID().toString();
    JID userId = JID.jidInstanceNS(jid);
    if (null == userId.getResource()) {
      userId = userId.copyWithResourceNS(uuid);
      attr.put(FROM_ATTR, userId.toString());
      bs.setUserJid(jid);
    }
    long rid = (long) (Math.random() * 10000000);

    attr.put(RID_ATTR, Long.toString(rid));

    UUID sid = bs.getSid();
    sessions.put(sid, bs);
    if (log.isLoggable(Level.FINE)) {
      log.log(
          Level.FINE,
          "{0} : {1} ({2})",
          new Object[] {BOSH_OPERATION_TYPE.CREATE, bs.getSid(), "Pre-bind"});
    }

    attr.put(SID_ATTR, sid.toString());

    Packet p = null;
    try {
      Element el = new Element("body");
      el.setAttributes(attr);
      p = Packet.packetInstance(el);
    } catch (TigaseStringprepException ex) {
      Logger.getLogger(BoshConnectionManager.class.getName()).log(Level.SEVERE, null, ex);
    }
    bs.init(
        p,
        null,
        max_wait,
        min_polling,
        max_inactivity,
        concurrent_requests,
        hold_requests,
        max_pause,
        max_batch_size,
        batch_queue_timeout,
        out_results,
        true);
    addOutPackets(out_results, bs);

    attr.put("hostname", getDefHostName().toString());

    return attr;
  }