Hello!
I am a newbie to the iOS app development as I just purchased the B4i yesterday.
I tried to use the example from
https://www.b4x.com/android/forum/threads/asyncstreamsobject-module.48276/#content
but I don't see any explicit use to read data from the connected server there.
In fact, I did use the B4A to have my simple Android app to connect to the server with:-
Sub TcpStreams_NewData (Buffer() As Byte)
Dim Rx_String As String
If Buffer.Length = 4 Then
Rx_String = BytesToString(Buffer, 0, 4 , "UTF8")
dataLabel.Text = Rx_String
End If
End Sub
and
Sub WiFi_Socket_Connected (Successful As Boolean)
If Successful = True Then
ToastMessageShow("Connected",True)
TcpStreams.Initialize(WiFi_Socket.InputStream,WiFi_Socket.OutputStream,"tcpStreams")
Else
ToastMessageShow("Server Not Available. Pls check for ESP_0191A9 Wifi.",True)
End If
End Sub
Therefore, I would like to ask if it would be that straight-forward without any change on server side,
I can use something like:-
Sub astreamO_NewData (Buffer() As Byte)
Dim Rx_String As String
If Buffer.Length = 4 Then
Rx_String = BytesToString(Buffer, 0, 4 , "UTF8")
dataLabel.Text = Rx_String
End If
End Sub
if I follow the example to have
Private astreamO As AsyncStreamsObject
and
Sub StartAstream(s As Socket)
astreamO.Start(s.InputStream, s.OutputStream)
SetUIState
End Sub
Or it should be
Sub Astream_NewData (Buffer() As Byte)
instead?!
Thanks & Best Regards,
Robert
I am a newbie to the iOS app development as I just purchased the B4i yesterday.
I tried to use the example from
https://www.b4x.com/android/forum/threads/asyncstreamsobject-module.48276/#content
but I don't see any explicit use to read data from the connected server there.
In fact, I did use the B4A to have my simple Android app to connect to the server with:-
Sub TcpStreams_NewData (Buffer() As Byte)
Dim Rx_String As String
If Buffer.Length = 4 Then
Rx_String = BytesToString(Buffer, 0, 4 , "UTF8")
dataLabel.Text = Rx_String
End If
End Sub
and
Sub WiFi_Socket_Connected (Successful As Boolean)
If Successful = True Then
ToastMessageShow("Connected",True)
TcpStreams.Initialize(WiFi_Socket.InputStream,WiFi_Socket.OutputStream,"tcpStreams")
Else
ToastMessageShow("Server Not Available. Pls check for ESP_0191A9 Wifi.",True)
End If
End Sub
Therefore, I would like to ask if it would be that straight-forward without any change on server side,
I can use something like:-
Sub astreamO_NewData (Buffer() As Byte)
Dim Rx_String As String
If Buffer.Length = 4 Then
Rx_String = BytesToString(Buffer, 0, 4 , "UTF8")
dataLabel.Text = Rx_String
End If
End Sub
if I follow the example to have
Private astreamO As AsyncStreamsObject
and
Sub StartAstream(s As Socket)
astreamO.Start(s.InputStream, s.OutputStream)
SetUIState
End Sub
Or it should be
Sub Astream_NewData (Buffer() As Byte)
instead?!
Thanks & Best Regards,
Robert