B4A Library WebSocket Client Library

Status
Not open for further replies.

jimmyF

Active Member
Licensed User
Longtime User
v2.10: New BinaryMessage event and SendBinary method.

Is there a possibility of getting some code samples of using these methods and events?
The samples in Post #1 are dated 2014

Thanks
j
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
1. Binary messages are not relevant when communicating with B4J servers. Most WebSocket servers send and receive text messages so it is not a commonly used feature. It was requested by one of the forum members so I've added it.
2. The usage is very simple:
B4X:
WebSocket1.SendBinary(data)

Sub WebSocket1_BinaryMessage (Data() As Byte)
 Log("Binary message received.")
 'work with Data.
End Sub
 

jimmyF

Active Member
Licensed User
Longtime User
Binary messages are not relevant when communicating with B4J servers.

Okay, I see.
And thinking more about it, I don't really see a need for it in my situation.

Thanks.
 

warwound

Expert
Licensed User
Longtime User
I'm trying to use the latest version 2.1 of WebSocket library but compilation keeps failing with this error message:


The offending code is:

B4X:
Sub DownloadQueue1_Ready
   Log("DownloadQueue1_Ready")
   Dim NextIncompleteTorrent As TorrentMeta=DownloadQueue1.GetNextIncompleteTorrent
   If NextIncompleteTorrent.IsInitialized Then
       BroadcastTorrentFile(NextIncompleteTorrent)
   Else
       Dim NotifyCompletePacket() As Byte=Array As Byte(Starter.COMMAND_NOTIFY_COMPLETE)
       
       Starter.WebSocketConnection1.SendBinary(NotifyCompletePacket)
       
   End If

End Sub

I've cleaned the project and restarted the b4a IDE but still compilation fails.
The b4a IDE shows i have version 2.1, and if i open the WebSocket.jar file in Java Decompiler i see the SendBinary(Data() As Byte) method exists in the wrapper.

What am i doing wrong?
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…