package com.github.noxan.aves.demo.chat;

import java.io.IOException;

import com.github.noxan.aves.client.Client;
import com.github.noxan.aves.client.ClientAdapter;
import com.github.noxan.aves.client.SocketClient;

public class ChatClient extends ClientAdapter {
    private SocketClient client;
    private ChatClientGUI gui;

    public static void main(String[] args) {
        new ChatClient();
    }

    public ChatClient() {
        client = new SocketClient(this);
        gui = new ChatClientGUI(this);
    }

    public void login(String username, String password) {
        try {
            client.write("login;" + username + ";" + password + "\n");
        } catch(IOException e) {
            e.printStackTrace();
        }
    }

    public void connect() {
        try {
            client.connect();
        } catch(IOException e) {
            e.printStackTrace();
        }
    }

    public void chat(String text) {
        try {
            client.write("chat;" + text);
        } catch(IOException e) {
            e.printStackTrace();
        }
    }
}

@@ -1068,11 +1068,307 @@
  %7D%0A    %7D
+%0A%0A    @Override%0A    public void readData(Client client, Object data) %7B%0A        String parts%5B%5D = ((String)data).trim().split(%22;%22);%0A        String message = parts%5B0%5D.toLowerCase();%0A        String%5B%5D args = new String%5Bparts.length - 1%5D;%0A        System.arraycopy(parts, 1, args, 0, args.length);%0A    %7D
 %0A%7D%0A

add readdata method to chatclient and split message