📄 x332.htm
字号:
<HTML
><HEAD
><TITLE
>Imaginary Conversation</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.64
"><LINK
REL="HOME"
TITLE="Programming Jabber"
HREF="book1.htm"><LINK
REL="UP"
TITLE="A Taste of Things to Come"
HREF="c324.htm"><LINK
REL="PREVIOUS"
TITLE="A Taste of Things to Come"
HREF="c324.htm"><LINK
REL="NEXT"
TITLE="A Simple Script"
HREF="x437.htm"></HEAD
><BODY
CLASS="SECT1"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>Programming Jabber</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="c324.htm"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Chapter 1. A Taste of Things to Come</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="x437.htm"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="JABTDG-CH-1-SECT-1.1"
>Imaginary Conversation</A
></H1
><P
>Jim and John work at two different companies, and are both interested in
stocks and shares, using Jabber-based services to check and monitor prices,
buy stock and manage their portfolios. There's a workflow assistant at
John's company that can do things like monitor incoming email and coordinate
work items between colleagues.</P
><P
><I
CLASS="EMPHASIS"
>Jim sends a quick chat message to John:</I
></P
><P
><PRE
CLASS="SCREEN"
><message type='chat' from='jim@company-a.com/home'
to='john@company-b.com'>
<thread>01</thread>
<body><TT
CLASS="USERINPUT"
><B
>Hey John, you seen the latest story on Megacorp earnings?</B
></TT
></body>
</message></PRE
></P
><P
><I
CLASS="EMPHASIS"
>John responds:</I
></P
><P
><PRE
CLASS="SCREEN"
><message type='chat' to='jim@company-a.com/home'
from='john@company-b.com/Desk'>
<thread>01</thread>
<body><TT
CLASS="USERINPUT"
><B
>No, where is it?</B
></TT
></body>
</message></PRE
></P
><P
><I
CLASS="EMPHASIS"
>Jim sends John the URL:</I
></P
><P
><PRE
CLASS="SCREEN"
><message type='chat' from='jim@company-a.com/home'
to='john@company-b.com/Desk'>
<thread>01</thread>
<body><TT
CLASS="USERINPUT"
><B
>Here's the link</B
></TT
></body>
<x xmlns='jabber:x:oob'>
<url><TT
CLASS="USERINPUT"
><B
>http://www.megacorp.co.uk/earnings3q.html</B
></TT
></url>
<desc><TT
CLASS="USERINPUT"
><B
>Third Quarter Earnings for Megacorp</B
></TT
></desc>
</x>
</message></PRE
></P
><P
><I
CLASS="EMPHASIS"
>John receives an alert about the price of ACME Holdings (ACMH) falling
below a threshold he previously set:</I
></P
><P
><PRE
CLASS="SCREEN"
><message to='john@company-b.com' from='alert@stocks.company-b.com'>
<subject><TT
CLASS="USERINPUT"
><B
>ACMH Fallen below 250p</B
></TT
></subject>
<body><TT
CLASS="USERINPUT"
><B
>ACME Holdings stock price 248p as at 10:20am today</B
></TT
></body>
</message></PRE
></P
><P
><I
CLASS="EMPHASIS"
>He checks the price of Megacorp stock (MEGC) by sending an empty
message to the stock and shares assistant application:</I
></P
><P
><PRE
CLASS="SCREEN"
><message type='chat' to='MEGC@stocks.company-b.com'
from='john@company-b.com/Desk>
<thread>T20</thread>
</message></PRE
></P
><P
><I
CLASS="EMPHASIS"
>In reply, the stocks and shares assistant application sends the
required information:</I
></P
><P
><PRE
CLASS="SCREEN"
><message type='chat' from='MEGC@stocks.company-b.com'
to='john@company-b.com/Desk'>
<thread>T20</thread>
<subject><TT
CLASS="USERINPUT"
><B
>MEGC Current Price</B
></TT
></subject>
<body>
<TT
CLASS="USERINPUT"
><B
>Megacorp stock price 1287p at 10:25am today</B
></TT
>
</body>
</message></PRE
></P
><P
><I
CLASS="EMPHASIS"
>John likes the price and decides to buy 100 more shares:</I
></P
><P
><PRE
CLASS="SCREEN"
><message type='chat' to='MEGC@stocks.company-b.com'
from='john@company-b.com/Desk'>
<thread>T20</thread>
<body><TT
CLASS="USERINPUT"
><B
>buy 100 at 1287 now</B
></TT
></body>
</message></PRE
></P
><P
><I
CLASS="EMPHASIS"
>He sends a message to Jim telling him of his new investment. Jim
checks his own portfolio:</I
></P
><P
><PRE
CLASS="SCREEN"
><iq type='get' to='portfolio.company-a.com'
id='port_01'
from='jim@company-a.com/home'>
<query xmlns='jabber:iq:browse'/>
</iq></PRE
></P
><P
><I
CLASS="EMPHASIS"
>He sees that he already holds 1200 Megacorp shares, and decides against
buying any more:</I
></P
><P
><PRE
CLASS="SCREEN"
><iq type='result' from='portfolio.company-a.com'
id='port_01'
to='jim@company-a.com/home'>
<portfolio xmlns='jabber:iq:browse' type='personal'
jid='jim@portfolio.company-a.com'>
<stock type='standard' name='Megacorp'
jid='MEGC@portfolio.company-a.com' holding='1200'/>
<stock type='standard' name='ACME Holdings'
jid='ACMH@portfolio.company-a.com' holding='500'/>
</portfolio>
</iq></PRE
></P
><P
><I
CLASS="EMPHASIS"
>Workassist, the workflow assistant application, sends John a notification
of an important email:</I
></P
><P
><PRE
CLASS="SCREEN"
><message from='workassist@company-b.com'>
<subject><TT
CLASS="USERINPUT"
><B
>New mail from: Alastair B</B
></TT
></subject>
<body>
<TT
CLASS="USERINPUT"
><B
> You have a new mail waiting; details are as follows:
Subject: Incident last week
From: Alastair B
</B
></TT
></body>
</message></PRE
></P
><P
><I
CLASS="EMPHASIS"
>He also receives an invite to a meeting:</I
></P
><P
><PRE
CLASS="SCREEN"
><message from='joanne@company-b.com/laptop'>
<body>
<TT
CLASS="USERINPUT"
><B
>Hey John, you're supposed to be helping us decide where to hold
this year's Christmas party!
</B
></TT
></body>
<x xmlns='jabber:x:conference' jid='room2@meeting.company-b.com'/>
</message></PRE
></P
><P
><I
CLASS="EMPHASIS"
>John decides to leave the mail until later and join the rest of his
colleagues in the meeting room.</I
></P
><P
>There's a great deal we see in this imaginary but not unlikely conversation.</P
><P
></P
><UL
><LI
><P
>There are human and application participants involved in this conversation;
Jabber makes no distinction, nor holds any prejudice against either participant
type.</P
></LI
><LI
><P
>XML is used effectively to segregate the conversational chunks (Jim's opening
gambit, John's response, the stock price alert, and so on) and to structure
and identify data within those chunks (the URL for the earnings story, the
portfolio information, the conference room invitation).</P
></LI
><LI
><P
>Conversational strands are kept in context by use of a
<TT
CLASS="LITERAL"
><thread/></TT
> tag, so that Jim's and John's
clients have a chance to present what's said in an appropriate way.</P
></LI
><LI
><P
>Each conversational chunk is either a
<TT
CLASS="LITERAL"
><message/></TT
> or a
<TT
CLASS="LITERAL"
><iq/></TT
> tag - two of the three Jabber
building blocks (<TT
CLASS="LITERAL"
><message/></TT
>,
<TT
CLASS="LITERAL"
><iq/></TT
> and
<TT
CLASS="LITERAL"
><presence/></TT
>) on which everything is based.</P
></LI
><LI
><P
>The conversation takes place across two Jabber servers - the one at
<TT
CLASS="LITERAL"
>company-a.com</TT
> and the other at
<TT
CLASS="LITERAL"
>company-b.com</TT
>. </P
></LI
><LI
><P
>The conversation flow is asynchronous, in the sense that out of nowhere,
a message alerting John to a stock price fall below threshold appears
seemingly in the middle of John's conversation with Jim, as does the
message from the 'workassist' agent.</P
></LI
><LI
><P
>All Jabber entities - human or otherwise - are identified by Jabber IDs
such as John's (<TT
CLASS="LITERAL"
>john@company-a.com</TT
>) or the stock alert
mechanism (<TT
CLASS="LITERAL"
>alert@stocks.company-b.com</TT
>).</P
></LI
><LI
><P
><TT
CLASS="LITERAL"
>company-b.com</TT
>'s stock system is multi-faceted. As well
as being able to send (and receive settings for) threshold alerts through
the <TT
CLASS="LITERAL"
>alert@stocks.company-b.com</TT
> address, it can also
interact using different identities to reflect the context of the stock
being discussed, for example <TT
CLASS="LITERAL"
>MEGC@stocks.company-b.com</TT
>
represents the Megacorp (MEGC) stock.</P
><P
>This stock system is in fact a Jabber component, a single element which
takes on each of the stock guises in the conversation.</P
></LI
></UL
><P
>Jabber is a set of protocols, a technology, a system that is extremely
capable of providing IM facilities, including bridging services to other
IM systems. </P
><P
>But it is capable of much more than that. Paring down what Jabber is to
its bare essentials, what do we have? An extensible client-server architecture
in which XML can be exchanged, be <I
CLASS="EMPHASIS"
>routed</I
>, between
clients and services that plug in as components to the Jabber server. The
original and core set of components provide the IM features (and supporting
services) that were briefly described in the Preface; the current
'off-the-shelf' Jabber clients are generally orientated towards IM. </P
><P
>But of course, IM is just one of countless domains to which XML-based
messaging technology such as Jabber's can be applied.</P
><P
>As we'll learn, the XML structures that make up the Jabber protocol fall
into three categories, each represented by a uniquely named top-level tag
(also referred to as an <I
CLASS="EMPHASIS"
>element</I
>).
But these tags mustn't necessarily
carry human-generated IM message content—as long as the resulting XML
is well-formed, anything goes.
<A
NAME="JABTDG-CH-1-FOOTNOTE-1"
HREF="#FTN.JABTDG-CH-1-FOOTNOTE-1"
>[1]</A
>
Furthermore, the Jabber protocol design makes use of an XML feature that
allows total flexibility of extention: <I
CLASS="EMPHASIS"
>Namespaces.</I
></P
><P
>Bearing this in mind, it's clear that Jabber can be deployed to provide
solutions outside the IM space as well as within it. </P
></DIV
><H3
CLASS="FOOTNOTES"
>Notes</H3
><TABLE
BORDER="0"
CLASS="FOOTNOTES"
WIDTH="100%"
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
WIDTH="5%"
><A
NAME="FTN.JABTDG-CH-1-FOOTNOTE-1"
HREF="x332.htm#JABTDG-CH-1-FOOTNOTE-1"
>[1]</A
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
WIDTH="95%"
><P
>To prevent flooding of the server with large amounts of data, there are
mechanisms in place to 'throttle' heavy connections. These mechanisms can
be configured in the server configuration, described in
<A
HREF="x1740.htm#JABTDG-CH-4-SECT-4.3.10"
>the section called <I
><I
CLASS="EMPHASIS"
>io</I
> Section</I
> in Chapter 4</A
>.</P
></TD
></TR
></TABLE
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="c324.htm"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="book1.htm"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="x437.htm"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>A Taste of Things to Come</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="c324.htm"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>A Simple Script</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -