Certainly there is a better method... also because... this does not work
I'm trying:
B4X:
' SERVER - WEBSOCKET CLASS
Sub Class_Globals
Type tProva(ID As Int, Name As String)
Private mB4XSerializator As B4XSerializator
Private mStringUtils As StringUtils
'...
Private Sub Test
Dim Prova As tProva
Prova.Initialize
Prova.ID = 123
Prova.Name = "Me stesso"
Dim Data() As Byte = mB4XSerializator.ConvertObjectToBytes(Prova)
Dim Base64 As String = mStringUtils.EncodeBase64(Data)
Dim lstData As List
lstData.Initialize
lstData.Add(Base64)
ws.RunFunction("TestRoutine", lstData)
ws.Flush
End Sub
B4X:
' CLIENT
' [mStringUtils, mB4XSerializator and tProva are declared, of course]
' Called by Private Sub ws_TextMessage(msg As String)
Public Sub TestRoutine(Params As List)
Dim Base64 As String = Params.Get(0)
Dim Data() As Byte = mStringUtils.DecodeBase64(Base64)
Dim Prova As tProva
Prova = mB4XSerializator.ConvertBytesToObject(Data)
LogColor("Ricevuti: " & Prova.ID & TAB & Prova.Name, Colors.Blue)
Error occurred on line: 181 (srvComm)
java.lang.RuntimeException: java.lang.ClassNotFoundException: .......$_tprova
Here's the code. Please note they are just quick adaptations of what you posted/was already posted on these forums (no original code). The B4J app is just a shell to log the result of the transfer.
Note: Change the IP addresses!
I have already deleted all; anyway, probably I declared it in the service I use for "communications" between the websocket handler "class" and the rest of the app (mainly activities).
Also, I don't think it should change something, @Roycefer, thank you.