org.red5.server.api.event.IEvent Java Examples

The following examples show how to use org.red5.server.api.event.IEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RTMPConnection.java    From red5-server-common with Apache License 2.0 6 votes vote down vote up
/**
 * Dispatches event
 * 
 * @param event
 *            Event
 */
@Override
public void dispatchEvent(IEvent event) {
    if (log.isDebugEnabled()) {
        log.debug("Event notify: {}", event);
    }
    // determine if its an outgoing invoke or notify
    switch (event.getType()) {
        case CLIENT_INVOKE:
            ClientInvokeEvent cie = (ClientInvokeEvent) event;
            invoke(cie.getMethod(), cie.getParams(), cie.getCallback());
            break;
        case CLIENT_NOTIFY:
            ClientNotifyEvent cne = (ClientNotifyEvent) event;
            notify(cne.getMethod(), cne.getParams());
            break;
        default:
            log.warn("Unhandled event: {}", event);
    }
}
 
Example #2
Source File: Scope.java    From red5-server-common with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public void dispatchEvent(IEvent event) {
    Set<IConnection> conns = getClientConnections();
    for (IConnection conn : conns) {
        try {
            conn.dispatchEvent(event);
        } catch (RuntimeException e) {
            log.error("Exception during dispatching event: {}", event, e);
        }
    }
}
 
Example #3
Source File: StreamRelay.java    From red5-client with Apache License 2.0 5 votes vote down vote up
@Override
public void dispatchEvent(IEvent event) {
    System.out.println("ClientStream.dispachEvent()" + event.toString());
    try {
        proxy.pushMessage(null, RTMPMessage.build((IRTMPEvent) event));
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
Example #4
Source File: BaseRTMPClientHandler.java    From red5-client with Apache License 2.0 5 votes vote down vote up
@Override
public void dispatchEvent(IEvent event) {
    log.debug("NetStream dispatchEvent: {}", event);
    if (dispatcher != null) {
        dispatcher.dispatchEvent(event);
    }
}
 
Example #5
Source File: BasicScope.java    From red5-server-common with Apache License 2.0 5 votes vote down vote up
/**
 * Dispatches event (notifies all listeners)
 *
 * @param event Event to dispatch
 */
public void dispatchEvent(IEvent event) {
    for (IEventListener listener : listeners) {
        if (event.getSource() == null || event.getSource() != listener) {
            listener.notifyEvent(event);
        }
    }
}
 
Example #6
Source File: RTMPTClientTest.java    From red5-client with Apache License 2.0 4 votes vote down vote up
@Override
public void dispatchEvent(IEvent event) {
    System.out.println("ClientStream.dispachEvent()" + event.toString());
}
 
Example #7
Source File: RTMPTSClientTest.java    From red5-client with Apache License 2.0 4 votes vote down vote up
@Override
public void dispatchEvent(IEvent event) {
    System.out.println("ClientStream.dispachEvent()" + event.toString());
}
 
Example #8
Source File: ClientTest.java    From red5-client with Apache License 2.0 4 votes vote down vote up
@Override
public void dispatchEvent(IEvent event) {
    System.out.println("ClientStream.dispachEvent()" + event.toString());
}
 
Example #9
Source File: ClientSharedObject.java    From red5-server-common with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
public synchronized void dispatchEvent(IEvent e) {
    if (e instanceof ISharedObjectMessage || e.getType() == IEvent.Type.SHARED_OBJECT) {
        try {
            ISharedObjectMessage msg = (ISharedObjectMessage) e;
            if (msg.hasSource()) {
                beginUpdate(msg.getSource());
            } else {
                beginUpdate();
            }
            for (ISharedObjectEvent event : msg.getEvents()) {
                switch (event.getType()) {
                    case CLIENT_INITIAL_DATA:
                        initialSyncReceived = true;
                        notifyConnect();
                        break;
                    case CLIENT_CLEAR_DATA:
                        attributes.clear();
                        notifyClear();
                        break;
                    case CLIENT_DELETE_DATA:
                    case CLIENT_DELETE_ATTRIBUTE:
                        attributes.remove(event.getKey());
                        notifyDelete(event.getKey());
                        break;
                    case CLIENT_SEND_MESSAGE:
                        notifySendMessage(event.getKey(), (List<?>) event.getValue());
                        break;
                    case CLIENT_UPDATE_DATA:
                        attributes.putAll((Map<String, Object>) event.getValue());
                        notifyUpdate(event.getKey(), (Map<String, Object>) event.getValue());
                        break;
                    case CLIENT_UPDATE_ATTRIBUTE:
                        Object val = event.getValue();
                        // null values are not allowed in concurrent hash maps
                        if (val != null) {
                            attributes.put(event.getKey(), val);
                        }
                        // we will however send the null out to the subscribers
                        notifyUpdate(event.getKey(), val);
                        break;
                    default:
                        log.warn("Unknown SO event: {}", event.getType());
                }
            }
        } finally {
            endUpdate();
        }
    }
}
 
Example #10
Source File: SharedObjectScope.java    From red5-server-common with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override
public void dispatchEvent(IEvent e) {
    if (e instanceof ISharedObjectMessage || e.getType() == IEvent.Type.SHARED_OBJECT) {
        try {
            IEventListener source = null;
            ISharedObjectMessage msg = (ISharedObjectMessage) e;
            if (msg.hasSource()) {
                source = msg.getSource();
                beginUpdate(source);
            } else {
                beginUpdate();
            }
            for (ISharedObjectEvent event : msg.getEvents()) {
                final String key = event.getKey();
                switch (event.getType()) {
                    case SERVER_CONNECT:
                        if (!isConnectionAllowed()) {
                            so.get().returnError(SO_NO_READ_ACCESS);
                        } else if (source != null) {
                            if (source instanceof BaseConnection) {
                                ((BaseConnection) source).registerBasicScope(this);
                            } else {
                                addEventListener(source);
                            }
                        }
                        break;
                    case SERVER_DISCONNECT:
                        if (source != null) {
                            if (source instanceof BaseConnection) {
                                ((BaseConnection) source).unregisterBasicScope(this);
                            } else {
                                removeEventListener(source);
                            }
                        }
                        break;
                    case SERVER_SET_ATTRIBUTE:
                        final Object value = event.getValue();
                        if (!isWriteAllowed(key, value)) {
                            // adds an owner event
                            //so.get().returnAttributeValue(key);
                            so.get().returnError(SO_NO_WRITE_ACCESS);
                        } else {
                            setAttribute(key, value);
                        }
                        break;
                    case SERVER_DELETE_ATTRIBUTE:
                        if (!isDeleteAllowed(key)) {
                            //so.get().returnAttributeValue(key);
                            so.get().returnError(SO_NO_WRITE_ACCESS);
                        } else {
                            removeAttribute(key);
                        }
                        break;
                    case SERVER_SEND_MESSAGE:
                        final List<?> arguments = (List<?>) event.getValue();
                        // Ignore request silently if not allowed
                        if (isSendAllowed(key, arguments)) {
                            sendMessage(key, arguments);
                        } else {
                            log.debug("Send is not allowed for {}", key);
                        }
                        break;
                    default:
                        log.warn("Unknown SO event: {}", event.getType());
                }
            }
        } finally {
            endUpdate();
        }
    } else {
        // don't know how to handle this event
        super.dispatchEvent(e);
    }
}
 
Example #11
Source File: AbstractScopeAdapter.java    From red5-server-common with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
public boolean handleEvent(IEvent event) {
    return canHandleEvent;
}
 
Example #12
Source File: MultiThreadedApplicationAdapter.java    From red5-server-common with Apache License 2.0 4 votes vote down vote up
@Override
public boolean handleEvent(IEvent event) {
    log.debug("handleEvent: {}", event);
    return super.handleEvent(event);
}
 
Example #13
Source File: BasicScope.java    From red5-server-common with Apache License 2.0 2 votes vote down vote up
/**
 * Handles event. To be implemented in subclass realization
 *
 * @param event Event context
 * @return Event handling result
 */
public boolean handleEvent(IEvent event) {
    return false;
}
 
Example #14
Source File: ClientBroadcastStream.java    From red5-server-common with Apache License 2.0 2 votes vote down vote up
/**
 * Check and send notification if necessary
 * 
 * @param event
 *            Event
 */
private void checkSendNotifications(IEvent event) {
    IEventListener source = event.getSource();
    sendStartNotifications(source);
}
 
Example #15
Source File: Scope.java    From red5-server-common with Apache License 2.0 2 votes vote down vote up
/**
 * Handles event. To be implemented in subclasses.
 * 
 * @param event
 *            Event to handle
 * @return true on success, false otherwise
 */
@Override
public boolean handleEvent(IEvent event) {
    return false;
}
 
Example #16
Source File: BaseConnection.java    From red5-server-common with Apache License 2.0 2 votes vote down vote up
/**
 * Handles event
 * 
 * @param event
 *            Event
 * @return true if associated scope was able to handle event, false otherwise
 */
public boolean handleEvent(IEvent event) {
    return getScope().handleEvent(event);
}
 
Example #17
Source File: BaseConnection.java    From red5-server-common with Apache License 2.0 2 votes vote down vote up
/**
 * Dispatches event
 * 
 * @param event
 *            Event
 */
public void dispatchEvent(IEvent event) {
    log.debug("Event notify was not dispatched: {}", event);
}
 
Example #18
Source File: BaseConnection.java    From red5-server-common with Apache License 2.0 2 votes vote down vote up
/**
 * Notified on event
 * 
 * @param event
 *            Event
 */
public void notifyEvent(IEvent event) {
    log.debug("Event notify was not handled: {}", event);
}
 
Example #19
Source File: BasicScope.java    From red5-server-common with Apache License 2.0 votes vote down vote up
/**
 * Notifies listeners on event. Current implementation is empty. To be implemented in subclass realization
 * 
 * @param event Event to broadcast
 */
public void notifyEvent(IEvent event) {

}
 
Example #20
Source File: IEventSink.java    From red5-rtsp-restreamer with Apache License 2.0 votes vote down vote up
public void dispatchEvent(IEvent event);