Package org.jgroups.demos
Class PubServer
- java.lang.Object
-
- org.jgroups.blocks.cs.ReceiverAdapter
-
- org.jgroups.demos.PubServer
-
- All Implemented Interfaces:
Receiver
public class PubServer extends ReceiverAdapter
Demo which starts anNioServer
that accepts messages from clients (PubClient
) and forwards them to all connected clients- Since:
- 3.6.5
- Author:
- Bela Ban
-
-
Field Summary
Fields Modifier and Type Field Description protected Log
log
protected BaseServer
server
-
Constructor Summary
Constructors Constructor Description PubServer()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static void
help()
static void
main(java.lang.String[] args)
void
receive(Address sender, byte[] buf, int offset, int length)
Delivers a message from a given sender to the applicationvoid
receive(Address sender, java.io.DataInput in)
void
receive(Address sender, java.nio.ByteBuffer buf)
The default implementation assumes thatByteBuffer.flip()
orByteBuffer.rewind()
was called on buf before invoking this callbackprotected void
start(java.net.InetAddress bind_addr, int port, boolean nio)
-
-
-
Field Detail
-
server
protected BaseServer server
-
log
protected final Log log
-
-
Method Detail
-
start
protected void start(java.net.InetAddress bind_addr, int port, boolean nio) throws java.lang.Exception
- Throws:
java.lang.Exception
-
receive
public void receive(Address sender, java.nio.ByteBuffer buf)
Description copied from class:ReceiverAdapter
The default implementation assumes thatByteBuffer.flip()
orByteBuffer.rewind()
was called on buf before invoking this callback- Specified by:
receive
in interfaceReceiver
- Overrides:
receive
in classReceiverAdapter
- Parameters:
sender
- The sender of the messagebuf
- The buffer. An application typically de-serializes data from the buffer into objects used by the application. Note that when receive() returns, it is not safe to use the buffer any longer; if an application needs to use a buffer after this callback returns, it must make a copy. Note that buf could be a direct ByteBuffer.
-
receive
public void receive(Address sender, byte[] buf, int offset, int length)
Description copied from interface:Receiver
Delivers a message from a given sender to the application- Specified by:
receive
in interfaceReceiver
- Overrides:
receive
in classReceiverAdapter
- Parameters:
sender
- The sender of the messagebuf
- The buffer. An application typically de-serializes data from the buffer into objects used by the application. Note that when receive() returns, it is not safe to use the buffer any longer; if an application needs to use a buffer after this callback returns, it must make a copy.offset
- The offset at which the received data startslength
- The length of the received data
-
receive
public void receive(Address sender, java.io.DataInput in) throws java.lang.Exception
- Specified by:
receive
in interfaceReceiver
- Overrides:
receive
in classReceiverAdapter
- Throws:
java.lang.Exception
-
main
public static void main(java.lang.String[] args) throws java.lang.Exception
- Throws:
java.lang.Exception
-
help
protected static void help()
-
-