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
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?
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
1. When an object can be initialized multiple time, it is safer to first call Dim. Otherwise, the same object instance will be reinitialized and this can cause problems in some cases.
2. This is indeed not needed. It is an old cross platform code, based on B4A activities.
1. When an object can be initialized multiple time, it is safer to first call Dim. Otherwise, the same object instance will be reinitialized and this can cause problems in some cases.
2. This is indeed not needed. It is an old cross platform code, based on B4A activities.
1. When an object can be initialized multiple time, it is safer to first call Dim. Otherwise, the same object instance will be reinitialized and this can cause problems in some cases.