//private static void ConfigureCertificateValidatation( // bool validateCertificates, // out System.Net.SecurityProtocolType protocolType, // out RemoteCertificateValidationCallback prevValidator) // { // prevValidator = null; // protocolType = (System.Net.SecurityProtocolType)0; // if (!validateCertificates) // { // protocolType = System.Net.ServicePointManager.SecurityProtocol; // System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls; // prevValidator = System.Net.ServicePointManager.ServerCertificateValidationCallback; // System.Net.ServicePointManager.ServerCertificateValidationCallback = (sender, cert, chain, sslPolicyErrors) => true; // } // } public static void DoLoginReqAction(AuthPackageReq cmd, LoginAuthRespCallBack cb) { respcb = cb; LoginwReqPack req = new LoginwReqPack(); req.parms = JsonMapper.ToJson(cmd); string jsonStr = JsonMapper.ToJson(req); IHttpContent content = new StringContent(jsonStr, System.Text.Encoding.UTF8, "application/json"); client.Post(new Uri(url), content, HttpCompletionOption.AllResponseContent, r => { if (r.IsSuccessStatusCode) { var respStr = r.ReadAsString(); try { AuthPackageResp resp = JsonMapper.ToObject <AuthPackageResp>(respStr); respcb(resp); } catch (Exception e) { SkynetLogger.Error(Channel.NetDevice, "Json Deserialize err:" + e.Message.ToString()); } } }); }
private void DoLoginRespAction(AuthPackageResp resp) { string str = DebugHelper.DumpJson <AuthPackageResp>(resp); Debug.Log(str); //NLog.Log.Debug("+++++DoLoginRespAction Resp+++++++++" + resp.gate); }
private void LoginResult(string socketstr) { AuthPackageResp resp = new AuthPackageResp(); var code = int.Parse(socketstr.Substring(0, 3)); var subidByte = Crypt.Base64Decode(socketstr.Substring(4)); var resultString = Encoding.UTF8.GetString(subidByte); if (code == 200) { var split = Regex.Split(resultString, "['$']"); resp.gate = split[0]; resp.port = Int32.Parse(split[1]); resp.uid = split[2]; resp.secret = split[3]; resp.subid = split[4]; } // Debug.Log("login result code:" + code); // Debug.Log("login result gate:" + resp.gate); // Debug.Log("login result port:" + resp.port); // Debug.Log("login result uid:" + resp.uid); // Debug.Log("login result subid:" + resp.subid); // Debug.Log("login result secret:" + resp.secret); _state = LoginAuthState.LoginFinished; OnLoginCallBack?.Invoke(code, resp); }
public void Run(AuthPackageResp req) { _req = req; _client = new GateTcpClient(NetWorkStateCallBack); //服务器验证成功标识 _client.On("verify", VerifySucess); _client.Connect(_req.gate, _req.port); }
private void ProcessLoginResp(int code, AuthPackageResp resp) { _login.DisConnect(); if (code == 200) { if (Protocol == "tcp") { _gateTcp = new TestGateTcp(); _gateTcp.Run(resp); } else { _gateWs = new TestGateWs(); _gateWs.Run(resp); } Signals.Get <UdpSignal>().AddListener(SignalUdp); } _login = null; }