B4J Library jWebSocketClient library

Note: this library depends on jetty_b4j.jar, which is included in jServer3.zip: https://www.b4x.com/android/forum/threads/jserver3.141323/#content

With this library you can implement WebSocket clients. The API is identical to the B4A library: http://www.b4x.com/android/forum/threads/websocket-client-library.40221/#content (except of the object name which is WebSocketClient).

It is based on Jetty WebSocket client implementation.

The push client example was ported to B4J: http://www.b4x.com/android/forum/threads/custom-websocket-based-push-framework.40272/

SS-2014-05-14_12.44.33.png


SS-2014-05-14_12.47.54.png


upload_2014-5-14_12-48-18.png


This means that you can now implement an (almost) always connected solution with bi-directional communication running on Androids, desktops and browsers.

This is an internal library.

Updates:
v1.13 - New SendTextAsync and SendBinaryAsync methods. Do not use SendText / SendBinary. By mistake they are sending the messages on the main thread which can lead to bad things. The old methods are kept for backward compatibility.
 

Attachments

  • WebSocketPush.zip
    5.8 KB · Views: 2,375
  • jWebSocketClient.zip
    6 KB · Views: 283
Last edited:

wl

Well-Known Member
Licensed User
Longtime User
Hi Erel,

As far as I know the library already existed for a few weeks: is there anything new in this library that made you create this post about an hour ago ?
Or has the B4J client library been added ?

Thanks
 

Silv

Member
Licensed User
Longtime User
Hi Erel can you give me the code of your server in the samples? ws://basic4ppc.com:51042/push/b4a_ws2 this one
 

KY Leng

Member
Licensed User
Longtime User
Hi Erel,

I am not sure whether the server can be implemented on android device or not?
Secondly, do we need static IP for the server or only hosting is enough ?

Best regards,
 

xulihang

Active Member
Licensed User
Longtime User
Does the library work with B4J v9.8? I can't get it to connect to a websocket jServer.

Edit:

It turns out to be the new filter I added which causes the problem.

B4X:
Public Sub Filter(req As ServletRequest, resp As ServletResponse) As Boolean
    resp.SetHeader("Access-Control-Allow-Private-Network","true")
    Return False
End Sub
 
Top