Android Question Which WebSocket library to use ?


Well-Known Member
Licensed User
Longtime User

If I look at
I notice I would need to have some class called "WebsocketHandler" when I use the WebSocket library.

I already download the latest version but the class WebSocketHandler seems not to exist ?

Sub btnSend_ClickDim data AsMap
data.Put("message", EditText1.Text)
wsh.SendEventToServer("Device_Message", data)
End Sub

I understand I would need to to use WebSocketHandler.SendEventToServer to send a message to the server ?

Or is the link not in sync with the latest source-code of the library ?

PS: In general I find the info on websockets (B4A on client and B4J on server) scattered around multiple posts and I find it hard to get a general (up-to-date?) info.

Is there anywhere an up-to-date B4A client and corresponding B4J server that sends data in both directions ?

Last edited:


Well-Known Member
Licensed User
Longtime User
Ok, got it thanks through this post:

WebSocketHandler is a seperate class that essentially wraps the Text params (used for passing data back and forth) into Maps.

Basically, client-side you have:

ws.SendText(jg.ToString): 'method to send data to the server: the text param should contain a map with at least an item called "event" that contains the name of method on the server (eg: Device_MessageDelivered (Data as Map))
Sub ws_TextMessage(msg As String) 'event called from the server: msg should be the json string of a map with at least a key 'prop' (name of the event) and 'value' (paramlist) (eg: prop = 'NewMessage')


Public Sub Device_MessageDelivered(Data As Map) 'See ws.SendText above
ws.RunFunction("NewMessage", Messages) 'See ws_TextMessage above

Correct ?

Upvote 0