📄 x1234.htm
字号:
><route to='dj@yak/81F2220' from='15@c2s/80EE868'>
<presence>
<status>Online</status>
</presence>
</route>
<message id="jim_id_7" to="sabine@merlix" type="chat">
<x xmlns="jabber:x:event">
<composing/>
</x>
<thread>3A378DF2B70F6A53A9C317CF526C6B7A</thread>
<body>Hi there</body>
</message></PRE
></P
></DIV
><P
>The first is an internal
<TT
CLASS="LITERAL"
><route/></TT
> packet, which is
carrying a <TT
CLASS="LITERAL"
><presence/></TT
> packet
from the <I
CLASS="EMPHASIS"
>Client (to Server) Connections</I
> component,
identified by the 'c2s' part of the <TT
CLASS="OPTION"
>from</TT
> attribute,
to the <I
CLASS="EMPHASIS"
>Session Management</I
>
component (where the session identifier 81F2220
<A
NAME="AEN1371"
HREF="#FTN.AEN1371"
>[1]</A
>
is significant in the
<TT
CLASS="OPTION"
>to</TT
> attribute.).
<A
NAME="JABTDG-CH-4-FOOTNOTE-1"
HREF="#FTN.JABTDG-CH-4-FOOTNOTE-1"
>[2]</A
> </P
><P
>The second is a
<TT
CLASS="LITERAL"
><message/></TT
> packet, which
contains the message itself ("Hi there") as well as other information
(a message event and a conversation thread identifier; these are examined
in detail in Part II of the book).</P
></DIV
><DIV
CLASS="SECT3"
><H3
CLASS="SECT3"
><A
NAME="JABTDG-CH-4-SECT-4.1.2.4"
></A
></H3
><P
>It isn't necessarily the case, however, that <I
CLASS="EMPHASIS"
>all</I
> xdb
components will handle <I
CLASS="EMPHASIS"
>all</I
>
<TT
CLASS="LITERAL"
><xdb/></TT
> packets, or <I
CLASS="EMPHASIS"
>all</I
> service components will handle <I
CLASS="EMPHASIS"
>all</I
>
<TT
CLASS="LITERAL"
><presence/></TT
> packets.
The configuration, described later in this chapter, determines how the
components announce themselves and state their readiness to receive
and handle packets.</P
></DIV
><DIV
CLASS="SECT3"
><H3
CLASS="SECT3"
><A
NAME="JABTDG-CH-4-SECT-4.1.2.5"
>Delivery trees</A
></H3
><P
>The phrase "delivery tree" is often used in Jabber terminology to signify a
component or components that handle certain types of packet. The path
a packet makes as it <I
CLASS="EMPHASIS"
>descends</I
> the collection of
decision branches that guide
it to the component or components that will handle it.
For example, an
'xdb type component' is sometimes referred to as an <I
CLASS="EMPHASIS"
>xdb Delivery
Tree</I
>. Considering the division of components into different
types that handle different packet types is perhaps easier to visualize
as a tree, as shown in <A
HREF="x1234.htm#JABTDG-CH-4-FIG-4.1"
>Figure 4-2</A
>.</P
><DIV
CLASS="FIGURE"
><A
NAME="JABTDG-CH-4-FIG-4.1"
></A
><P
><B
>Figure 4-2. The Jabber Delivery Tree</B
></P
><PRE
CLASS="SCREEN"
> |
+-------+-----------------------------+
| | | component
log xdb service types
| | |
| | +----------+----------+----------+
| | | | | | packets
<log/> <xdb/> <message/> <presence/> <iq/> <route/> handled
</PRE
></DIV
><P
>The Jabber Delivery Tree shows which component types can handle what
sorts of packets in the Jabber world.</P
></DIV
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="JABTDG-CH-4-SECT-4.1.3"
>Component Connection Methods</A
></H2
><P
>The notion of components providing distinct services and being coordinated
by a central mechanism (<B
CLASS="COMMAND"
>jabberd</B
>) suggests a certain amount
of independence and individuality—a plug-in architecture—and
that is what
Jabber is. The components described earlier, and others too, are "plugged in"
to the Jabber backbone according to the requirements of the server.</P
><P
>The idea is that once you have the basic services like
<I
CLASS="EMPHASIS"
>Session Management</I
>,
<I
CLASS="EMPHASIS"
>Client (to Server) Connectivity</I
> and <I
CLASS="EMPHASIS"
>Data
Storage</I
>,
you plug in whatever you need to suit the server's requirements. For
example if you need conferencing facilities, you can plug in the
<I
CLASS="EMPHASIS"
>Conferencing</I
>
component. If you need user directory facilities, you can plug in the
<I
CLASS="EMPHASIS"
>Jabber User Directory (JUD)</I
> component. If you need a
bridge to the Yahoo!
Instant Messaging system, you can plug in the
<I
CLASS="EMPHASIS"
>Yahoo! Transport</I
> component.
<A
NAME="JABTDG-CH-4-FOOTNOTE-2"
HREF="#FTN.JABTDG-CH-4-FOOTNOTE-2"
>[3]</A
>
Indeed, you can write your own components to provide services that are not
available off the shelf and plug those in too.</P
><P
>So, how are components 'plugged in' to the Jabber server backbone?
<A
NAME="JABTDG-CH-4-FOOTNOTE-3"
HREF="#FTN.JABTDG-CH-4-FOOTNOTE-3"
>[4]</A
>
Well, there are three methods:</P
><P
></P
><UL
><LI
><P
>Library load</P
></LI
><LI
><P
>TCP sockets</P
></LI
><LI
><P
>STDIO</P
></LI
></UL
><P
>Let's examine each one in turn. </P
><DIV
CLASS="SECT3"
><H3
CLASS="SECT3"
><A
NAME="JABTDG-CH-4-SECT-4.1.3.1"
>library load</A
></H3
><P
>The core components of a Jabber Server providing IM services are connected
using the <I
CLASS="EMPHASIS"
>library load</I
> method. This simply means that
the component sources are compiled into shared object (<TT
CLASS="FILENAME"
>.so</TT
>)
libraries and loaded into the main Jabber process (<B
CLASS="COMMAND"
>jabberd</B
>).</P
><P
>The components are written specially with the Jabber backbone in mind and
contain standard registration routines that utilize functions in
the core
Jabber libraries. These routines are used to bind the component relationship
with
<B
CLASS="COMMAND"
>jabberd</B
> (for example there is a 'heartbeat' mechanism
through which the components are monitored) and to specify packet receipt
requirements.
<A
NAME="JABTDG-CH-4-FOOTNOTE-4"
HREF="#FTN.JABTDG-CH-4-FOOTNOTE-4"
>[5]</A
> </P
><P
>The <I
CLASS="EMPHASIS"
>library load</I
> method is represented in the
configuration by the
<TT
CLASS="LITERAL"
><load/></TT
> tag, which wraps
the library (or libraries) that should be loaded.
<A
HREF="x1234.htm#JABTDG-CH-4-EX-4"
>Example 4-4</A
> and
<A
HREF="x1234.htm#JABTDG-CH-4-EX-5"
>Example 4-5</A
>
show excerpts from the standard <TT
CLASS="FILENAME"
>jabber.xml</TT
> configuration file where we can see components being plugged
in using the <I
CLASS="EMPHASIS"
>library load</I
> method.</P
><P
><A
HREF="x1234.htm#JABTDG-CH-4-EX-4"
>Example 4-4</A
>
shows the <I
CLASS="EMPHASIS"
>Client (to Server) Connections (c2s)</I
>
component, which has been written and compiled as a <TT
CLASS="FILENAME"
>.so</TT
>
library, being connected using the <I
CLASS="EMPHASIS"
>library load</I
> method.</P
><DIV
CLASS="EXAMPLE"
><A
NAME="JABTDG-CH-4-EX-4"
></A
><P
><B
>Example 4-4. Loading of the c2s component with <I
CLASS="EMPHASIS"
>library load</I
> </B
></P
><P
><PRE
CLASS="SCREEN"
><load>
<pthsock_client>./pthsock/pthsock_client.so</pthsock_client>
</load></PRE
></P
></DIV
><P
>In this example, we see the "simpler" form of the
<TT
CLASS="LITERAL"
><load/></TT
> tag: inside the tag
we have:</P
><P
><PRE
CLASS="SCREEN"
><pthsock_client>./pthsock/pthsock_client.so</pthsock_client></PRE
></P
><P
>which specifies two things:</P
><P
></P
><UL
><LI
><P
>Which library to load
(<TT
CLASS="LITERAL"
>./pthsock/pthsock_client.so</TT
>).</P
></LI
><LI
><P
>The name of the component registration routine that should be called
by <B
CLASS="COMMAND"
>jabberd</B
> once the library has been loaded. The
name of the routine is the name given to the tag that wraps
the library filename; in this example it's
<TT
CLASS="FUNCTION"
>pthsock_client()</TT
>, denoted by
<TT
CLASS="LITERAL"
><pthsock_client/></TT
>.</P
></LI
></UL
><P
><A
HREF="x1234.htm#JABTDG-CH-4-EX-5"
>Example 4-5</A
>
shows multiple <TT
CLASS="FILENAME"
>.so</TT
> libraries being loaded
when a component is connected; the form of the
<TT
CLASS="LITERAL"
><load/></TT
> tag is slightly more
involved.</P
><DIV
CLASS="EXAMPLE"
><A
NAME="JABTDG-CH-4-EX-5"
></A
><P
><B
>Example 4-5. Loading of the jsm component with <I
CLASS="EMPHASIS"
>library load</I
> </B
></P
><P
><PRE
CLASS="SCREEN"
><load main="jsm">
<jsm>./jsm/jsm.so</jsm>
<mod_echo>./jsm/jsm.so</mod_echo>
<mod_roster>./jsm/jsm.so</mod_roster>
<mod_time>./jsm/jsm.so</mod_time>
<mod_vcard>./jsm/jsm.so</mod_vcard>
<mod_last>./jsm/jsm.so</mod_last>
<mod_version>./jsm/jsm.so</mod_version>
<mod_announce>./jsm/jsm.so</mod_announce>
<mod_agents>./jsm/jsm.so</mod_agents>
<mod_browse>./jsm/jsm.so</mod_browse>
<mod_admin>./jsm/jsm.so</mod_admin>
<mod_filter>./jsm/jsm.so</mod_filter>
<mod_offline>./jsm/jsm.so</mod_offline>
<mod_presence>./jsm/jsm.so</mod_presence>
<mod_auth_plain>./jsm/jsm.so</mod_auth_plain>
<mod_auth_digest>./jsm/jsm.so</mod_auth_digest>
<mod_auth_0k>./jsm/jsm.so</mod_auth_0k>
<mod_log>./jsm/jsm.so</mod_log>
<mod_register>./jsm/jsm.so</mod_register>
<mod_xml>./jsm/jsm.so</mod_xml>
</load></PRE
></P
></DIV
><P
>Here we see multiple libraries being loaded to form the <I
CLASS="EMPHASIS"
>Session
Management</I
> (the JSM) component, known as "<SPAN
CLASS="ACRONYM"
>jsm</SPAN
>".</P
><P
>What happens is this:</P
><P
></P
><OL
TYPE="1"
><LI
><P
><B
CLASS="COMMAND"
>jabberd</B
> loads the library in the
tag that's pointed
to by the <TT
CLASS="LITERAL"
>main=""</TT
> attribute of the
<TT
CLASS="LITERAL"
><load/></TT
>
tag; in this example it's the library
<TT
CLASS="FILENAME"
>./jsm/jsm.so</TT
>:</P
><P
><PRE
CLASS="SCREEN"
><jsm>./jsm/jsm.so</jsm></PRE
></P
></LI
><LI
><P
><B
CLASS="COMMAND"
>jabberd</B
> then invokes the registration routine called
<TT
CLASS="FUNCTION"
>jsm()</TT
></P
></LI
><LI
><P
>jsm loads the rest of the modules defined within the
<TT
CLASS="LITERAL"
><load/></TT
>
tag (<TT
CLASS="FILENAME"
>mod_echo</TT
>, <TT
CLASS="FILENAME"
>mod_roster</TT
>,
<TT
CLASS="FILENAME"
>mod_time</TT
>, and so on), invoking each module's
registration routine (<TT
CLASS="FUNCTION"
>mod_echo()</TT
>,
<TT
CLASS="FUNCTION"
>mod_roster()</TT
>, <TT
CLASS="FUNCTION"
>mod_time()</TT
>, and
so on) as they're loaded. </P
></LI
></OL
><P
>In case you're wondering, all the modules that belong to the jsm
are actually compiled into a single <TT
CLASS="FILENAME"
>.so</TT
>
library - which is why all the <TT
CLASS="FILENAME"
>.so</TT
> references
in this example are the same.</P
></DIV
><DIV
CLASS="SECT3"
><H3
CLASS="SECT3"
><A
NAME="JABTDG-CH-4-SECT-4.1.3.2"
>TCP sockets</A
></H3
><P
>Another method for connecting components to the Jabber backbone uses
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -