Hi,
I am trying to get to work a simple server-client communication using Processing's Network library.
I want that my server refuses new clients past a certain amount of already connected clients.
Here is my serverEvent method :
void serverEvent(Server _S, Client _C) // is run when a client connects
{
if(idCount > maxClients)
{
_S.disconnect(_C);
println("Client "+idCount+" refused.");
idCount ++;
}
else {
S.write(_C.ip()+" "+Integer.toString(idCount));
println("Client "+idCount+" connected.");
idCount ++;
}
}
The else part works fine. But when the program executes the if part, it throws this exception :
java.lang.NullPointerException
at processing.net.Client.run(Unknown Source)
at java.lang.Thread.run(Thread.java:748)
However the exception is thrown outside the if brackets : I can print something after the if/else statement before the exception is thrown.
Any hint to solve this ?