virtual void onConsoleCommand(ConsoleWindow* con, const std::string& str) { if (_remote.getHostPeer() == NULL) { String cmd = str.c_str(); if (StringUtil::startsWith(cmd, "connect")) { String addr = cmd.substr(8); if (_remote.connect(addr)) { DataValue params = DataValue::fromJson("{ client:'nit-rsh', version:'1.0', log:true }"); _remote.request(_remote.getHostPeer(), _channelID, RQ_ATTACH, params); _lastAddr = addr; } return; } else { if (!_lastAddr.empty()) { if (_remote.connect(_lastAddr)) { DataValue params = DataValue::fromJson("{ client:'nit-rsh', version:'1.0', log:true }"); _remote.request(_remote.getHostPeer(), _channelID, RQ_ATTACH, params); } } if (_remote.getHostPeer() == NULL) LOG(0, "*** not connected\n"); } } if (!str.empty()) { Ref<RemotePeer> peer = _remote.getHostPeer(); if (peer) { if (str == "bye") peer->disconnect(); else _remote.notify(peer, _channelID, NT_COMMAND, DataValue(str.c_str(), (int) str.length())); } } }