Set timeout for Network.connectToServer

i will look at monkey trap. so far, it was difficult to me to handle that “uninitialized blind spot” between creating app state and initializing it, so i can use it. i also want to leave constructor empty.

@Ascaria said: i will look at monkey trap. so far, it was difficult to me to handle that "uninitialized blind spot" between creating app state and initializing it, so i can use it. i also want to leave constructor empty.

Well, for network states you will want to pass the connection to the constructor so it can store it. Then the state does all of the work on init. You shouldn’t have to access it before that.

In fact, if you find this blind spot then it’s a sign that responsibilities are poorly distributed and you have some coupling where you shouldn’t.

@pspeed said: Well, for network states you will want to pass the connection to the constructor so it can store it. Then the state does all of the work on init. You shouldn't have to access it before that.

In fact, if you find this blind spot then it’s a sign that responsibilities are poorly distributed and you have some coupling where you shouldn’t.

i prefer to have connection stored in app class (not static) so it can be accessed easily, connected or disconnected, but everytime it is there and it is same instance, even after 10 connections and disconnections, initiating connection must be non-blocking “end command” (means not any logic should be after “connect” is called). constructors sux, DI sux (setA setB setC ou yea), im using them only when it is really necessary. i prefer to have initialize and cleanup not only in appstate but in at least half of classes. i think its better to have diverse, but unified approach. i imagine initialize as a “big setter” and cleanup as a cleanup :slight_smile:

luckily, as my game progress, those blind spots are disappearing and i have less and less coupling as i continuously refactoring it :slight_smile:

tu du dum @fegarcia
lesson from this topic is: dont mess with some timeout, do that connection in a way that do not block main thread and use connection listeners to take next step :slight_smile:

You could have accessed the connection easily from any app state if it was also in an app state. I think most of your issues are self-imposed but whatever. I’ll let you deal with it and let this topic revert back to the original.