Esempio n. 1
0
  private void handleMuteIq(MuteIq muteIq) {
    Boolean doMute = muteIq.getMute();
    String jid = muteIq.getJid();

    if (doMute == null || StringUtils.isNullOrEmpty(jid)) return;

    String from = muteIq.getFrom();
    JitsiMeetConference conference = getConferenceForMucJid(from);
    if (conference == null) {
      logger.debug("Mute error: room not found for JID: " + from);
      return;
    }

    IQ result;

    if (conference.handleMuteRequest(muteIq.getFrom(), jid, doMute)) {
      result = IQ.createResultIQ(muteIq);

      if (!muteIq.getFrom().equals(jid)) {
        MuteIq muteStatusUpdate = new MuteIq();
        muteStatusUpdate.setType(IQ.Type.SET);
        muteStatusUpdate.setTo(jid);

        muteStatusUpdate.setMute(doMute);

        smackXmpp.getXmppConnection().sendPacket(muteStatusUpdate);
      }
    } else {
      result =
          IQ.createErrorResponse(muteIq, new XMPPError(XMPPError.Condition.interna_server_error));
    }

    smackXmpp.getXmppConnection().sendPacket(result);
  }
  /**
   * Implements {@link PacketListener}. Notifies this instance that a specific {@link Packet} (which
   * this instance has already expressed interest into by returning <tt>true</tt> from {@link
   * #accept(Packet)}) has been received.
   *
   * @param packet the <tt>Packet</tt> which has been received and which this instance is given a
   *     chance to process
   */
  public void processPacket(Packet packet) {
    /*
     * As we do elsewhere, acknowledge the receipt of the Packet first and
     * then go about our business with it.
     */
    IQ iq = (IQ) packet;

    if (iq.getType() == IQ.Type.SET)
      protocolProvider.getConnection().sendPacket(IQ.createResultIQ(iq));

    /*
     * Now that the acknowledging is out of the way, do go about our
     * business with the Packet.
     */
    ColibriConferenceIQ conferenceIQ = (ColibriConferenceIQ) iq;
    boolean interrupted = false;

    try {
      processColibriConferenceIQ(conferenceIQ);
    } catch (Throwable t) {
      logger.error(
          "An error occurred during the processing of a " + packet.getClass().getName() + " packet",
          t);

      if (t instanceof InterruptedException) {
        /*
         * We cleared the interrupted state of the current Thread by
         * catching the InterruptedException. However, we do not really
         * care whether the current Thread has been interrupted - we
         * caught the InterruptedException because we want to swallow
         * any Throwable. Consequently, we should better restore the
         * interrupted state.
         */
        interrupted = true;
      } else if (t instanceof ThreadDeath) throw (ThreadDeath) t;
    }
    if (interrupted) Thread.currentThread().interrupt();
  }