Search in sources :

Example 6 with IConnection

use of org.red5.server.api.IConnection in project bigbluebutton by bigbluebutton.

the class VoiceConferenceApplication method appConnect.

@Override
public boolean appConnect(IConnection conn, Object[] params) {
    IServiceCapableConnection service = (IServiceCapableConnection) conn;
    log.debug("VoiceConferenceApplication appConnect[" + conn.getClient().getId() + "," + service + "]");
    return true;
}
Also used : IServiceCapableConnection(org.red5.server.api.service.IServiceCapableConnection)

Example 7 with IConnection

use of org.red5.server.api.IConnection 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 8 with IConnection

use of org.red5.server.api.IConnection 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 9 with IConnection

use of org.red5.server.api.IConnection 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 10 with IConnection

use of org.red5.server.api.IConnection 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

IConnection (org.red5.server.api.IConnection)33 HashMap (java.util.HashMap)8 IScope (org.red5.server.api.scope.IScope)7 Gson (com.google.gson.Gson)6 Matcher (java.util.regex.Matcher)4 IServiceCapableConnection (org.red5.server.api.service.IServiceCapableConnection)4 ClientBroadcastStream (org.red5.server.stream.ClientBroadcastStream)4 ArrayList (java.util.ArrayList)2 ISharedObject (org.red5.server.api.so.ISharedObject)2 IStreamListener (org.red5.server.api.stream.IStreamListener)2 ExecutionException (java.util.concurrent.ExecutionException)1 TimeoutException (java.util.concurrent.TimeoutException)1 IoBuffer (org.apache.mina.core.buffer.IoBuffer)1 ScreenshareStreamListener (org.bigbluebutton.app.screenshare.ScreenshareStreamListener)1 PeerNotFoundException (org.bigbluebutton.voiceconf.sip.PeerNotFoundException)1 ConnectionClientMethodInvoker (org.red5.app.sip.ConnectionClientMethodInvoker)1 RTMPMinaConnection (org.red5.server.net.rtmp.RTMPMinaConnection)1 VideoData (org.red5.server.net.rtmp.event.VideoData)1