Package org.red5.server.messaging
Class AbstractPipe
java.lang.Object
org.red5.server.messaging.AbstractPipe
- All Implemented Interfaces:
IMessageInput
,IMessageOutput
,IPipe
- Direct Known Subclasses:
InMemoryPullPullPipe
,InMemoryPushPushPipe
Abstract pipe that books providers/consumers and listeners. Aim to ease the implementation of concrete pipes. For more information on what pipe is, see IPipe interface documentation.
- Author:
- The Red5 Project, Steven Gong (steven.gong@gmail.com)
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprotected CopyOnWriteArrayList<IConsumer>
Pipe consumers listprotected CopyOnWriteArrayList<IPipeConnectionListener>
Event listenersprivate static final org.slf4j.Logger
protected CopyOnWriteArrayList<IProvider>
Pipe providers listprivate static ExecutorService
Executor service used to run pipe tasks. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Registers pipe connect events listenervoid
close()
Close the pipeprotected void
fireConsumerConnectionEvent
(IConsumer consumer, PipeConnectionEvent.EventType type, Map<String, Object> paramMap) Broadcast consumer connection eventprotected void
Fire any pipe connection event and run all it's tasksprotected void
fireProviderConnectionEvent
(IProvider provider, PipeConnectionEvent.EventType type, Map<String, Object> paramMap) Broadcast provider connection eventGetter for consumersGetter for pipe connection events listenersGetter for providersvoid
Removes pipe connection listenervoid
sendOOBControlMessage
(IConsumer consumer, OOBControlMessage oobCtrlMsg) Send out-of-band ("special") control message to all providersvoid
sendOOBControlMessage
(IProvider provider, OOBControlMessage oobCtrlMsg) Send out-of-band ("special") control message to all consumersvoid
setListeners
(List<IPipeConnectionListener> newListeners) Setter for pipe connection events listenersboolean
Connect consumer to this pipe.boolean
Connect provider to this pipe.boolean
unsubscribe
(IConsumer consumer) Disconnects consumer from this pipe.boolean
unsubscribe
(IProvider provider) Disconnects provider from this pipe.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.red5.server.messaging.IMessageInput
pullMessage, pullMessage
Methods inherited from interface org.red5.server.messaging.IMessageOutput
pushMessage
-
Field Details
-
log
private static final org.slf4j.Logger log -
consumers
Pipe consumers list -
providers
Pipe providers list -
listeners
Event listeners -
taskExecutor
Executor service used to run pipe tasks.
-
-
Constructor Details
-
AbstractPipe
public AbstractPipe()
-
-
Method Details
-
subscribe
Connect consumer to this pipe. Doesn't allow to connect one consumer twice. Does register event listeners if instance of IPipeConnectionListener is given.- Specified by:
subscribe
in interfaceIMessageInput
- Parameters:
consumer
- ConsumerparamMap
- Parameters passed with connection, used in concrete pipe implementations- Returns:
- true if consumer was added, false otherwise
-
subscribe
Connect provider to this pipe. Doesn't allow to connect one provider twice. Does register event listeners if instance of IPipeConnectionListener is given.- Specified by:
subscribe
in interfaceIMessageOutput
- Parameters:
provider
- ProviderparamMap
- Parameters passed with connection, used in concrete pipe implementations- Returns:
- true if provider was added, false otherwise
-
unsubscribe
Disconnects provider from this pipe. Fires pipe connection event.- Specified by:
unsubscribe
in interfaceIMessageOutput
- Parameters:
provider
- Provider that should be removed- Returns:
- true on success, false otherwise
-
unsubscribe
Disconnects consumer from this pipe. Fires pipe connection event.- Specified by:
unsubscribe
in interfaceIMessageInput
- Parameters:
consumer
- Consumer that should be removed- Returns:
- true on success, false otherwise
-
addPipeConnectionListener
Registers pipe connect events listener- Specified by:
addPipeConnectionListener
in interfaceIPipe
- Parameters:
listener
- Listener
-
removePipeConnectionListener
Removes pipe connection listener- Specified by:
removePipeConnectionListener
in interfaceIPipe
- Parameters:
listener
- Listener
-
sendOOBControlMessage
Send out-of-band ("special") control message to all consumers- Specified by:
sendOOBControlMessage
in interfaceIMessageOutput
- Parameters:
provider
- Provider, may be used in concrete implementationsoobCtrlMsg
- Out-of-band control message
-
sendOOBControlMessage
Send out-of-band ("special") control message to all providers- Specified by:
sendOOBControlMessage
in interfaceIMessageInput
- Parameters:
consumer
- Consumer, may be used in concrete implementationsoobCtrlMsg
- Out-of-band control message
-
getListeners
Getter for pipe connection events listeners- Returns:
- Listeners
-
setListeners
Setter for pipe connection events listeners- Parameters:
newListeners
- Listeners
-
getProviders
Getter for providers- Specified by:
getProviders
in interfaceIMessageOutput
- Returns:
- Providers list
-
getConsumers
Getter for consumers- Specified by:
getConsumers
in interfaceIMessageInput
- Returns:
- consumers list
-
fireConsumerConnectionEvent
protected void fireConsumerConnectionEvent(IConsumer consumer, PipeConnectionEvent.EventType type, Map<String, Object> paramMap) Broadcast consumer connection event- Parameters:
consumer
- Consumer that has connectedtype
- Event typeparamMap
- Parameters passed with connection
-
fireProviderConnectionEvent
protected void fireProviderConnectionEvent(IProvider provider, PipeConnectionEvent.EventType type, Map<String, Object> paramMap) Broadcast provider connection event- Parameters:
provider
- Provider that has connectedtype
- Event typeparamMap
- Parameters passed with connection
-
firePipeConnectionEvent
Fire any pipe connection event and run all it's tasks- Parameters:
event
- Pipe connection event
-
close
public void close()Close the pipe
-