Closed programmerr47 closed 7 years ago
@Matthias247 Hello, I've added pull request, that expose State
object. If it's normal, please, accept it. Thank you.
This is by intention. The whole State
thing is an implementation detail which is not intented to be used by the library user. It even can't be used, as it is not thread safe and the users can code run in an arbitrary thread while the state changes happen in a thread owned by jawampa.
The sole way for the user to observe the state is the statusChanged
event that you mention. You can subscribe to it and observe it from any thread. You can in this subscription also update a local field which stores the last known connection state in your thread and make your further assumptions based on that.
Currently, as I know, 'WampClient' use 'StateController' that holds current State of the client. As for know, user only able to subscribe on state chanings by calling
client.statusChanged()
. But I need just get current state. For example, I just need to check is current state is 'Connected' state.As for know, I need to make some workaround. I need to store external field and in every event that comes from
statusChanged
method update this field. Also I need to control, for example,close
method to update my field to be on the safe side.But it's just an work around, why I need to do it, where there is already such field in
StateController
.Could you, please, provide that functionality?