[solved] Network.connectToServer is blocking

Hello,



as i use this function, the screen is not updated anymore

i wanted to have a round object rotating as a waiting status display



how can i achieve this ?



thx

You have to do it on a background thread to get what you want. This isn’t too bad because the networking layer already gives you the listener support you need to watch for full connection setup to be complete.



connectToServer() just opens the socket, though. It doesn’t do any other processing. So it should only take a long time if the network between the client and the server is kind of crappy.



All of the actual connection setup work is done on a background thread.

@pspeed said:
You have to do it on a background thread to get what you want. This isn't too bad because the networking layer already gives you the listener support you need to watch for full connection setup to be complete.

connectToServer() just opens the socket, though. It doesn't do any other processing. So it should only take a long time if the network between the client and the server is kind of crappy.

All of the actual connection setup work is done on a background thread.


and how do i do that
i checked to add a listener but could not find any entry point

http://hub.jmonkeyengine.org/javadoc/com/jme3/network/Client.html#addClientStateListener(com.jme3.network.ClientStateListener)

@pspeed said:
http://hub.jmonkeyengine.org/javadoc/com/jme3/network/Client.html#addClientStateListener(com.jme3.network.ClientStateListener)


well that's what i have done before bit it wont allow me to update the gui that way
Code:
myClient.addClientStateListener(new ClientStateListener() { public void clientConnected(Client c) { } public void clientDisconnected(Client c, DisconnectInfo info) { } });

i need to refresh the gui while sockets are working, here the whole program is blocked in debug mode as i step on connectToServer :(
besides the listener is added after the connection is launched

You need to connect and wait for the connection from a different thread - not the rendering one.

@zarch said:
You need to connect and wait for the connection from a different thread - not the rendering one.


yes but how do i force a refresh of the screen ?

i tried with a timer and a thread , i modify some elements and make a LayoutElments() but it only refresh once the connection is established

yes it works !!!