M Mr.Coder Member Licensed User Longtime User Oct 10, 2019 #1 Hi, I have android app and i want to send custom type to the b4j server, I use B4XSerializator to convert the custom type to bytes and then i use the following websocket method : Code: WebSocket1.SendBinary(data) to send it to the b4j server and for receiving the binary data from the b4j server side i use the following event : Code: Sub WebSocket1_BinaryMessage (Data() As Byte) Log("Binary message received.") 'work with Data. End Sub the question here how can i receive the binary data in the b4j server side and how can i send back the binary data from the b4j sever to the android app. Note: I want to mention that i use AddWebSocket method and WebSocket class in the b4j server. Thank you.
Hi, I have android app and i want to send custom type to the b4j server, I use B4XSerializator to convert the custom type to bytes and then i use the following websocket method : Code: WebSocket1.SendBinary(data) to send it to the b4j server and for receiving the binary data from the b4j server side i use the following event : Code: Sub WebSocket1_BinaryMessage (Data() As Byte) Log("Binary message received.") 'work with Data. End Sub the question here how can i receive the binary data in the b4j server side and how can i send back the binary data from the b4j sever to the android app. Note: I want to mention that i use AddWebSocket method and WebSocket class in the b4j server. Thank you.
Erel B4X founder Staff member Licensed User Longtime User Oct 11, 2019 #2 B4J jServer WebSocket only works with text and it expects it in a specific format. You need to use WebSocketHandler class on the client: https://www.b4x.com/android/forum/threads/websocket-client-library.40221/#content You can convert the binary data to text with StringUtils.EncodeBase64. Upvote 0
B4J jServer WebSocket only works with text and it expects it in a specific format. You need to use WebSocketHandler class on the client: https://www.b4x.com/android/forum/threads/websocket-client-library.40221/#content You can convert the binary data to text with StringUtils.EncodeBase64.
M Mr.Coder Member Licensed User Longtime User Oct 11, 2019 #3 Thank you Erel, I know what you mentioned but I was wondering why there is a byte type parameter in the reception event if we send a text message from the server. Upvote 0
Thank you Erel, I know what you mentioned but I was wondering why there is a byte type parameter in the reception event if we send a text message from the server.