-
Notifications
You must be signed in to change notification settings - Fork 434
Received Data From Client
徐昊 edited this page Nov 12, 2018
·
3 revisions
mServerManager = OkSocket.server(/* the port you need listened */).registerReceiver(new ServerActionAdapter() {
@Override
public void onClientConnected(IClient client, int serverPort, IClientPool clientPool) {
//You need add a callback when client connected.
//All IO things will through by this callback.
//You'd better use one callback object to do that and you'll distinguish each client in this callback.
client.addIOCallback(/* The implementation of IClientIOCallback */);
}
@Override
public void onClientDisconnected(IClient client, int serverPort, IClientPool clientPool) {
//You need remove the callback when client is disconnected.
client.removeIOCallback(/* The callback object which you added */);
}
});
@Override
public void onClientRead(OriginalData originalData, IClient client, IClientPool<IClient, String> clientPool) {
//The parameter originalData is the data from the server.
//The parameter client is mean which one received this originalData
}
@Override
public void onClientWrite(ISendable sendable, IClient client, IClientPool<IClient, String> clientPool) {
//The parameter sendable is the data already sent.
//The parameter client is mean which one sends this data.
}