package com.qq.weixin.sdk.message.handler;
import org.w3c.dom.Element;
import com.qq.weixin.sdk.message.Message;
import com.qq.weixin.sdk.message.MessageEvent;
import com.qq.weixin.sdk.message.filter.FilterChain;
import com.qq.weixin.sdk.message.filter.FilterDefaultResult;
import com.qq.weixin.sdk.message.filter.FilterGreeting;
/**
* handle event message
*
* @author hujiawei
*
*/
public class MessageHandlerEvent extends MessageHandlerHelper {
@Override
public Message handleSpecialMessage(Message message) {
FilterChain filterChain = new FilterChain();
filterChain.addFilter(new FilterGreeting());// I do not check if it is "subscribe"
filterChain.addFilter(new FilterDefaultResult());// add this,so the next line does not have to verify whether result is null or not
return filterChain.doFilterChain(message);
}
@Override
protected void parseSpecialMessage(Message message, Element root) {
MessageEvent messageEvent = (MessageEvent) message;
messageEvent.setEvent(root.getElementsByTagName(TAG_EVENT).item(0).getTextContent());
messageEvent.setEventKey(root.getElementsByTagName(TAG_EVENTKEY).item(0).getTextContent());
}
}