/// <summary> /// 设置交互标识 /// </summary> /// <param name="sid"></param> public bool SetSessionID(string sid) { bool res = false; // 发送设置指令 _client.Sendln("SID"); _client.Sendln($"@{sid.Length}"); _client.Send(sid, (string data) => { // 判断是否成功 if (data.StartsWith("+")) { res = true; this.SessionID = data.Substring(1); } }); return(res); }
/// <summary> /// 实例化一个交互连接 /// </summary> /// <param name="ip"></param> /// <param name="port"></param> /// <param name="pwd"></param> public Session(string ip, int port, string pwd) { _client = new ssr.Client(new Host(), ip, port); _cache = new Dictionary <string, string>(); // 执行登录 _client.Sendln("PWD"); _client.Sendln($"${pwd.Length}"); _client.Send(pwd, (string data) => { // 判断是否成功 if (data.StartsWith("-")) { throw new Exception(data.Substring(1)); } }); }