I send text when service connected, like this
@Override public void onConnected(WebSocket websocket, Map<String, List<String>> headers) throws Exception { Logs.d("onConnected"); websocket.sendText("Hello World"); }
there is the lifecycle log:
onStateChanged CONNECTING onSendingHandshake onStateChanged OPEN onThreadCreated onThreadCreated onThreadStarted onConnected // I send text message at this lifecycle onThreadStarted onFrame onTextFrame onSendingFrame onFrameSent onThreadStopping onSendingFrame onStateChanged CLOSING onFrameSent onStateChanged CLOSED onDisconnected closedByServer ? false onThreadStopping
I recommend that you NOT call sendXxx methods in onConnected. In general, programmers should avoid calling time-consuming methods from within listener methods.
I send text when service connected, like this
@Override public void onConnected(WebSocket websocket, Map<String, List<String>> headers) throws Exception { Logs.d("onConnected"); websocket.sendText("Hello World"); }
there is the lifecycle log:onStateChanged CONNECTING onSendingHandshake onStateChanged OPEN onThreadCreated onThreadCreated onThreadStarted onConnected // I send text message at this lifecycle onThreadStarted onFrame onTextFrame onSendingFrame onFrameSent onThreadStopping onSendingFrame onStateChanged CLOSING onFrameSent onStateChanged CLOSED onDisconnected closedByServer ? false onThreadStopping