If anyone is using JabberBeans, I would certainly appreciate you taking a look at this:
I'm trying to build a simple client, at the moment everything is quite static (until I get things right).
I can't seem to send the Message Packet to the other client (pre-set into code).. nothing seems to happen. Is the code correct?
public class KeyEventAlgorithm extends Connection implements KeyListener, ActionListener {
//Create a MessengerBean using the existing ConnectionBean within Connection Class
//MessengerBean msgBean = new MessengerBean( cb );//Didn't work!
//Thread test
private String thread;
{ thread = Long.toHexString( ( new java.util.Random() ).nextLong() ) ; }
public KeyEventAlgorithm() {
}
//Listener method for KeyEventListener
public void keyPressed( KeyEvent e ) {
}
//Listener method for KeyEventListener
public void keyReleased( KeyEvent e ) {
}
//Listener method for KeyEventListener
public void keyTyped( KeyEvent e ) {
pushPacket( e );
}
//Listener method for ActionListener
public void actionPerformed( ActionEvent e ) {
}
//Method to push <body> packet to other client
protected void pushPacket( KeyEvent e ) {
char c[] = { e.getKeyChar() };
String s1 = new String ( c );
System.out.println( s1 );
//Create new Instance of MessageBuilder
MessageBuilder msgBuild = new MessageBuilder();
//Create new Instance of Message
Message message;
msgBuild.reset();
JID jid = new JID( "adrianxp", "jabber.org", "home" );
JID jid1 = new JID( "adrian2000", "jabber.org", "work");
msgBuild.setFromAddress( jid1 );
msgBuild.setToAddress( jid );
msgBuild.setThread( thread );
msgBuild.setSubject( "Test client" );
msgBuild.setType( "normal" );
msgBuild.setBody( s1 );
try {
//Build Message Packet from MessageBuilder
message = ( Message ) msgBuild.build();
//Sends Message Packet
cb.send( message );
}
catch( InstantiationException g ) {
System.out.println( "Failed to build Message Packet");
}
}
}
- Re: [JDEV] Client using JabberBeans.. Adrian Brown
- Re: [JDEV] Client using JabberBeans.. Adrian Blakey
