Symbian3/SDK/Source/GUID-3472798D-CEC5-5BA9-A3A7-D4245661DEDB.dita
author Dominic Pinkman <Dominic.Pinkman@Nokia.com>
Thu, 21 Jan 2010 18:18:20 +0000
changeset 0 89d6a7a84779
permissions -rw-r--r--
Initial contribution of Documentation_content according to Feature bug 1266 bug 1268 bug 1269 bug 1270 bug 1372 bug 1374 bug 1375 bug 1379 bug 1380 bug 1381 bug 1382 bug 1383 bug 1385

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
<!-- This component and the accompanying materials are made available under the terms of the License 
"Eclipse Public License v1.0" which accompanies this distribution, 
and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
<!-- Initial Contributors:
    Nokia Corporation - initial contribution.
Contributors: 
-->
<!DOCTYPE concept
  PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
<concept id="GUID-3472798D-CEC5-5BA9-A3A7-D4245661DEDB" xml:lang="en"><title>pubsub:
Using the Publish and Subscribe IPC Mechanism</title><shortdesc>This example demonstrates the Publish and Subscribe IPC mechanisms
using the <apiname>RProperty</apiname> class. </shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
<section id="GUID-909438A0-5FCA-4FA3-96EF-2666A3C07227"><title>Download</title> <p>Click on the following link to download
the example: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/zips/guid-b24148a4-d20f-4af6-a0d2-d404f1a5698e.zip" scope="external">pubsub.zip</xref>.</p><p>Click: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/guid-b24148a4-d20f-4af6-a0d2-d404f1a5698e.html" scope="peer">browse</xref> to view the example code.</p> </section>
<section id="GUID-20D6C064-50E0-52EE-8287-1D657C27FF75"><title>Description</title> <p>This
example demonstrates three types of usage pattern for Publish and Subscribe: </p> <ul>
<li id="GUID-12170122-3E04-5098-99C3-0C0C6B8C8914"><p>Standard State Publishing </p> <ul>
<li id="GUID-DA65B928-6F46-5238-AED8-8CE062098621"><p> <b>Publisher:</b> The
publisher defines a byte-array property and pre-allocates memory to it. It
interactively updates and re-publishes the value of the property. </p> </li>
<li id="GUID-0519A68F-E898-5FD7-95C1-A6AA79C5CAE1"><p> <b>Subscriber:</b> The
subscriber gets the value of the property defined by the publisher by subscribing
to it. It displays an error and stops running if it fails to get the value
of the property. </p> </li>
</ul> </li>
<li id="GUID-FA0336A7-3402-58BF-A987-BC3273FFB687"><p>Pure Event Distribution </p> <ul>
<li id="GUID-03D5D3D0-23F5-5E75-840E-70DC8BB74388"><p> <b>Publisher:</b> The
publisher defines an integer property and publishes a random integer value
periodically. This value has no significance to the subscriber. </p> </li>
<li id="GUID-4A3987D9-B916-584A-81C9-DC8079AA1270"><p> <b>Subscriber:</b> The
subscriber gets a notification when the publisher publishes a value. It exits
when the property is deleted by the publisher. </p> </li>
</ul> </li>
<li id="GUID-FFBD46FD-D0FB-5C9A-98D8-ABA7B8C6E398"><p>Speculative Publishing </p> <ul>
<li id="GUID-073BA0B9-1682-5642-8929-4B45738F28BD"><p> <b>Publisher:</b> The
publisher does not define the property. It ignores the <codeph>KErrNotFound</codeph> error
when it publishes the value of the property. </p> </li>
<li id="GUID-78B22435-963F-5E5E-9A2B-AC582DD520D4"><p> <b>Subscriber:</b> The
subscriber defines and subscribes to the property. It ignores the <codeph>KErrAlreadyExists</codeph> error. </p> </li>
</ul> </li>
</ul> </section>
<section id="GUID-63F559E8-36AB-41CD-9A2E-57080EA29601"><title>Class summary</title><ul>
<li><p><xref href="GUID-C4776034-D190-3FC4-AF45-C7F195093AC3.dita"><apiname>RProperty</apiname></xref> - User side interface to Publish &amp;
Subscribe.</p></li>
<li><p><xref href="GUID-067293BF-B28C-3CEC-92F4-1351A795EA7F.dita"><apiname>CActive</apiname></xref> - The core class of the active object abstraction.</p></li>
</ul></section>
<section id="GUID-43D665F1-BB55-5D5D-808E-3CBE18D2F6DA"><title>Build</title> <p><xref href="GUID-3100800B-B2F7-50EF-BD4C-3C345ECCB2A5.dita">The Symbian OS build process</xref> describes
how to build this example. </p> <p>This example builds the following binaries
in the standard location (<filepath>\epoc32\release\winscw\&lt;build_variant&gt;</filepath>)
for Carbide.c++: </p> <ul>
<li id="GUID-F06CD099-75C7-5070-89E9-015AAC1F0D9A"><p> <filepath>publishstd.exe</filepath>:
The publisher process for the Standard State pattern. </p> </li>
<li id="GUID-772A8A83-743C-5EE5-8D78-F1E8B60B070F"><p> <filepath>subscribestd.exe</filepath>:
The subscriber process for the Standard State pattern. </p> </li>
<li id="GUID-19AD84BC-4618-518B-8F46-3DA1B1279B20"><p> <filepath>publishpe.exe</filepath>:
The publisher process for the Pure Event Distribution pattern. </p> </li>
<li id="GUID-BDCCB376-3EE5-5F5B-A53D-43F52418E6AA"><p> <filepath>subscribepe.exe</filepath>:
The subscriber process for the Pure Event Distribution pattern. </p> </li>
<li id="GUID-9731BBF0-0C21-5739-A9C6-4894E78A6B41"><p> <filepath>publishspec.exe</filepath>:
The publisher process for the Speculative Publishing pattern. </p> </li>
<li id="GUID-0897C9AB-A30D-57A7-817C-80750877350C"><p> <filepath>subscribespec.exe</filepath>:
The subscriber process for the Speculative Publishing pattern. </p> </li>
</ul> </section>
<section id="GUID-D8D0CB53-A319-55EA-8650-6F9A74DBDD6C"><title>Running the
example</title> <p>To run the example, perform the following steps on each
usage pattern: </p> <ol id="GUID-5BFB2C37-2036-542C-9CD4-672D9D18F25C">
<li id="GUID-80B81388-C636-50A0-BCCC-8F6F609E410E"><p>Open two eshells. </p> </li>
<li id="GUID-A1FF28F1-696E-593C-9FFA-54F5C96F32F2"><p>Run the publisher executable
file in one eshell. </p> </li>
<li id="GUID-E3227D02-EB36-518A-8A25-59335A27F062"><p>Run the subscriber executable
file in another eshell. </p> </li>
</ol> <p> <b>Note</b>: Switch between eshells by pressing <codeph>CTRL+ALT+SHIFT+T</codeph>. </p> </section>
<section id="GUID-935115E3-FF46-5EC1-8F36-A6AE35356AD4"><title>See also</title> <p>For
more information, see <xref href="GUID-A81C65CF-CF4E-571C-8080-9D387F46AAD6.dita">Publish
and Subscribe</xref> in <i>Using User Library (E32)</i>. </p> </section>
</conbody></concept>