Regarding the example provided in the jWebSocketClient Library post - https://www.b4x.com/android/forum/threads/jwebsocketclient-library.40985/#content,
I have a couple of questions on the PushService module:
1. The WebSocketHandler appears to be declared twice, both in Process_Globals and the Connect sub:
Is this correct, if so why?
2. In the wsh_Closed sub, CallSub2 is used rather than just referencing the Main module directly, is there a reason for this?
Many thanks.
I have a couple of questions on the PushService module:
1. The WebSocketHandler appears to be declared twice, both in Process_Globals and the Connect sub:
B4X:
Sub Process_Globals
Private fx As JFX
Private VERSION As Double = 1.0
Private wsh As WebSocketHandler
Private id As String
Public kvs As KeyValueStore
Private pingTimer As Timer
Private lastServerPong As Long
Type Message (id As String, Text As String)
Private ReconnectTimer As Timer
End Sub
Private Sub Connect
Dim wsh As WebSocketHandler
wsh.Initialize(Me, "wsh")
wsh.Connect(Main.serverLink)
End Sub
2. In the wsh_Closed sub, CallSub2 is used rather than just referencing the Main module directly, is there a reason for this?
B4X:
Sub wsh_Closed (Reason As String)
Log("WebSocket Closed: " & Reason)
CallSub2(Main, "UpdateStatus", wsh.ws.Connected) 'why not Main.UpdateStatus(wsh.ws.Connected)
pingTimer.Enabled = False
ReconnectTimer.Enabled = True
End Sub
Many thanks.
Last edited: