I am getting really messed up results each time I run the b4a websocket push client. Can someone tell me when sometimes I run this app and I get a socket connection and sometimes like this example I get the service called but no socket connections. Sometimes the connection gets made and it sits in the ping pong loop and never gets back to Activity (main) resume to continue on processing.. and why am I starting the service in Resume if it is sticky and starts at boot time? why does it look like the service is restarting again? I have never been more confused or frustrated in my life. Almost want to give up on this project. Maybe sleep will help.
thanks
thanks
B4X:
Sub Activity_Resume
StartService(PushService)
Select session_map.Get("device_status")
Case "UnAuth"
etc
B4X:
#Region Service Attributes
#StartAtBoot: True
#StartCommandReturnValue: android.app.Service.START_STICKY
#End Region
B4X:
** Activity (main) Pause, UserClosed = false **
** Service (pushservice) Create **
** Service (pushservice) Start **
38:94:96:92:CC:89
WebSocket Connected
true
{"type":"event","event":"Device_id","params":{"id":"38:94:96:92:CC:89"}}
{"type":"event","event":"Device_Ping","params":{}}
{"type":"event","event":"Device_Ping","params":{}}
{"type":"event","event":"Device_Ping","params":{}}
{"type":"event","event":"Device_Ping","params":{}}
{"type":"event","event":"Device_Ping","params":{}}
** Service (pushservice) Start **
38:94:96:92:CC:89
{"type":"event","event":"Device_Ping","params":{}}
{"type":"event","event":"Device_Ping","params":{}}
{"type":"event","event":"Device_Ping","params":{}}
{"type":"event","event":"Device_Ping","params":{}}
{"type":"event","event":"Device_Ping","params":{}}
** Service (pushservice) Start **
38:94:96:92:CC:89
B4X:
** Activity (main) Pause, UserClosed = false **
** Service (pushservice) Create **
** Service (pushservice) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Error occurred on line: 34 (WebSocketHandler)
java.lang.NullPointerException: Attempt to invoke virtual method 'void anywheresoftware.b4a.objects.WebSocketWrapper.SendText(java.lang.String)' on a null object reference
at b4a.example.websockethandler._sendeventtoserver(websockethandler.java:77)
at b4a.example.main._activity_resume(main.java:575)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:697)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:336)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:246)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:153)
at b4a.example.main.afterFirstLayout(main.java:108)
at b4a.example.main.access$000(main.java:17)
at b4a.example.main$WaitForLayout.run(main.java:80)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6134)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
** Activity (main) Resume **