Exemplo n.º 1
0
        // 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");
        }
Exemplo n.º 2
0
        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();
            }
        }
Exemplo n.º 3
0
        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;
        }
Exemplo n.º 4
0
 protected bool Equals(TelnetEndPoint other)
 {
     return(string.Equals(Host, other.Host) && Port == other.Port);
 }