Search in sources :

Example 16 with IScope

use of org.red5.server.api.scope.IScope in project bigbluebutton by bigbluebutton.

the class ParticipantsService method getParticipants.

public void getParticipants() {
    IScope scope = Red5.getConnectionLocal().getScope();
    String meetingId = scope.getName();
    String userId = getBbbSession().getInternalUserID();
    red5InGW.getUsers(meetingId, userId);
}
Also used : IScope(org.red5.server.api.scope.IScope)

Example 17 with IScope

use of org.red5.server.api.scope.IScope in project bigbluebutton by bigbluebutton.

the class ConnectionInvokerService method handlDisconnectClientMessage.

private void handlDisconnectClientMessage(DisconnectClientMessage msg) {
    IScope meetingScope = getScope(msg.getMeetingId());
    if (meetingScope != null) {
        String userId = msg.getUserId();
        IConnection conn = getConnection(meetingScope, userId);
        if (conn != null) {
            if (conn.isConnected()) {
                log.info("Disconnecting user=[{}] from meeting=[{}]", msg.getUserId(), msg.getMeetingId());
                conn.close();
            }
        }
    }
}
Also used : IScope(org.red5.server.api.scope.IScope) IConnection(org.red5.server.api.IConnection)

Example 18 with IScope

use of org.red5.server.api.scope.IScope in project bigbluebutton by bigbluebutton.

the class ConnectionInvokerService method handleDisconnectAllClientsMessage.

private void handleDisconnectAllClientsMessage(DisconnectAllClientsMessage msg) {
    IScope meetingScope = getScope(msg.getMeetingId());
    if (meetingScope != null) {
        Set<IConnection> conns = meetingScope.getClientConnections();
        for (IConnection conn : conns) {
            if (conn.isConnected()) {
                String connId = (String) conn.getAttribute("INTERNAL_USER_ID");
                log.info("Disconnecting client=[{}] from meeting=[{}]", connId, msg.getMeetingId());
                conn.close();
            }
        }
    }
}
Also used : IScope(org.red5.server.api.scope.IScope) IConnection(org.red5.server.api.IConnection)

Example 19 with IScope

use of org.red5.server.api.scope.IScope in project bigbluebutton by bigbluebutton.

the class ConnectionInvokerService method handleDisconnectAllMessage.

private void handleDisconnectAllMessage(DisconnectAllMessage msg) {
    IScope meetingScope = bbbAppScope.getContext().resolveScope("bigbluebutton");
    if (meetingScope != null) {
        Set<IConnection> conns = meetingScope.getClientConnections();
        for (IConnection conn : conns) {
            if (conn.isConnected()) {
                String connId = (String) conn.getAttribute("INTERNAL_USER_ID");
                log.info("Disconnecting client=[{}] as bbb-apps isn't running.", connId);
                conn.close();
            }
        }
    }
}
Also used : IScope(org.red5.server.api.scope.IScope) IConnection(org.red5.server.api.IConnection)

Example 20 with IScope

use of org.red5.server.api.scope.IScope in project bigbluebutton by bigbluebutton.

the class ConnectionInvokerService method sendDirectMessage.

private void sendDirectMessage(final DirectClientMessage msg) {
    if (log.isTraceEnabled()) {
        Gson gson = new Gson();
        String json = gson.toJson(msg.getMessage());
        log.trace("Handle direct message: " + msg.getMessageName() + " msg=" + json);
    }
    final String userId = msg.getUserID();
    Runnable sender = new Runnable() {

        public void run() {
            IScope meetingScope = getScope(msg.getMeetingID());
            if (meetingScope != null) {
                IConnection conn = getConnection(meetingScope, userId);
                if (conn != null) {
                    if (conn.isConnected()) {
                        List<Object> params = new ArrayList<Object>();
                        params.add(msg.getMessageName());
                        params.add(msg.getMessage());
                        if (log.isTraceEnabled()) {
                            Gson gson = new Gson();
                            String json = gson.toJson(msg.getMessage());
                            log.debug("Send direct message: " + msg.getMessageName() + " msg=" + json);
                        }
                        ServiceUtils.invokeOnConnection(conn, "onMessageFromServer", params.toArray());
                    }
                } else {
                    log.info("Cannot send message=[" + msg.getMessageName() + "] to [" + userId + "] as no such session on meeting=[" + msg.getMeetingID() + "]");
                }
            }
        }
    };
    /**
     * We need to add a way to cancel sending when the thread is blocked.
     * Red5 uses a semaphore to guard the rtmp connection and we've seen
     * instances where our thread is blocked preventing us from sending messages
     * to other connections. (ralam nov 19, 2015)
     */
    long endNanos = System.nanoTime() + SEND_TIMEOUT;
    Future<?> f = runExec.submit(sender);
    try {
        // Only wait for the remaining time budget         
        long timeLeft = endNanos - System.nanoTime();
        f.get(timeLeft, TimeUnit.NANOSECONDS);
    } catch (ExecutionException e) {
        log.warn("ExecutionException while sending direct message on connection[" + userId + "]");
        log.warn("ExcecutionException cause: " + e.getMessage());
    } catch (InterruptedException e) {
        log.warn("Interrupted exception while sending direct message on connection[" + userId + "]");
        Thread.currentThread().interrupt();
    } catch (TimeoutException e) {
        log.warn("Timeout exception while sending direct message on connection[" + userId + "]");
        f.cancel(true);
    }
}
Also used : ArrayList(java.util.ArrayList) Gson(com.google.gson.Gson) IConnection(org.red5.server.api.IConnection) IScope(org.red5.server.api.scope.IScope) ISharedObject(org.red5.server.api.so.ISharedObject) ExecutionException(java.util.concurrent.ExecutionException) TimeoutException(java.util.concurrent.TimeoutException)

Aggregations

IScope (org.red5.server.api.scope.IScope)27 IConnection (org.red5.server.api.IConnection)9 ISharedObject (org.red5.server.api.so.ISharedObject)5 ArrayList (java.util.ArrayList)4 Gson (com.google.gson.Gson)3 ExecutionException (java.util.concurrent.ExecutionException)2 TimeoutException (java.util.concurrent.TimeoutException)2 HashMap (java.util.HashMap)1 IoBuffer (org.apache.mina.core.buffer.IoBuffer)1 AudioStream (org.red5.app.sip.AudioStream)1 IContext (org.red5.server.api.IContext)1 IServiceCapableConnection (org.red5.server.api.service.IServiceCapableConnection)1 IBroadcastStream (org.red5.server.api.stream.IBroadcastStream)1 IStreamListener (org.red5.server.api.stream.IStreamListener)1 IStreamPacket (org.red5.server.api.stream.IStreamPacket)1 AudioData (org.red5.server.net.rtmp.event.AudioData)1 IProviderService (org.red5.server.stream.IProviderService)1