|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.miv.mbox.net.Sender
public class Sender
Sends messages to message boxes.
A sender is an object able to send data to another host on a given port. It is not necessary to create a distinct sender for each object we want to send data to (and it would be a loss of space), only for each host and port we need to send data to.
The SenderPool allows to remember a set of senders
toward several hosts and ports. It can also create them.
Senders send data synchronously, that is, you wait while the data is sent, however you do not wait until the data is received.
SenderPool| Field Summary | |
|---|---|
protected ByteArrayOutputStream |
byteArrayOut
Byte output stream. |
protected boolean |
debug
Echo debugging messages?. |
protected byte[] |
header
Oh?!. |
protected static String |
LIGHT_GREEN
|
protected MBoxLocator |
locator
Locator of the distant message box. |
protected ObjectOutputStream |
objectOut
Object output stream. |
protected int |
reset
Ah?!. |
protected static String |
RESET
|
protected SocketChannel |
socket
Socket to the receiver. |
| Constructor Summary | |
|---|---|
Sender(MBoxLocator locator)
New sender toward the given receiver. |
|
Sender(MBoxLocator locator,
boolean debug)
New sender toward the given receiver. |
|
| Method Summary | |
|---|---|
protected void |
debug(String message,
Object... data)
|
MBoxLocator |
getLocator()
Locator of the distant receiver. |
void |
send(Packet packet)
Send a data packet. |
void |
send(String from,
String to,
Object... messages)
Send a message. |
void |
setDebugOn(boolean on)
Enable or disable debugging. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected SocketChannel socket
protected MBoxLocator locator
protected ObjectOutputStream objectOut
protected ByteArrayOutputStream byteArrayOut
protected boolean debug
protected int reset
protected byte[] header
protected static final String LIGHT_GREEN
protected static final String RESET
| Constructor Detail |
|---|
public Sender(MBoxLocator locator)
throws IOException,
UnknownHostException
locator - MBoxLocator of the receiver.
IOException
UnknownHostException
public Sender(MBoxLocator locator,
boolean debug)
throws IOException,
UnknownHostException
locator - MBoxLocator of the receiver.debug - Enable or disable debugging outputs on the console.
IOException
UnknownHostException| Method Detail |
|---|
public MBoxLocator getLocator()
public void setDebugOn(boolean on)
public void send(String from,
String to,
Object... messages)
throws IOException
from - Sender identifier.to - Receiver identifier.messages - Message parameters.
IOException
public void send(Packet packet)
throws IOException
send(String, String, Object[]) method uses it.
packet - The already packed message to send.
IOException
protected void debug(String message,
Object... data)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||