de.anneck.jcast.core
Interface IChannel

All Known Subinterfaces:
IChannelThread

public interface IChannel

This specifies all core abilities of a JCast type Channel. The channel is part of the producer-bus-consumer pattern and provides the "bus" type features.

Author:
Andre Anneck
See Also:
MP3ChannelThread, SimpleChannelThread

Method Summary
 void add(IListener listener)
          Adds a JCast listener into the Channel.
 void add(IListener listener, ISource source)
          Adds a listener to a specific source.
 void add(ISource source)
          Adds JCast Sources into the Channel.
 java.lang.String getIdentifyingName()
          Returns the unique name for the Channel
 java.lang.String getListenerResponseHeader()
          Returns the current ListenerResponseHeader
 java.util.List getListeners()
          Returns a list of all listenes
 java.util.List getListeners(ISource source)
          Returns a list of all listeners, subscribed to source
 java.lang.String getSourceResponseHeader()
          Returns the current SourceResponseHeader
 java.util.List getSources()
          Returns a list of all sources
 void remove(IListener listener)
          Removes a listener form the Channel
 void remove(IListener listener, ISource source)
          Removes the listener from the specific source subscribtion list
 void remove(ISource source)
          Removes a source from the channel
 void send(byte[] b, ISource source)
          This send command will send the byte[] b to all listeners of ISource source.
 void setIdentifyingName(java.lang.String idName)
          Sets a unique name for a channel
 void setListenerResponseHeader(java.lang.String resHeader)
          Sets the response header to be send to listeners connecting to this channel
 void setSourceResponseHeader(java.lang.String resHeader)
          Sets the response header to be send to sources connecting to this channel
 

Method Detail

add

public void add(ISource source)
         throws ChannelException
Adds JCast Sources into the Channel.
Parameters:
source - The source to be added into the Channel. Has to implement ISource

remove

public void remove(ISource source)
            throws ChannelException
Removes a source from the channel

getSources

public java.util.List getSources()
Returns a list of all sources

add

public void add(IListener listener)
         throws ChannelException
Adds a JCast listener into the Channel.
Parameters:
listener - The listener to be added into the Channel. Has to implement IChannel

remove

public void remove(IListener listener)
            throws ChannelException
Removes a listener form the Channel

getListeners

public java.util.List getListeners()
Returns a list of all listenes

add

public void add(IListener listener,
                ISource source)
         throws ChannelException
Adds a listener to a specific source. This is the basic subscriber method for all listeners.
Parameters:
listener - The listener to be subscribed to the specified source.
source - The target source the listener is subscribed to.

remove

public void remove(IListener listener,
                   ISource source)
            throws ChannelException
Removes the listener from the specific source subscribtion list

getListeners

public java.util.List getListeners(ISource source)
Returns a list of all listeners, subscribed to source

send

public void send(byte[] b,
                 ISource source)
This send command will send the byte[] b to all listeners of ISource source. You use this method to send byte[] to the subscribed listeners.

 public class MySource implements ISource {

 .
 .
 .

 String helloStr = "hello";
 byte[] b = helloStr.toBytes();

 // I want to say hello to all my listeners.
 myChannel.send(b,this);

 .
 .
 .

 }
 
Parameters:
b - The byte[] array to be send to all subscribed listeners.
source - The source that sends the byte[].

setIdentifyingName

public void setIdentifyingName(java.lang.String idName)
Sets a unique name for a channel

getIdentifyingName

public java.lang.String getIdentifyingName()
Returns the unique name for the Channel

setListenerResponseHeader

public void setListenerResponseHeader(java.lang.String resHeader)
Sets the response header to be send to listeners connecting to this channel

getListenerResponseHeader

public java.lang.String getListenerResponseHeader()
Returns the current ListenerResponseHeader

setSourceResponseHeader

public void setSourceResponseHeader(java.lang.String resHeader)
Sets the response header to be send to sources connecting to this channel

getSourceResponseHeader

public java.lang.String getSourceResponseHeader()
Returns the current SourceResponseHeader