String pollType = poll.getString("poll_type");
JSONObject pollData = poll.getJSONObject("value");
if (pollType.equals("input_notify")) {
long fromUin = pollData.getLong("from_uin");
QQBuddy buddy = store.getBuddyByUin(fromUin);
notifyEvents.add(new QQNotifyEvent(
QQNotifyEvent.Type.BUDDY_INPUT, buddy));
} else if (pollType.equals("message")) {
// 好友消息
notifyEvents.add(processBuddyMsg(pollData));
} else if (pollType.equals("group_message")) {
// 群消息
notifyEvents.add(processGroupMsg(pollData));
} else if (pollType.equals("discu_message")) {
// 讨论组消息
notifyEvents.add(processDiscuzMsg(pollData));
} else if (pollType.equals("sess_message")) {
// 临时会话消息
notifyEvents.add(processSessionMsg(pollData));
} else if (pollType.equals("shake_message")) {
// 窗口震动
long fromUin = pollData.getLong("from_uin");
QQUser user = getContext().getStore().getBuddyByUin(
fromUin);
notifyEvents.add(new QQNotifyEvent(
QQNotifyEvent.Type.SHAKE_WINDOW, user));
} else if (pollType.equals("kick_message")) {
// 被踢下线
getContext().getAccount().setStatus(QQStatus.OFFLINE);
getContext().getSession().setState(
QQSession.State.KICKED);
notifyEvents.add(new QQNotifyEvent(
QQNotifyEvent.Type.KICK_OFFLINE, pollData
.getString("reason")));
} else if (pollType.equals("buddies_status_change")) {
notifyEvents.add(processBuddyStatusChange(pollData));
} else {
// TODO ...
LOG.warn("unknown pollType: " + pollType);
}
}
}
// end recode == 0
} else if (retcode == 102) {
// 接连正常,没有消息到达 {"retcode":102,"errmsg":""}
// 继续进行下一个消息请求
} else if (retcode == 110 || retcode == 109) { // 客户端主动退出
getContext().getSession().setState(QQSession.State.OFFLINE);
} else if (retcode == 116) {
// 需要更新Ptwebqq值,暂时不知道干嘛用的
// {"retcode":116,"p":"2c0d8375e6c09f2af3ce60c6e081bdf4db271a14d0d85060"}
// if (a.retcode === 116) alloy.portal.setPtwebqq(a.p)
getContext().getSession().setPtwebqq(json.getString("p"));
} else if (retcode == 121 || retcode == 120 || retcode == 100) { // 121,120 : ReLinkFailure 100 : NotReLogin
// 服务器需求重新认证
// {"retcode":121,"t":"0"}
LOG.info("**** NEED_REAUTH retcode: " + retcode + " ****");
getContext().getSession().setState(QQSession.State.OFFLINE);
QQException ex = new QQException(QQException.QQErrorCode.INVALID_LOGIN_AUTH);
notifyActionEvent(QQActionEvent.Type.EVT_ERROR, ex);
return ;
//notifyEvents.add(new QQNotifyEvent(QQNotifyEvent.Type.NEED_REAUTH, null));
} else {
LOG.error("**Reply retcode to author**");
LOG.error("***************************");
LOG.error("Unknown retcode: " + retcode);
LOG.error("***************************");
// 返回错误,核心遇到未知recode
// getContext().getSession().setState(QQSession.State.ERROR);
notifyEvents.add(new QQNotifyEvent(QQNotifyEvent.Type.UNKNOWN_ERROR, json));
}
notifyActionEvent(QQActionEvent.Type.EVT_OK, notifyEvents);
}