Welcome!

Welcome to the Official BlackBerry Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
New Developer
New Developer
baj
Posts: 11
Registered: ‎11-23-2009
Accepted Solution

Listening to incoming messages from chat server

Hi all,

I am trying to connect to a chat server and send messages to known user id. I am able to connect to server and login and send a message to a user. But I am confused about how to listen to incoming messages.

 

Below is the code which I'm trying.. This code below is written in the run method of a class extending Thread.

 

final StreamConnection connection = (StreamConnection) Connector
 .open("socket://" + this.server + ":" + this.port,Connector.READ_WRITE);
DataOutputStream o = connection.openDataOutputStream();
DataInputStream i = connection.openDataInputStream();
this.writer = new XmlWriter(o);
if(!isLogin){
 this.login(); 
}
this.sendMessage();
int c;
while (true) {
    c = i.read();
    if (c == -1) {
	break;
    } else { 
	System.out.println(String.valueOf(((char) c)));
    }

 

 

I am trying this in 8330 Simulator.  Initially the xml output confirming the authentication is printed but after that i get the exception. 

 

net.rim.device.cldc.io.ippp.SocketBaseIOException: Connection Timed Out

 

Please can anybody help me understand whats wrong. I want to establish a connection so that instant messaging would be possible between the two users.

 

Thanks in advance,

baj

 

 

Please use plain text.
New Developer
New Developer
baj
Posts: 11
Registered: ‎11-23-2009

Re: Listening to incoming messages from chat server

Any pointers, please?

Please use plain text.
New Developer
New Developer
baj
Posts: 11
Registered: ‎11-23-2009

Re: Listening to incoming messages from chat server

Solved with the help of the below open source project:

http://sourceforge.net/projects/kvmjab/

Please use plain text.
Developer
yog123
Posts: 51
Registered: ‎07-15-2008

Re: Listening to incoming messages from chat server

hi,

 

I am facing the same problem .

 

It will be great if u put part of sample code to listen to messages coming from server.

 

Thanks

 

 

Please use plain text.
Developer
yog123
Posts: 51
Registered: ‎07-15-2008

Re: Listening to incoming messages from chat server

Hi,

 

anybody out there ??? 

 

 

Please use plain text.