1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-12-22 20:47:57 +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">
<pre>
<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>);
<font color="gray"><i>// Send the packet (assume we have a XMPPConnection instance called "con").</i></font>
con.sendPacket(presence);
@ -115,7 +115,7 @@ XMPPConnection instance.
<p><div class="footer">
Copyright &copy; Jive Software 2002-2005
Copyright &copy; Jive Software 2002-2007
</div>
</body>

View file

@ -29,15 +29,21 @@ A chat creates a new thread of messages (using a thread ID) between two users. T
following code snippet demonstrates how to create a new Chat with a user and then send
them a text message:<p>
<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
<div class="code"><pre><font color="gray"><i>// Assume we've created an XMPPConnection name "connection".</i></font>
ChatManager chatmanager = connection.getChatManager();
Chat newChat = chatmanager.createChat(<font
color="green">"jsmith@jivesoftware.com"</font>, new MessageListener() {
public void processMessage(Chat chat, Message 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>
System.out.println(<font color="green">"Received message: "</font> + message);
}
});
try {
newChat.sendMessage(<font color="green">"Howdy!"</font>);
}
catch (XMPPException e) {
System.out.println(<font color="green">"Error Delivering block"</font>);
}
</pre>
</div>
<p>
@ -51,7 +57,7 @@ ChatManager chatmanager = connection.getChatManager();<br>Chat newChat = chatman
<p>
<div class="code"><pre>
Message newMessage = newChat.createMessage();
Message newMessage = new Message();
newMessage.setBody(<font color="green">"Howdy!"</font>);
message.setProperty(<font color="green">"favoriteColor"</font>, <font color="green">"red"</font>);
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:
<pre>
Roster roster = con.getRoster();
<b>for</b> (Iterator i=roster.getEntries(); i.hasNext(); ) {
System.out.println(i.next());
Roster roster = connection.getRoster();
Collection&lt;RosterEntry&gt; entries = roster.getEntries();
for (RosterEntry entry : entries) {
System.out.println(entry);
}
</pre>
@ -77,19 +78,16 @@ similar code to update the roster UI with the changing information.
<br clear="all">
<pre>
final Roster roster = con.getRoster();
Roster roster = con.getRoster();
roster.addRosterListener(new RosterListener() {
<b>public void</b> rosterModified() {
<font color="gray"><i>// Ignore event for this example.</i></font>
}
<b>public void</b> presenceChanged(String user) {
<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));
// Ignored events public void entriesAdded(Collection&lt;String&gt; addresses) {}
public void entriesDeleted(Collection&lt;String&gt; addresses) {}
public void entriesUpdated(Collection&lt;String&gt; addresses) {}
public void presenceChanged(Presence presence) {
System.out.println("Presence changed: " + presence.getFrom() + " " + presence);
}
});
</pre>
</pre>
<p class="subheader">Adding Entries to the Roster</p>
@ -108,17 +106,17 @@ in one of three ways: <ul>
<li> Process presence subscription requests manually.
</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
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
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>
<div class="footer">
Copyright &copy; Jive Software 2002-2004
Copyright &copy; Jive Software 2002-2007
</div>
</body>