From bd07f5a9aa784f3babf729e5678fa52734cfe832 Mon Sep 17 00:00:00 2001 From: Matt Tucker Date: Fri, 17 Jan 2003 18:37:44 +0000 Subject: [PATCH] API fixes. git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@1809 b35dd754-fafc-0310-a699-88a17e54d16e --- documentation/gettingstarted.html | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/documentation/gettingstarted.html b/documentation/gettingstarted.html index a9bf8bb05..a12852706 100644 --- a/documentation/gettingstarted.html +++ b/documentation/gettingstarted.html @@ -58,7 +58,7 @@ Working with the Roster CONTENT COMING SOON

-Packets, the PacketReader, and the PacketWriter +Packets -- Reading and Writing

Each message to the XMPP server from a client is called a packet and is @@ -67,25 +67,28 @@ classes that encapsulate the different packet types allowed by XMPP (message, presence, and IQ). Classes such as Chat and GroupChat provide higher-level constructs that manage creating and sending packets automatically, but you can also create and send packets directly. Below -is a code example for changing the presence to let people we're unavailable -because we're out fishing:

+is a code example for changing our presence to let people know we're unavailable +because we're "out fishing":

 // Create a new presence. Pass in false to indicate we're unavailable.
-Presence presence = new Presence(false);
+Presence presence = new Presence(Presence.Type.UNAVAILABLE);
 presence.setStatus("Gone fishing");
 // Send the packet (assume we have a XMPPConnection instance called "con").
-con.getPacketWriter().sendPacket(presence);
+con.sendPacket(presence);
 

-Every connection has a PacketReader and PacketWriter. The -packet reader listens for XML data from the server and parses it into -individual packets. You can listen for incoming packets by registering -PacketWatcher objects with the packet reader. The packet writer -is responsible for writing packets to the server. It takes Packet -objects and converts them to XML before sending them over the network. +Smack provides two ways to read incoming packets: PacketListener, and +PacketCollector. Both use PacketFilter instances to determine +which packets should be processed. A packet listener is used for event style programming, +while a packet collector has a result queue of packets that you can do +polling and blocking operations on. So, a packet listener is useful when +you want to take some action whenever a packet happens to come in, while a +packet collector is useful when you want to wait for a specific packet +to come through. Packet collectors and listeners can be created using the +connection object.