Registering event handlers |
The Jscape.Ssh.IpClientSsh class is a subclass of the Jscape.IpClient.IpClient class firing the same events.
The IpClient class may publish one or more events during the lifetime of a session. Any object that subscribes to events published by the IpClient class can receive and process these events.
Capturing the IpClientConnectedEvent event
The IpClientConnectedEvent is fired by the IpClient instance once a connection to the server has been established.
Example
[C#]
// register event handler
ipclient.IpClientConnectedEvent += new Jscape.IpClient.IpClient.IpClientConnectedEventHandler(OnConnected);
// handle IpClientConnectedEvent
public void OnConnected(object sender, IpClientConnectedEventArgs args) {
Console.WriteLine("Connected to: " + args.Hostname);
}
[VB]
' register event handler
ipclient.IpClientConnectedEvent += New Jscape.IpClient.IpClient.IpClientConnectedEventHandler(OnConnected)
' handle IpClientConnectedEvent
Public Sub OnConnected(ByVal sender As Object, ByVal args As IpClientConnectedEventArgs)
Console.WriteLine("Connected to: " + args.Hostname)
End Sub
Capturing the IpClientDisconnectedEvent event
The IpClientDisconnectedEvent is fired by the IpClient instance once a connection to the server has been released.
Example
[C#]
// register event handler
ssh.IpClientDisconnectedEvent += new Jscape.IpClient.IpClient.IpClientDisconnectedEventHandler(OnDisconnected);
// handle IpClientDisconnectedEvent
public void OnDisconnected(object sender, IpClientDisconnectedEventArgs args) {
Console.WriteLine("Disconnected from: " + args.Hostname);
}
[VB]
' register event handler
ipclient.IpClientDisconnectedEvent += New Jscape.IpClient.IpClient.IpClientDisconnectedEventHandler(OnDisconnected)
' handle IpClientDisconnectedEvent
Public Sub OnDisconnected(ByVal sender As Object, ByVal args As IpClientDisconnectedEventArgs)
Console.WriteLine("Disconnected from: " + args.Hostname)
End Sub