mirror of https://github.com/oupson/FooTerm.git
Move ssh and slave watcher to functions
This commit is contained in:
parent
287474bd41
commit
d0f95935a9
|
@ -145,7 +145,12 @@ namespace FooTerm {
|
|||
slave_channel.set_encoding (null);
|
||||
slave_channel.set_buffered (false);
|
||||
|
||||
sock_channel.add_watch (GLib.IOCondition.IN, (source, condition) => {
|
||||
sock_channel.add_watch (GLib.IOCondition.IN, this.on_ssh_event);
|
||||
slave_channel.add_watch (GLib.IOCondition.IN, this.on_slave_event);
|
||||
}
|
||||
}
|
||||
|
||||
private bool on_ssh_event(GLib.IOChannel source, GLib.IOCondition condition) {
|
||||
if (condition == IOCondition.HUP) {
|
||||
print ("The connection has been broken.\n");
|
||||
return false;
|
||||
|
@ -154,6 +159,7 @@ namespace FooTerm {
|
|||
try {
|
||||
var buffer = new uint8[1024];
|
||||
var size = this.channel.read(buffer);
|
||||
debug("Got %zu from ssh", size);
|
||||
|
||||
if (Posix.write(this.slave_pty, buffer, size) < 0) {
|
||||
throw GLib.IOError.from_errno(Posix.errno);
|
||||
|
@ -164,9 +170,9 @@ namespace FooTerm {
|
|||
GLib.warning("Failed to read from ssh : %s", e.message);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
slave_channel.add_watch (GLib.IOCondition.IN, (source, condition) => {
|
||||
private bool on_slave_event(GLib.IOChannel source, GLib.IOCondition condition) {
|
||||
if (condition == IOCondition.HUP) {
|
||||
print ("The connection has been broken.\n");
|
||||
return false;
|
||||
|
@ -186,8 +192,6 @@ namespace FooTerm {
|
|||
GLib.warning("Failed to read from terminal : %s", e.message);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue