AsyncStreams disconnect

wl

Well-Known Member
Licensed User
Longtime User

Erel

B4X founder
Staff member
Licensed User
Longtime User
You should also handle the Terminated event.

The Error or Terminated events will always be called when the device "knows" that the connection broke. The connection might appear to be connected although this is not the case.

For that reason I recommend you to use a heartbeat mechanism. You can check B4A-Bridge code for an example.
 
Upvote 0

wl

Well-Known Member
Licensed User
Longtime User
Erel,

In order to implement a heartbeat mechanism I would like to have a timeout while reading from the stream. When a timeout occurs a TimeOut event should be called.

It seems this is not possible with the standard RadnomAccess library. Would it be possible to obtain the code so I can make my own version that implements this ?

Thanks !
 
Upvote 0

wl

Well-Known Member
Licensed User
Longtime User
Hi Erel,

Yes I'm using AsyncStreams. But unless I'm mistaken but the AsyncStreams are part of the RandomAccessFile library ?

<name>anywheresoftware.b4a.randomaccessfile.AsyncStreams</name>

Thanks,

Wim
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
I see. You want to update AsyncStreams. I'm sorry but this code is not available. I also don't think that it will help you in anyway.

Implementing a heartbeat mechanism is simple. You should have a timer that counts each second. When a message arrives the timer counter is reset.

If the counter reaches 10 then you break the connection. This is how B4A-Bridge timeout works.
 
Upvote 0
Top