Send message to client while client has session

Dear all,

I am starting to use and modify wildfire source code for my server.

I use instant message to transport my transaction by subject defined as key response server.

Exp: client send message subject defined “AccBal” to client self for action to know current account balance of client. Then the server will catch the Subject defined “AccBall” to collect data from database then send back to client.

Client send message format to server like:

081009 is username of client who ask to server, so this is like send message to self.

I modify in like this:

public void route(Message packet) {

if (packet == null) {

throw new NullPointerException();


Session session = sessionManager.getSession(packet.getFrom());

if (session == null

|| session.getStatus() == Session.STATUS_AUTHENTICATED)


JID recipientJID = packet.getTo();

// Check if the message was sent to the server hostname

if (recipientJID != null && recipientJID.getNode() == null &&

recipientJID.getResource() == null &&

serverName.equals(recipientJID.getDomain())) {

if (packet.getElement().element(“addresses”) != null) {

// Message includes multicast processing instructions. Ask the multicastRouter

// to route this packet



else {

// Message was sent to the server hostname so forward it to a configurable

// set of JID’'s (probably admin users)





String Ssubject = packet.getSubject();

try {

String username = packet.getTo().toString();

Date creationDate = new Date();

if (Ssubject.compareTo(“AccBal”)==0)



System.out.println(“this is the packet”+packet);

OnlineMessageStore test = new OnlineMessageStore();


OnlineMessage message = null;

message = test.getMessage(username, creationDate);

System.out.println("Before send to client "+ message);









catch (Exception e) {

try {

// if (Ssubject.compareTo(“AccBal”)!=0)

// {



// }


catch (Exception e1) {





else {




try {



catch (UnauthorizedException ue) {





I was copy OfflineMessage**.java to OnlineMessage**.java in order to keep original process and in order to process additional client transaction request.

Below is little code:

public OnlineMessage getMessage(String username, Date creationDate) {

OnlineMessage message = null;

Message smess= null,smess1= null;

Connection con = null;

PreparedStatement pstmt = null;

SAXReader xmlReader = null;

if (subject.compareTo(“AccBal”)==0)


try {

String msgXML = “”;

// Get a sax reader from the pool

xmlReader = xmlReaders.take();

con = DbConnectionManager.getConnection();

pstmt = con.prepareStatement(SELECT_accbal);

pstmt.setString(1, username);

//pstmt.setString(2, StringUtils.dateToMillis(creationDate));

ResultSet rs = pstmt.executeQuery();

while ( {

msgXML = rs.getString(1);

//g = new

//JID recipient = message.getTo();

smess = new Message();





message =

new OnlineMessage(creationDate, StringReader(smess.toString())).getRootElement());

// Add a delayed delivery (JEP-0091) element to the message.

Element delay = message.addChildElement(“x”, “jabber:x:delay”);

delay.addAttribute(“from”, XMPPServer.getInstance().getServerInfo().getName());

delay.addAttribute(“stamp”, dateFormat.format(creationDate));




catch (Exception e) {

Log.error("Error retrieving online messages of username: " + username +

" creationDate: " + creationDate, e);


finally {

// Return the sax reader to the pool

if (xmlReader != null) xmlReaders.add(xmlReader);

try { if (pstmt != null) { pstmt.close(); } }

catch (Exception e) { Log.error(e); }

try { if (con != null) { con.close(); } }

catch (Exception e) { Log.error(e); }



System.out.println(“before leave OnlineMessageStore at getMessage function”+message);

return message;


I can’t send back to client while the client is online / have session. The message only can be send to client after the client sign out and rejoin to server.

I need send response from server real time to client while the client has the session like send message to self.

Kindly help me to solve this problem.

Any way where I can get the wildfire UML?

Thank you