我安卓端 使用 smack4.1.4 对message 扩展一个节点 <ext>
private String orderID;
public String getOrderID() {
return orderID;
}
public void setOrderID(String orderID) {
this.orderID = orderID;
}
@Override
public String getElementName() {
// TODO Auto-generated method stub
return "ext";
}
@Override
public String getNamespace() {
return "ihelper:chat:text";
}
@Override
public String toXML() {
StringBuilder sb = new StringBuilder();
sb.append("<ext");
sb.append(" xmlns=");
sb.append("'ihelper:chat:text'");
sb.append(">");
sb.append("<orderID>");
sb.append(orderID);
sb.append("</orderID>");
sb.append("</ext>");
return sb.toString();
}
}
下面的时候对 扩展节点的解析
public class ExtProvider extends DataPacketProvider.PacketExtensionProvider {
private String orderID;
private String url;
private String type;
public ExtensionElement parseExtension(XmlPullParser parser)
throws Exception {
Ext ext = new Ext();
StringBuffer buffer = new StringBuffer();
boolean done = false;
while (!done) {
int eventType = parser.getEventType();
switch (eventType) {
case XmlPullParser.START_TAG:
String startTag = parser.getName();
switch (startTag) {
case "orderID":
orderID = parser.nextText();
break;
}
break;
case XmlPullParser.END_TAG:
String endTag = parser.getName();
switch (endTag) {
case "ext":
done = true;
break;
}
break;
}
}
ext.setOrderID(orderID);
return ext;
}
}
当对方给我发来消息的时候 报
12-21 21:59:50.822: W/AbstractXMPPConnection(5312): java.lang.NumberFormatException: Invalid long: "null"
12-21 21:59:50.822: W/AbstractXMPPConnection(5312): at java.lang.Long.invalidLong(Long.java:125)
12-21 21:59:50.822: W/AbstractXMPPConnection(5312): at java.lang.Long.parseLong(Long.java:342)
12-21 21:59:50.822: W/AbstractXMPPConnection(5312): at java.lang.Long.parseLong(Long.java:319)
12-21 21:59:50.822: W/AbstractXMPPConnection(5312): at org.jivesoftware.smackx.bytestreams.ibb.provider.DataPacketProvider$PacketExtensionProvider.parse(DataPacketProvider.java:56)
12-21 21:59:50.822: W/AbstractXMPPConnection(5312): at org.jivesoftware.smackx.bytestreams.ibb.provider.DataPacketProvider$PacketExtensionProvider.parse(DataPacketProvider.java:49)
12-21 21:59:50.822: W/AbstractXMPPConnection(5312): at org.jivesoftware.smack.provider.Provider.parse(Provider.java:35)
12-21 21:59:50.822: W/AbstractXMPPConnection(5312): at org.jivesoftware.smack.util.PacketParserUtils.parseExtensionElement(PacketParserUtils.java:929)
12-21 21:59:50.822: W/AbstractXMPPConnection(5312): at org.jivesoftware.smack.util.PacketParserUtils.addExtensionElement(PacketParserUtils.java:1060)
12-21 21:59:50.822: W/AbstractXMPPConnection(5312): at org.jivesoftware.smack.util.PacketParserUtils.parseMessage(PacketParserUtils.java:287)
12-21 21:59:50.822: W/AbstractXMPPConnection(5312): at org.jivesoftware.smack.util.PacketParserUtils.parseStanza(PacketParserUtils.java:151)
12-21 21:59:50.822: W/AbstractXMPPConnection(5312): at org.jivesoftware.smack.AbstractXMPPConnection.parseAndProcessStanza(AbstractXMPPConnection.java:956)
12-21 21:59:50.822: W/AbstractXMPPConnection(5312): at org.jivesoftware.smack.tcp.XMPPTCPConnection.access$500(XMPPTCPConnection.java:140)
12-21 21:59:50.822: W/AbstractXMPPConnection(5312): at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:989)
12-21 21:59:50.822: W/AbstractXMPPConnection(5312): at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$300(XMPPTCPConnection.java:944)
12-21 21:59:50.822: W/AbstractXMPPConnection(5312): at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnection.java:959)
12-21 21:59:50.822: W/AbstractXMPPConnection(5312): at java.lang.Thread.run(Thread.java:841)
请问 是不是 我写的扩展节点以及解析不对
是不是应该继承DataPacketExtension来写扩展节点呢 有使用过smack4.1.4 对message进行扩展的前辈吗 求指教。谢谢
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
异常信息很明显啊,传递了null