public Task StartReading(Action <string> callback = null) { return(Task.Run(() => { while (true) { var data = ReadAvaiable(); if (data.Length > 0) { callback?.Invoke(ANSI.RemoveCursorPosition(data)); } } })); }
public async Task StartTunneling() { using (_frontend = new TelnetServer(_frontendEndpoint.Address, _frontendEndpoint.Port)) using (_backend = new TelnetClient(_backendEndpoint.Address, _backendEndpoint.Port)) { await _frontend.ListenConnections(); string backendLogin = await _backend.LoginAsync("lucas", ""); var data = ANSI.RemoveCursorPosition(_backend.ReadAvaiable()); Console.Write(backendLogin); Console.Write(data); _frontend.Write(backendLogin); _frontend.Write(data); await Task.WhenAll(LoopProcessFrontEnd(), LoopProcessBackEnd()); } }