Esempio n. 1
0
        public override void OnHttpStatusOK(QQHttpResponse response)
        {
            //{"retcode":0,"result":{"dnamelist":[{"did":3536443553,"name":"\u8FD9\u662F\u6807\u9898"},
            //{"did":625885728,"name":""}],"dmasklist":[{"did":1000,"mask":0}]}}

            JObject json  = JObject.Parse(response.GetResponseString());
            QQStore store = Context.Store;

            if (json["retcode"].ToString() == "0")
            {
                JObject result  = json["result"].ToObject <JObject>();
                JArray  dizlist = result["dnamelist"].ToObject <JArray>();
                for (int i = 0; i < dizlist.Count; i++)
                {
                    QQDiscuz discuz  = new QQDiscuz();
                    JObject  dizjson = dizlist[i].ToObject <JObject>();
                    discuz.Did  = dizjson["did"].ToObject <long>();
                    discuz.Name = dizjson["name"].ToString();
                    store.AddDiscuz(discuz);
                }
                NotifyActionEvent(QQActionEventType.EVT_OK, store.GetDiscuzList());
            }
            else
            {
                NotifyActionEvent(QQActionEventType.EVT_ERROR, new QQException(QQErrorCode.UNEXPECTED_RESPONSE));
            }
        }
Esempio n. 2
0
        public override void OnHttpStatusOK(QQHttpResponse response)
        {
            JObject json  = JObject.Parse(response.GetResponseString());
            QQStore store = Context.Store;

            if (json["retcode"].ToString() == "0")
            {
                JObject result = json["result"].ToObject <JObject>();

                //result/info
                JObject info = result["info"].ToObject <JObject>();
                discuz.Name  = info["discu_name"].ToString();
                discuz.Owner = info["discu_owner"].ToObject <long>();

                //result/mem_list
                JArray memlist = result["mem_info"].ToObject <JArray>();
                foreach (JToken t in memlist)
                {
                    JObject        memjson = t.ToObject <JObject>();
                    QQDiscuzMember member  = discuz.GetMemberByUin(memjson["uin"].ToObject <long>());
                    if (member == null)
                    {
                        member = new QQDiscuzMember();
                        discuz.AddMemeber(member);
                    }
                    member.Uin      = memjson["uin"].ToObject <long>();
                    member.QQ       = memjson["uin"].ToObject <long>(); //这里有用户真实的QQ号
                    member.Nickname = memjson["nick"].ToString();
                    member.Discuz   = discuz;
                }

                // 消除所有成员状态,如果不在线的,webqq是不会返回的。
                discuz.ClearStatus();
                //result/mem_status
                JArray statlist = result["mem_status"].ToObject <JArray>();
                foreach (JToken t in statlist)
                {
                    // 下面重新设置最新状态
                    JObject statjson = t.ToObject <JObject>();
                    QQUser  member   = discuz.GetMemberByUin(statjson["uin"].ToObject <long>());
                    if (statjson["client_type"] != null && member != null)
                    {
                        member.ClientType = QQClientType.ValueOfRaw(statjson["client_type"].ToObject <int>());
                        member.Status     = QQStatus.ValueOfRaw(statjson["status"].ToString());
                    }
                }

                //result/mem_info
                JArray infolist = result["mem_info"].ToObject <JArray>();
                foreach (JToken t in infolist)
                {
                    JObject infojson = t.ToObject <JObject>();
                    QQUser  member   = discuz.GetMemberByUin(infojson["uin"].ToObject <long>());
                    member.Nickname = infojson["nick"].ToString();
                }

                NotifyActionEvent(QQActionEventType.EVT_OK, store.GetDiscuzList());
            }
            else
            {
                NotifyActionEvent(QQActionEventType.EVT_ERROR, new QQException(QQErrorCode.UNEXPECTED_RESPONSE));
            }
        }