B4R Question Sender in Events NewData or Error

JanG

Member
Licensed User
Longtime User
Does the Sender object have a valid value (the object which raised this event) in events NewData/Error (AsyncStreams)? Which type of object is it?
 

JanG

Member
Licensed User
Longtime User
Okay. That means maybe I found a bug... The Sender object in my code in streamData_Error is invalid and I got a crash if I reconnect after a successful connect. If I send data, then the streamData_Error has a valid Sender (AsyncStreams) and I don't get a crash when disconnecting.
Shorter:
a) Connecting->Disconnecting => invalid Sender/AsyncStreams in streamData_Error => CRASH
b) Connecting->SendData->Disconnecting => valid Sender/AsyncStreams in streamData_Error => FINE
Here The code snippet, the full project is appended. I marked my AsyncStream by setting the buffer to a well known value (here 101). But the log (reading this value) crashes.
B4X:
Private Sub streamData_Error
    Log("streamData_Error")

    Dim TempAsyncStreams As AsyncStreams
    Dim TempWiFiSocketWrapper As WiFiSocketWrapper
 
    TempAsyncStreams = Sender
    Log("MaxBufferSize: ", TempAsyncStreams.MaxBufferSize)
     
    If StaticFixedTypeMap.Get(TempAsyncStreams, TempWiFiSocketWrapper) Then
        Log("Gefunden!")
        If TempWiFiSocketWrapper.EnclosedObject.Connected Then
            TempWiFiSocketWrapper.EnclosedObject.Close
        End If

        TempWiFiSocketWrapper.EnclosedObject.Stream.Flush
        StaticFixedTypeMap.Remove(TempAsyncStreams)         
    End If
 
    wifiServerSocket.Listen
End Sub
 

Attachments

  • TestESP8266ServerSocket.zip
    2.7 KB · Views: 246
  • ConnectWemos.zip
    2.2 KB · Views: 259
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…