public class SimpleTcpClientExample {
public static void main(String[] args) {
final SimpleTcpClient client = new SimpleTcpClient("localhost", 9900,
new StringLineDecoder(), new StringLineEncoder());
TcpConnection c = client.connect();
c.send("hello client 1", new MessageReceiveCallBack() {
@Override
public void messageRecieved(Session session, Object obj) {
System.out.println("con1|" + obj.toString());
}
});
c.send("test client 2", new MessageReceiveCallBack() {
@Override
public void messageRecieved(Session session, Object obj) {
System.out.println("con1|" + obj.toString());
}
});
c.send("test client 3", new MessageReceiveCallBack() {
@Override
public void messageRecieved(Session session, Object obj) {
System.out.println("con1|" + obj.toString());
}
});
c.send("quit", new MessageReceiveCallBack() {
@Override
public void messageRecieved(Session session, Object obj) {
System.out.println("con1|" + obj.toString());
}