/// <summary>
/// Initializes a new instance of the <see cref="libanimus.Networking.TelnetUpstream"/> class.
/// </summary>
public TelnetUpstream()
{
Clients = new List<TcpClient> ();
Actions = new List<HostAction> ();
globalLog = new List<string> ();
notifications = new Dictionary<TcpClient, List<string>> ();
var local = IPAddress.Any;
listener = new TcpListener (local, 23);
listener.AllowNatTraversal (true);
try {
listener.Start ();
} catch {
NetworkManager.Instance.Broadcast ("Failed to start telnet client.");
return;
}
Task.Factory.StartNew (Listen).ContinueWith (task => {
if (task.IsFaulted) {
// Log exception here
Console.WriteLine ("Telnet listener task faulted.");
}
try {
listener.Stop ();
}
finally {
listener = null;
}
});
}