Examples of XMLLightweightParser


Examples of org.jivesoftware.openfire.nio.XMLLightweightParser

  @Override
  public void sessionOpened(IoSession session) throws Exception {
    log.info("client===>session 打开会话开始! session id:"+session.getId());
    // 初始化一个xml解析器,放到session上下文中
    XMLLightweightParser parser = new XMLLightweightParser("UTF-8");
      session.setAttribute(XML_PARSER, parser);
  }
View Full Code Here

Examples of org.jivesoftware.openfire.nio.XMLLightweightParser

public class XmppDecoder extends CumulativeProtocolDecoder {
  @Override
  protected boolean doDecode(IoSession session, IoBuffer in,ProtocolDecoderOutput out) throws Exception {
    //XMLLightweightParser 是一個輕量級xml解析器
    //session创建的时候,初始化的这个解析器实例:XMLLightweightParser parser = new XMLLightweightParser("UTF-8");
        XMLLightweightParser parser = (XMLLightweightParser) session
                                       .getAttribute(XmppIoHandler.XML_PARSER); // 二进制格式转换为xml
            parser.read(in);
         // 判断是否还有数据可读取
        if (parser.areThereMsgs()) {
          // 将二进制数据转解析成xml
            for (String stanza : parser.getMsgs()) {
                out.write(stanza);
            }
        }
        return !in.hasRemaining();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.