mil.navy.nps.bridge
Class Channel

java.lang.Object
  extended bymil.navy.nps.bridge.Channel
All Implemented Interfaces:
java.lang.Runnable

public class Channel
extends java.lang.Object
implements java.lang.Runnable


Field Summary
(package private)  java.util.HashSet clients
           
(package private)  java.net.InetAddress mcastAddress
           
(package private)  int port
           
(package private)  java.net.MulticastSocket sock
           
 
Constructor Summary
Channel(java.lang.String pMcastAddress, int pPort)
          Constructor; takes a multicast address and a port to listen on
 
Method Summary
 boolean equals(java.lang.Object pObject)
          A Channel object is equal to another channel object if it has the same multicast address and port to listen on.
 int hashCode()
          hascode, just the hashcode of the mcast address.
 void run()
          Implementation of the Runnable interface.
 void subscribeClient(Client pClient)
          Subscribe one client.
 void unsubscribeClient(Client pClient)
          Unsubscribe a client; this client will no longer receive packets that arrive on this mcast address.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mcastAddress

java.net.InetAddress mcastAddress

port

int port

sock

java.net.MulticastSocket sock

clients

java.util.HashSet clients
Constructor Detail

Channel

public Channel(java.lang.String pMcastAddress,
               int pPort)
Constructor; takes a multicast address and a port to listen on

Method Detail

hashCode

public int hashCode()
hascode, just the hashcode of the mcast address. Close enough. Note that this is not the same as equality...


equals

public boolean equals(java.lang.Object pObject)
A Channel object is equal to another channel object if it has the same multicast address and port to listen on.


subscribeClient

public void subscribeClient(Client pClient)
Subscribe one client. This client will receive, via unicast packets, the packets that arrive on them multicast address. (see observer pattern)


unsubscribeClient

public void unsubscribeClient(Client pClient)
Unsubscribe a client; this client will no longer receive packets that arrive on this mcast address. (see observer pattern)


run

public void run()
Implementation of the Runnable interface. Loops, reading from the multicast socket and forwarding to the list of clients.

Specified by:
run in interface java.lang.Runnable