1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-26 14:02:06 +01:00

Doc fixes (SMACK-277)

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@8428 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Matt Tucker 2007-06-01 21:42:38 +00:00 committed by matt
parent 41b4308936
commit c5ab2829d4
3 changed files with 30 additions and 26 deletions

View file

@ -96,7 +96,7 @@ and "out fishing":<p>
<div class="code"> <div class="code">
<pre> <pre>
<font color="gray"><i>// Create a new presence. Pass in false to indicate we're unavailable.</i></font> <font color="gray"><i>// Create a new presence. Pass in false to indicate we're unavailable.</i></font>
Presence presence = new Presence(Presence.Type.UNAVAILABLE); Presence presence = new Presence(Presence.Type.unavailable);
presence.setStatus(<font color="green">"Gone fishing"</font>); presence.setStatus(<font color="green">"Gone fishing"</font>);
<font color="gray"><i>// Send the packet (assume we have a XMPPConnection instance called "con").</i></font> <font color="gray"><i>// Send the packet (assume we have a XMPPConnection instance called "con").</i></font>
con.sendPacket(presence); con.sendPacket(presence);
@ -115,7 +115,7 @@ XMPPConnection instance.
<p><div class="footer"> <p><div class="footer">
Copyright &copy; Jive Software 2002-2005 Copyright &copy; Jive Software 2002-2007
</div> </div>
</body> </body>

View file

@ -30,14 +30,20 @@ following code snippet demonstrates how to create a new Chat with a user and the
them a text message:<p> them a text message:<p>
<div class="code"><pre><font color="gray"><i>// Assume we've created an XMPPConnection name "connection".</i></font> <div class="code"><pre><font color="gray"><i>// Assume we've created an XMPPConnection name "connection".</i></font>
ChatManager chatmanager = connection.getChatManager();<br>Chat newChat = chatmanager.createChat(<font ChatManager chatmanager = connection.getChatManager();
Chat newChat = chatmanager.createChat(<font
color="green">"jsmith@jivesoftware.com"</font>, new MessageListener() { color="green">"jsmith@jivesoftware.com"</font>, new MessageListener() {
public void processMessage(Chat chat, Message message) { public void processMessage(Chat chat, Message message) {
System.out.println(<font color="green">"Received message: "</font> + message); System.out.println(<font color="green">"Received message: "</font> + message);
} }
}); <br>try { });
chat.sendMessage(<font color="green">"Howdy!"</font>); <br>} catch (XMPPException e) {<br> System.out.println(&quot;Error Delivering block&quot;);<br>}<br><br>
try {
newChat.sendMessage(<font color="green">"Howdy!"</font>);
}
catch (XMPPException e) {
System.out.println(<font color="green">"Error Delivering block"</font>);
}
</pre> </pre>
</div> </div>
<p> <p>
@ -51,7 +57,7 @@ ChatManager chatmanager = connection.getChatManager();<br>Chat newChat = chatman
<p> <p>
<div class="code"><pre> <div class="code"><pre>
Message newMessage = newChat.createMessage(); Message newMessage = new Message();
newMessage.setBody(<font color="green">"Howdy!"</font>); newMessage.setBody(<font color="green">"Howdy!"</font>);
message.setProperty(<font color="green">"favoriteColor"</font>, <font color="green">"red"</font>); message.setProperty(<font color="green">"favoriteColor"</font>, <font color="green">"red"</font>);
newChat.sendMessage(newMessage); newChat.sendMessage(newMessage);

View file

@ -37,9 +37,10 @@ Every user in a roster is represented by a RosterEntry, which consists of:<ul>
The following code snippet prints all entries in the roster: The following code snippet prints all entries in the roster:
<pre> <pre>
Roster roster = con.getRoster(); Roster roster = connection.getRoster();
<b>for</b> (Iterator i=roster.getEntries(); i.hasNext(); ) { Collection&lt;RosterEntry&gt; entries = roster.getEntries();
System.out.println(i.next()); for (RosterEntry entry : entries) {
System.out.println(entry);
} }
</pre> </pre>
@ -77,16 +78,13 @@ similar code to update the roster UI with the changing information.
<br clear="all"> <br clear="all">
<pre> <pre>
final Roster roster = con.getRoster(); Roster roster = con.getRoster();
roster.addRosterListener(new RosterListener() { roster.addRosterListener(new RosterListener() {
<b>public void</b> rosterModified() { // Ignored events public void entriesAdded(Collection&lt;String&gt; addresses) {}
<font color="gray"><i>// Ignore event for this example.</i></font> public void entriesDeleted(Collection&lt;String&gt; addresses) {}
} public void entriesUpdated(Collection&lt;String&gt; addresses) {}
public void presenceChanged(Presence presence) {
<b>public void</b> presenceChanged(String user) { System.out.println("Presence changed: " + presence.getFrom() + " " + presence);
<font color="gray"><i>// If the presence is unavailable then "null" will be printed,
// which is fine for this example.</i></font>
System.out.println(<font color="green">"Presence changed: "</font> + roster.getPresence(user));
} }
}); });
</pre> </pre>
@ -108,17 +106,17 @@ in one of three ways: <ul>
<li> Process presence subscription requests manually. <li> Process presence subscription requests manually.
</ul> </ul>
The mode can be set using the <tt>Roster.setSubscriptionMode(int subscriptionMode)</tt> The mode can be set using the <tt>Roster.setSubscriptionMode(Roster.SubscriptionMode)</tt>
method. Simple clients normally use one of the automated subscription modes, while method. Simple clients normally use one of the automated subscription modes, while
full-featured clients should manually process subscription requests and let the full-featured clients should manually process subscription requests and let the
end-user accept or reject each request. If using the manual mode, a PacketListener end-user accept or reject each request. If using the manual mode, a PacketListener
should be registered that listens for Presence packets that have a type of should be registered that listens for Presence packets that have a type of
<tt>Presence.Type.SUBSCRIBE</tt>. <tt>Presence.Type.subscribe</tt>.
<br clear="all" /><br><br> <br clear="all" /><br><br>
<div class="footer"> <div class="footer">
Copyright &copy; Jive Software 2002-2004 Copyright &copy; Jive Software 2002-2007
</div> </div>
</body> </body>