package com.github.noxan.aves.demo;

import java.io.IOException;

import com.github.noxan.aves.net.Connection;
import com.github.noxan.aves.server.ServerHandler;
import com.github.noxan.aves.server.SocketServer;

public class DemoServer implements ServerHandler {
    public static void main(String[] args) {
	new DemoServer();
    }

    private SocketServer server;

    public DemoServer() {
	server = new SocketServer(this);
	server.start();
    }

    @Override
    public void readData(Connection connection, Object data) {
	try {
	    connection.write(data);
	} catch (IOException e) {
	    e.printStackTrace();
	}
	System.out.println(connection + ": " + data);
    }

    @Override
    public void clientConnect(Connection connection) {
	System.out.println("Client connect: " + connection);
    }

    @Override
    public void clientDisconnect(Connection connection) {
	System.out.println("Client disconnect: " + connection);
    }

    @Override
    public void clientLost(Connection connection) {
	System.out.println("Client lost: " + connection);
    }
}

@@ -659,19 +659,24 @@
 %22 + data
+ + %22%22
 );%0A
-
     %7D%0A%0A 
@@ -767,36 +767,30 @@
 tln(
-%22Client connect: %22 +
+connection + %22
  connect
 ion)
@@ -777,35 +777,33 @@
 tion + %22 connect
-ion
+%22
 );%0A    %7D%0A%0A    @O
@@ -892,42 +892,34 @@
 tln(
-%22Client disconnect: %22 + 
+connection + %22 dis
 connect
-ion
+%22
 );%0A 
@@ -1014,26 +1014,8 @@
 tln(
-%22Client lost: %22 + 
 conn
@@ -1020,16 +1020,26 @@
 nnection
+ + %22 lost%22
 );%0A    %7D

update demo server handler console output