#Region Project Attributes
#MainFormWidth: 600
#MainFormHeight: 600
#End Region
Sub Process_Globals
Dim ws As WebSocketClient
Dim timerws As Timer
Private fx As JFX
Private MainForm As Form
End Sub
Sub timerws_tick
ws.Close
Init_Ws
End Sub
Sub ws_TextMessage (Message As String)
timerws.Enabled = False
timerws.Enabled = True
Log (Message)
End Sub
Sub Init_Ws
ws.Initialize("ws")
timerws.Enabled = True
Dim ssl As JavaObject
ssl.InitializeNewInstance("org.eclipse.jetty.util.ssl.SslContextFactory", Array(True))
Dim jo As JavaObject = ws
Dim wsc As JavaObject
wsc.InitializeNewInstance("org.eclipse.jetty.websocket.client.WebSocketClient", Array(ssl))
jo.SetField("wsc", wsc)
ws.Connect("wss://***")
Log("ws Connecting")
Wait For ws_Connected
Log("connected")
ws.SendText($"***"$)
Wait For ws_TextMessage (Message As String)
Log (Message)
ws.SendText($"***"$)
Log ("send 2")
Sleep (100)
ws.SendText($"***"$)
Log ("send 3")
Sleep (100)
ws.SendText($"***"$)
Log ("send 4")
Sleep (100)
ws.SendText($"***"$)
Log ("send 5")
Sleep (100)
ws.SendText($"***"$)
Log ("send 6")
Sleep (100)
ws.SendText($"***"$)
Log ("send 7")
Wait For ws_TextMessage (Message As String)
Log(Message)
timerws.Enabled = False
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
'MainForm.RootPane.LoadLayout("Layout1") 'Load the layout file.
MainForm.Show
ws.Initialize("ws")
timerws.Initialize("timerws",20000)
Init_Ws
End Sub
Private Sub ws_Connected
Log ("ws closed")
End Sub
Sub ws_Closed (Reason As String)
Log("ws error: " & Reason)
ws.close
timerws.Enabled = True
End Sub
'Return true to allow the default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
Return True
Log (Error.Message & " " & StackTrace)
End Sub