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;
}
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();
}
}
}
}
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();
}
}
}
}
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();
}
}
}
}
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);
}
}
Aggregations