Closed weiluenju closed 3 years ago
The IFtpConnection
implementation also implements IObservable<IFtpConnectionEvent>
, but you have to register your observer for all connections.
First, you have to create an implementation of IFtpConnectionConfigurator
. An example for this interface is the class AuthTlsConfigurator
, which is used to implement implicit TLS. Your implementation has to be registered as (singleton!) service too.
Now, you can subscribe the connection events.
if (connection is IObservable<IFtpConnectionEvent> observable)
{
_subscription = observable.Subscribe(new YourEventObserver());
}
The class YourEventObserver
must implement IObserver<IFtpConnectionEvent>
. In the OnNext
function, you get a IFtpConnectionEvent
parameter. FtpConnectionDataTransferStartedEvent
implements this interface and can be tested fir with pattern matching.
An example for an event observer can be found in the class FtpConnectionIdleCheck
.
I follow your teaching and successfully subscribe the events.
Thank you very much.
I am a beginner.
How to subscribe the FtpConnectionDataTransferStartedEvent & FtpConnectionDataTransferStoppedEvent event or how to use?
There is my code:
Thank you.