The xml that i need to receive is :
<message id="qm5Dx8" to="adsfxcv" type="chat"from="adsf"
msgType="2"
thumbnail="randomThumbnail"
serverMediaURL="random"
isFromMe="1"
status="1"><body>Image</body><request xmlns='urn:xmpp:receipts'/></message>
消息正在发送的 MyCustomMessage扩展信息类。
在我的消息监听器,在那里我需要得到该数据包是:
In my message listener, Where i need to get the packet is :
public void processPacket(Packet packet) {
String recivedPacket = packet.toXML();
try {
if (packet instanceof MyCustomMessage) {
MyCustomMessage msg = (MyCustomMessage) packet;
....
但我在邮件标签仅接收ID,来,类型和距离。和数据包的实例也是消息和它说,不能施放包的消息。 PLZ指导我怎样才能收到我的希望的分组。
But I am receiving only id,to,type and from in message tag. And the instance of packet is also of Message and it says , cannot cast packet to message. plz guide me how can i receive my desired packet.
推荐答案
您不能。你也永远不应该延长消息
或 presence
类。
You can't. Also you should never extend the Message
or Presence
class.
从不添加自定义值,指定的流元素属性(例如消息类型属性的新值),从来没有增加新的属性,顶级元素(像你一样与 MSGTYPE
, msgTimeStamp
等)。
Never add custom values to specified stream element attributes (e.g. a new value for the type attribute of messages), and never add new attributes to top level elements (like you did with msgType
, msgTimeStamp
and so on).
这已经打破东西的潜力!不这样做。另请参见XEP-0134:XMPP设计指南第2.1 XMPP是神圣的。这就是为什么它是不可能在拍击。相反,使用自定义扩展元素,像xnyhps显示,他的例子(数据
元素)。另请参见RFC 6120§8.4扩展内容那些被称为 PacketExtension 的中啪。
This has the potential to break things! Don't do it. See also "XEP-0134: XMPP Design Guidelines § 2.1 XMPP is Sacred". That's why it's not possible in Smack. Instead, use a custom extension element, like xnyhps showed in his example (the data
element). See also "RFC 6120 § 8.4 Extended Content" Those are called PacketExtension's in Smack.
另请参阅这个答案和问题。
相关推荐
最新文章