Note that there are some explanatory texts on larger screens.

plurals
  1. POJava Sockets and Blackberry programming
    primarykey
    data
    text
    <p>i'm new to programming and I'm trying to build a blackberry IRC Client, I made it connect to a server, join a channel and say something, but how can I receive messages ? I don't know how to make a loop to wait for messages, can somebody help me ? here is my code:</p> <pre><code>package com.rim.samples.device.socketdemo; import java.io.*; import javax.microedition.io.*; import net.rim.device.api.ui.*; public class ConnectThread extends Thread { private InputStream _in; private OutputStreamWriter _out; private SocketDemoScreen _screen; // Constructor public ConnectThread() { _screen = ((SocketDemo)UiApplication.getUiApplication()).getScreen(); } public void run() { StreamConnection connection = null; String user = "Cegooow"; String channel = "#oi"; try { _screen.updateDisplay("Opening Connection..."); String url = "socket://" + _screen.getHostFieldText() + ":6667" + (_screen.isDirectTCP() ? ";deviceside=true" : ""); connection = (StreamConnection)Connector.open(url); _screen.updateDisplay("Connection open"); _in = connection.openInputStream(); _out = new OutputStreamWriter(connection.openOutputStream()); StringBuffer s = new StringBuffer(); _out.write("NICK " + _screen.getNickText() + "\r\n"); _out.write("USER " + user + "8 * : Java Bot\r\n"); _out.write("JOIN " + channel + "\r\n"); _out.write("PRIVMSG " + channel + " " + _screen.getMessageFieldText() + "\r\n"); _screen.updateDisplay("Done!"); } catch(IOException e) { System.err.println(e.toString()); } finally { _screen.setThreadRunning(false); try { _in.close(); } catch(IOException ioe) { } try { _out.close(); } catch(IOException ioe) { } try { connection.close(); } catch(IOException ioe) { } } } } </code></pre> <p>I used the sockets demo sample on blackerry jre, thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload