Platforms to show: All Mac Windows Linux Cross-Platform
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /CURL/CURL WebSocket Test
This example is the version from Mon, 10th Sep 2023.
Project "CURL WebSocket Test.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Control TextAreaLog Inherits TextArea
ControlInstance TextAreaLog Inherits TextArea
End Control
Control Timer1 Inherits Timer
ControlInstance Timer1 Inherits Timer
EventHandler Sub Action()
dim m as CURLSWebSocketFrameMBS = curl.WebSocketReceive
if m <> nil then
TextAreaLog.AddText "Received: "+m.Text
curl = nil // close
me.RunMode = timer.RunModes.Off
end if
End EventHandler
End Control
EventHandler Sub Open()
curl = New CURLSMBS
curl.OptionURL = "ws://yourserver.com/echo" // <- put in URL for an echo web service
curl.OptionConnectOnly = 2
curl.OptionConnectionTimeout = 5
dim e as integer = curl.Perform
if e <> 0 then
MessageBox curl.LasterrorMessage
end if
dim d as string = curl.DebugData
dim o as string = curl.OutputData
TextAreaLog.AddText d
TextAreaLog.AddText EndOfLine
TextAreaLog.AddText o
TextAreaLog.AddText EndOfLine
curl.OptionTimeOut = 1
if e = 0 then
// and we send something
dim b as integer = curl.WebSocketSend("Hello World", 0)
TextAreaLog.AddText "Sent: "+b.ToString
TextAreaLog.AddText EndOfLine
// now wait in timer for answer
timer1.RunMode = timer.RunModes.Multiple
end if
End EventHandler
Property curl As CURLSMBS
End Class
MenuBar MainMenuBar
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem EditSeparator1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem EditSeparator2 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
End Project
See also:
The items on this page are in the following plugins: MBS CURL Plugin.