Expand my Community achievements bar.

Custom Message Service adapter

Avatar

Level 2
Hi,



anybody knows where can I find some serious documentation
about how to create custom message service adapters?

I tried the sample from the lcds dev guide, it works fine,
but i need to use subscription handling, but not found it anywhere
how to realize one...

Can anybody point me where can i find one, or how to do this?



I already override the handlesSubscriptions(), and manage()
methods. The manage() is being called, but dont know what to do
there...



Thanx
3 Replies

Avatar

Former Community Member
Did you figure this out? If not, could you elaborate more on
what you're trying to achieve with the custom adapter?

Avatar

Level 2
I needed the custom adapter to send 3 messages to 3subscribed
users. The message contains each users name...



The adapter code is something like this(not like a pro but
working)



private Vector messages = new Vector();



public Object invoke(Message message)

{

MessageService msgService =
(MessageService)getDestination().getService();



String header = message.getHeader("msgType").toString();



if (header.equals("playerData")) {



i = i + 1;

Integer j = new Integer(i);



//NEEDED ONLY IN CLUSTERED ENVIRONMENT

//msgService.sendPushMessageFromPeer(message, true);



messages.add(message);

if (i == 3) {

i = 0;

msgService.pushMessageToClients((Message)messages.get(0),
true);

msgService.pushMessageToClients((Message)messages.get(1),
true);

msgService.pushMessageToClients((Message)messages.get(2),
true);

messages.clear();

return message;

} else {

return null;

}

} else {

msgService.pushMessageToClients(message, true);

return message;

}

}





When the adapter received all the usernames from the
playerData-headered messages, it sends back to all clients. So now
each client knows who is playing with.



cheers