StormHub / NetUV

.Net standard/Core binding for Libuv
Other
76 stars 20 forks source link

How to get a callback on server when client disconnect #54

Closed lth3726381 closed 7 years ago

lth3726381 commented 7 years ago

In the Example EchoServer/Client ,when remote tcp server or client disconnected,there are some logs printed on console,but no callback. How can I do jobs when client disconnect?

StormHub commented 7 years ago

The OnError callback will be invoked on the handle.

lth3726381 commented 7 years ago

Which OnError? Only found a param named OnError in StreamHandle.OnRead,and it won't be invoked when client disconnect. Is there any public callback like "OnClose" and it will be invoked when a handle is disposing?(when disconnect by remote,not the CloseHandle method)

lth3726381 commented 7 years ago

Another way to get the "OnClose" callback is checking ReadableBuffer.Count==0 in OnAccept. but it's not friendly to newer(me). A public callback setter is more intuitively,Or write a check method into example.

StormHub commented 7 years ago

https://github.com/StormHub/NetUV/blob/dev/src/NetUV.Core/Handles/StreamHandle.cs#L70 When a new stream starts and the OnRead is called with callbacks of accept/error/complete The OnError callback will be invoked if any internal handle errors happened.