I have created a fairly basic client and server. In the client, once I receive the connected() message, I want to send data to the server. I do that directly in the connected() method, and it looks thusly:
public void connected(byte[] arg0)
{
Log.l().log(Level.INFO, "Connected");
ccManager.openChannel("appMainChannel");
ByteBuffer myByteBuffer=createRequest();
try{ Thread.sleep(1000); }catch(Exception e){}
ccManager.sendToServer(myByteBuffer, true);
}
The byte buffer gets created in an extra method, but that shouldn’t be the problem (I have checked that it creates a correct byte array with 6 elements. Now, this works fine, on the server side I have added a SimUserDataListener which receives the
userDataReceived(UserID from, ByteBuffer data)
method call. However, if I remove the wait statement in the connected() method, i.e. this line:
try{ Thread.sleep(1000); }catch(Exception e){}
then it does not work, i.e. the userDataReceived() method is NOT called. What am I doing wrong?