/** {@inheritDoc} */ public override void onHttpStatusOK(QQHttpResponse response) { //{"retcode":0,"result":{"uin":236557647,"cip":1991953329,"index":1075,"port":51494,"status":"online","vfwebqq":"41778677efd86bae2ed575eea02349046a36f3f53298a34b97d75297ec1e67f6ee5226429daa6aa7","psessionid":"8368046764001d636f6e6e7365727665725f77656271714031302e3133332e342e31373200005b9200000549016e04004f95190e6d0000000a4052347371696a62724f6d0000002841778677efd86bae2ed575eea02349046a36f3f53298a34b97d75297ec1e67f6ee5226429daa6aa7","user_state":0,"f":0}} JSONObject json = new JSONObject(new JSONTokener(new StringReader(response.getResponseMessage()))); QQSession session = getContext().getSession(); QQAccount account = (QQAccount)getContext().getAccount(); if (json.getInt("retcode") == 0) { JSONObject ret = json.getJSONObject("result"); account.setUin(ret.getLong("uin")); account.setQQ(ret.getLong("uin")); session.setSessionId(ret.getString("psessionid")); session.setVfwebqq(ret.getString("vfwebqq")); account.setStatus(QQStatus.ONLINE); session.setState(QQSession.State.ONLINE); session.setIndex(ret.getInt("index")); session.setPort(ret.getInt("port")); notifyActionEvent(QQActionEvent.Type.EVT_OK, null); } else { notifyActionEvent(QQActionEvent.Type.EVT_ERROR, new QQException(QQWpfApplication1.action.QQException.QQErrorCode.INVALID_RESPONSE)); //TODO .. } }
/** {@inheritDoc} */ public override void onHttpFinish(QQHttpResponse response) { // 如果返回的内容为空,认为这次pollMsg仍然成功 if (response.getResponseMessage().Length == 0) { notifyActionEvent(QQActionEvent.Type.EVT_OK, new List <QQNotifyEvent>()); } else { base.onHttpFinish(response); } }
/** {@inheritDoc} */ public override void onHttpStatusOK(QQHttpResponse response) { Regex p = new Regex(QQConstants.REGXP_CHECK_VERIFY); String msg = response.getResponseMessage(); Match m = p.Match(msg); if (m.Success) { Console.WriteLine(msg); String qqHex = m.Groups[3].Value; qqHex = qqHex.Replace("\\x", ""); QQActionEventArgs.CheckVerifyArgs args = new QQActionEventArgs.CheckVerifyArgs(); args.result = int.Parse(m.Groups[1].Value); args.code = m.Groups[2].Value; args.uin = long.Parse(qqHex, NumberStyles.AllowHexSpecifier); notifyActionEvent(QQActionEvent.Type.EVT_OK, args); } else { notifyActionEvent(QQActionEvent.Type.EVT_ERROR, QQWpfApplication1.action.QQException.QQErrorCode.UNEXPECTED_RESPONSE); } }