packetReader.shutdown();
final PacketWriter pw = connection.new PacketWriter(); connection.packetWriter = pw; connection.packetReader = connection.new PacketReader(); connection.setWriter(new BlockingStringWriter()); pw.init();
/** * Initializes the connection by creating a stanza reader and writer and opening a * XMPP stream to the server. * * @throws XMPPException if establishing a connection to the server fails. * @throws SmackException if the server fails to respond back or if there is anther error. * @throws IOException */ private void initConnection() throws IOException { boolean isFirstInitialization = packetReader == null || packetWriter == null; compressionHandler = null; // Set the reader and writer instance variables initReaderAndWriter(); if (isFirstInitialization) { packetWriter = new PacketWriter(); packetReader = new PacketReader(); } // Start the writer thread. This will open an XMPP stream to the server packetWriter.init(); // Start the reader thread. The startup() method will block until we // get an opening stream packet back from server packetReader.init(); }