Skip navigation
2958 Views 11 Replies Latest reply: Dec 10, 2008 8:08 AM by Coolcat RSS
chiodi84 Bronze 10 posts since
Dec 9, 2008
Currently Being Moderated

Dec 9, 2008 2:02 AM

replace message body in packetinterceptor

hi all.

i'm trying to create a packetinterceptor plugin.

just for a test i'd like to replace the body of all chat messages to the string "test". i've simply tried to do message.setBody("test") but it doesnt work: i receive always the original body.

the packet interceptor is correctly registered and receiving notifications.


thank you,

Paolo

 

ps:

this is my code:

 

public void interceptPacket(Packet packet, Session session, boolean incoming, boolean processed) throws PacketRejectedException
 {
 if(packet instanceof Message)
 {
 Log.error("TD Message");
 if(((Message)packet).getType() == Message.Type.chat)
 {
 if(!processed)
 {
 Log.debug("TD Body: " + ((Message)packet).getBody());
 if(((Message)packet).getBody() != null)
 {
 ((Message)packet).setBody("test");
 Log.debug("TD Changing");
 }
 }
 }
 }
 }

More Like This

  • Retrieving data ...

Bookmarked By (0)

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points