Purple Code

com.purpletech.message.server
Class Splitter

java.lang.Object
  |
  +--com.purpletech.message.server.Splitter
All Implemented Interfaces:
MessageServerListener

public class Splitter
extends java.lang.Object
implements MessageServerListener

The splitter takes a message and multicasts it -- makes N new messages for each of its N clients and adds them back to the queue.

A "chat channel" client could either subclass or own this object.

Version:
$Id: Splitter.java,v 1.2 2001/10/30 12:20:52 alex Exp $
Author:
Alex

Field Summary
protected  ClientSet clients
           
 boolean copyWhenCreated
           
protected  Queue messages
           
 
Constructor Summary
Splitter(Queue messages, ClientSet clientsInitial)
           
 
Method Summary
 void addClient(Client c)
           
 void clientAdded(MessageServerEvent e)
           
 void clientRemoved(MessageServerEvent e)
           
 void removeClient(Client c)
           
 void sendMessage(Message m)
          must be synchronized to avoid collision with addClient and removeClient -- we don't want the iterator to fail-fast, now, do we?
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

messages

protected Queue messages

clients

protected ClientSet clients

copyWhenCreated

public boolean copyWhenCreated
Constructor Detail

Splitter

public Splitter(Queue messages,
                ClientSet clientsInitial)
Method Detail

addClient

public void addClient(Client c)

removeClient

public void removeClient(Client c)

sendMessage

public void sendMessage(Message m)
must be synchronized to avoid collision with addClient and removeClient -- we don't want the iterator to fail-fast, now, do we?


clientAdded

public void clientAdded(MessageServerEvent e)
Specified by:
clientAdded in interface MessageServerListener

clientRemoved

public void clientRemoved(MessageServerEvent e)
Specified by:
clientRemoved in interface MessageServerListener

Documentation generated March 5 2003