// private readonly string historyPath; public TelnetHistory(TelnetEndPoint endPoint) { if (endPoint == null) { throw new ArgumentNullException("endPoint"); } // historyPath = HttpContext.Current.Server.MapPath("~/App_Data/" + Guid.NewGuid().ToString("N") + "_" + endPoint + ".dat"); }
public async Task TelnetConnect(string host, int port) { var endpoint = new TelnetEndPoint(host, port); var connectionId = Context.ConnectionId; var connection = new TelnetConnection( endpoint, data => Clients.Client(connectionId).telnetAddKeyCodes(data.Select(x => (int)x).ToArray()), () => Clients.Client(connectionId).telnetDisconnected()); if (telnetConnections.TryAdd(connectionId, connection)) { await connection.ConnectAndReceiveData(); } }
public TelnetConnection(TelnetEndPoint telnetEndpoint, Action <byte[]> dataReceived, Action disconnected) { if (dataReceived == null) { throw new ArgumentNullException("dataReceived"); } if (telnetEndpoint == null) { throw new ArgumentNullException("telnetEndpoint"); } history = new TelnetHistory(telnetEndpoint); cts = new CancellationTokenSource(); Endpoint = telnetEndpoint; this.dataReceived = dataReceived; this.disconnected = disconnected; }
protected bool Equals(TelnetEndPoint other) { return(string.Equals(Host, other.Host) && Port == other.Port); }