mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2025-09-10 02:39:42 +02:00
Rename PacketFilter (and implementing classes) and PacketExtension
to StanzaFilter and ExtensionElement.
This commit is contained in:
parent
2250ac20ed
commit
d4a6d8e653
233 changed files with 1175 additions and 895 deletions
|
@ -42,9 +42,9 @@ connection. The window will contain the following information:
|
|||
|
||||
* XMPPConnection tabs -- each tab shows debugging information related to the connection.
|
||||
* Smack info tab -- shows information about Smack (e.g. Smack version, installed components, etc.). The connection tab will contain the following information:
|
||||
* All Packets -- shows sent and received packets information parsed by Smack.
|
||||
* Raw Sent Packets -- raw XML traffic generated by Smack and sent to the server.
|
||||
* Raw Received Packets -- raw XML traffic sent by the server to the client.
|
||||
* All Stanzas -- shows sent and received packets information parsed by Smack.
|
||||
* Raw Sent Stanzas -- raw XML traffic generated by Smack and sent to the server.
|
||||
* Raw Received Stanzas -- raw XML traffic sent by the server to the client.
|
||||
* Ad-hoc message -- allows to send ad-hoc packets of any type.
|
||||
* Information -- shows connection state and statistics.
|
||||
|
||||
|
@ -57,6 +57,6 @@ contain the following information:
|
|||
|
||||
* Client Traffic (red text) -- raw XML traffic generated by Smack and sent to the server.
|
||||
* Server Traffic (blue text) -- raw XML traffic sent by the server to the client.
|
||||
* Interpreted Packets (green text) -- shows XML packets from the server as parsed by Smack. Right click on any of the panes to bring up a menu with the choices to copy of the contents to the system clipboard or to clear the contents of the pane.
|
||||
* Interpreted Stanzas (green text) -- shows XML packets from the server as parsed by Smack. Right click on any of the panes to bring up a menu with the choices to copy of the contents to the system clipboard or to clear the contents of the pane.
|
||||
|
||||
Copyright (C) Jive Software 2002-2008
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
PacketExtension
|
||||
===============
|
||||
|
||||
The static `from(Packet)` Method
|
||||
The static `from(Stanza)` Method
|
||||
--------------------------------
|
||||
|
||||
Every PacketExtension class must have a static `from()` method that retrieves that extension for a given Stanza (if any).
|
||||
|
@ -9,7 +9,7 @@ Every PacketExtension class must have a static `from()` method that retrieves th
|
|||
Sample Code
|
||||
|
||||
```java
|
||||
public static RSMSet from(Packet) {
|
||||
public static RSMSet from(Stanza) {
|
||||
return packet.getExtension(ELEMENT, NAMESPACE);
|
||||
}
|
||||
```
|
||||
|
|
|
@ -89,7 +89,7 @@ req.setTo("juliet@capulet.com/balcony");
|
|||
|
||||
// send it
|
||||
connection.sendIqWithResponseCallback(req, new PacketListener() {
|
||||
public void processPacket(Packet packet) {
|
||||
public void processPacket(Stanza packet) {
|
||||
HttpOverXmppResp resp = (HttpOverXmppResp) iq;
|
||||
// check HTTP response code
|
||||
if (resp.getStatusCode() == 200) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
Group Chat Invitations
|
||||
======================
|
||||
|
||||
The group chat invitation packet extension is used to invite other users to a
|
||||
The group chat invitation extension is used to invite other users to a
|
||||
group chat room.
|
||||
|
||||
* Inviting Other Users
|
||||
|
@ -20,7 +20,7 @@ appropriately, as in the following code example:
|
|||
Message message = new Message("user@chat.example.com");
|
||||
message.setBody("Join me for a group chat!");
|
||||
message.addExtension(new GroupChatInvitation("room@chat.example.com"));
|
||||
con.sendPacket(message);
|
||||
con.sendStanza(message);
|
||||
```
|
||||
|
||||
The XML generated for the invitation portion of the code above would be:
|
||||
|
@ -32,11 +32,11 @@ The XML generated for the invitation portion of the code above would be:
|
|||
Listening for Invitations
|
||||
-------------------------
|
||||
|
||||
To listen for group chat invitations, use a PacketExtensionFilter for the `x`
|
||||
To listen for group chat invitations, use a StanzaExtensionFilter for the `x`
|
||||
element name and `jabber:x:conference` namespace, as in the following code
|
||||
example:
|
||||
|
||||
```
|
||||
PacketFilter filter = new PacketExtensionFilter("x", "jabber:x:conference");
|
||||
StanzaFilter filter = new StanzaExtensionFilter("x", "jabber:x:conference");
|
||||
// Create a packet collector or packet listeners using the filter...
|
||||
```
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
Packet Properties
|
||||
Stanza Properties
|
||||
=================
|
||||
|
||||
Smack provides an easy mechanism for attaching arbitrary properties to
|
||||
|
@ -20,7 +20,7 @@ jpe.setProperty("favoriteColor", new Color(0, 0, 255));
|
|||
// Add an int as a property._
|
||||
jpe.setProperty("favoriteNumber", 4);
|
||||
// Add the JivePropertiesExtension to the message packet_
|
||||
message.addPacketExtension(jpe);
|
||||
message.addStanzaExtension(jpe);
|
||||
chat.sendMessage(message);
|
||||
```
|
||||
|
||||
|
@ -39,8 +39,8 @@ int favoriteNumber = ((Integer)jpe.getProperty("favoriteNumber")).intValue();
|
|||
```
|
||||
|
||||
For convenience `JivePropertiesManager` contains two helper methods namely
|
||||
`addProperty(Packet packet, String name, Object value)` and
|
||||
`getProperty(Packet packet, String name)`.
|
||||
`addProperty(Stanza packet, String name, Object value)` and
|
||||
`getProperty(Stanza packet, String name)`.
|
||||
|
||||
Objects as Properties
|
||||
---------------------
|
||||
|
|
|
@ -98,7 +98,7 @@ done. The last step is to send the message as you do with any other message.
|
|||
An XHTML message is like any regular message, therefore to send the message
|
||||
you can follow the usual steps you do in order to send a message. For example,
|
||||
to send a message as part of a chat just use the message **#send(Message)** of
|
||||
_**Chat**_ or you can use the message **#send(Packet)** of
|
||||
_**Chat**_ or you can use the message **#send(Stanza)** of
|
||||
_**XMPPConnection**_.
|
||||
|
||||
**Example**
|
||||
|
@ -143,7 +143,7 @@ XHTML bodies of any received message.
|
|||
```
|
||||
// Create a listener for the chat and display any XHTML content
|
||||
PacketListener packetListener = new PacketListener() {
|
||||
public void processPacket(Packet packet) {
|
||||
public void processPacket(Stanza packet) {
|
||||
Message message = (Message) packet;
|
||||
// Obtain the XHTML bodies of the message
|
||||
List<CharSequence> bodies = XHTMLManager.getBodies(message);
|
||||
|
|
|
@ -83,7 +83,7 @@ Retrieve the roster using the `Roster.getInstanceFor(XMPPConnection)` method. Th
|
|||
class allows you to find all the roster entries, the groups they belong to,
|
||||
and the current presence status of each entry.
|
||||
|
||||
Reading and Writing Packets
|
||||
Reading and Writing Stanzas
|
||||
|
||||
Each message to the XMPP server from a client is called a packet and is sent
|
||||
as XML. The `org.jivesoftware.smack.packet` package contains classes that
|
||||
|
@ -102,7 +102,7 @@ con.sendPacket(presence);
|
|||
```
|
||||
|
||||
Smack provides two ways to read incoming packets: `PacketListener`, and
|
||||
`PacketCollector`. Both use `PacketFilter` instances to determine which
|
||||
`PacketCollector`. Both use `StanzaFilter` 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
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* [Managing Connections](connections.html)
|
||||
* [Messaging Basics](messaging.html)
|
||||
* [Roster and Presence](roster.html)
|
||||
* [Processing Incoming Packets](processing.html)
|
||||
* [Processing Incoming Stanzas](processing.html)
|
||||
* [Provider Architecture](providers.html)
|
||||
* [Debugging with Smack](debugging.html)
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
Processing Incoming Packets
|
||||
Processing Incoming Stanzas
|
||||
===========================
|
||||
|
||||
[Back](index.html)
|
||||
|
@ -9,7 +9,7 @@ constructs:
|
|||
* `org.jivesoftware.smack.PacketCollector` -- a class that lets you synchronously wait for new packets.
|
||||
* `org.jivesoftware.smack.PacketListener` -- an interface for asynchronously notifying you of incoming packets. 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 arrive. Packet collectors and listeners can be created using an `XMPPConnection` instance.
|
||||
|
||||
The `org.jivesoftware.smack.filter.PacketFilter` interface determines which
|
||||
The `org.jivesoftware.smack.filter.StanzaFilter` interface determines which
|
||||
specific packets will be delivered to a `PacketCollector` or `PacketListener`.
|
||||
Many pre-defined filters can be found in the `org.jivesoftware.smack.filter`
|
||||
package.
|
||||
|
@ -20,7 +20,7 @@ and a packet listener:
|
|||
```
|
||||
// Create a packet filter to listen for new messages from a particular
|
||||
// user. We use an AndFilter to combine two other filters._
|
||||
PacketFilter filter = new AndFilter(new PacketTypeFilter(Message.class),
|
||||
StanzaFilter filter = new AndFilter(new StanzaTypeFilter(Message.class),
|
||||
new FromContainsFilter("mary@jivesoftware.com"));
|
||||
// Assume we've created an XMPPConnection name "connection".
|
||||
|
||||
|
@ -38,19 +38,19 @@ PacketListener myListener = new PacketListener() {
|
|||
connection.addPacketListener(myListener, filter);
|
||||
```
|
||||
|
||||
Standard Packet Filters
|
||||
Standard Stanza Filters
|
||||
-----------------------
|
||||
|
||||
A rich set of packet filters are included with Smack, or you can create your
|
||||
own filters by coding to the `PacketFilter` interface. The default set of
|
||||
own filters by coding to the `StanzaFilter` interface. The default set of
|
||||
filters includes:
|
||||
|
||||
* `PacketTypeFilter` -- filters for packets that are a particular Class type.
|
||||
* `StanzaTypeFilter` -- filters for packets that are a particular Class type.
|
||||
* `StanzaIdFilter` -- filters for packets with a particular packet ID.
|
||||
* `ThreadFilter` -- filters for message packets with a particular thread ID.
|
||||
* `ToContainsFilter` -- filters for packets that are sent to a particular address.
|
||||
* `FromContainsFilter` -- filters for packets that are sent to a particular address.
|
||||
* `PacketExtensionFilter` -- filters for packets that have a particular packet extension.
|
||||
* `StanzaExtensionFilter` -- filters for packets that have a particular packet extension.
|
||||
* `AndFilter` -- implements the logical AND operation over two filters.
|
||||
* `OrFilter` -- implements the logical OR operation over two filters.
|
||||
* `NotFilter` -- implements the logical NOT operation on a filter.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
Provider Architecture: Packet Extensions and Custom IQ's
|
||||
Provider Architecture: Stanza Extensions and Custom IQ's
|
||||
========================================================
|
||||
|
||||
[Back](index.html)
|
||||
|
@ -73,7 +73,7 @@ an XMPP time packet resembles the following:
|
|||
|
||||
### Introspection
|
||||
|
||||
_Time Packet_
|
||||
_Time Stanza_
|
||||
|
||||
|
||||
<iq type='result' to='joe@example.com' from='mary@example.com' id='time_1'>
|
||||
|
@ -190,7 +190,7 @@ public class MyIQProvider extends IQProvider<MyIQ> {
|
|||
|
||||
### DiscoItemsProvider
|
||||
|
||||
_Disco Items Packet_
|
||||
_Disco Items Stanza_
|
||||
|
||||
|
||||
|
||||
|
@ -264,11 +264,11 @@ _Disco Items IQProvider_
|
|||
Extension Providers
|
||||
-------------------
|
||||
|
||||
Packet extension providers are responsible for parsing packet extensions,
|
||||
Stanza extension providers are responsible for parsing packet extensions,
|
||||
which are child elements in a custom namespace of IQ, message and presence
|
||||
packets.
|
||||
|
||||
_Pubsub Subscription Packet_
|
||||
_Pubsub Subscription Stanza_
|
||||
|
||||
|
||||
<iq type='result' from='pubsub.shakespeare.lit' to='francisco@denmark.lit/barracks' id='sub1'>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue