Timing problem: sendToServer() immediately after connected()

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?

Sorry - just found out that this is actually documented in the ‘known bugs’ list. Until this is fixed, the sleep is explicitly recommended.

You will be happy to know i just comitted back a fix for thsi for the next release.

Wow, that was quick. Great news - thank you very much!