Symbian3/PDK/Source/GUID-3472798D-CEC5-5BA9-A3A7-D4245661DEDB.dita
author Dominic Pinkman <dominic.pinkman@nokia.com>
Fri, 16 Jul 2010 17:23:46 +0100
changeset 12 80ef3a206772
parent 5 f345bda72bc4
permissions -rw-r--r--
Week 28 contribution of PDK documentation content. See release notes for details. Fixes bugs Bug 1897, Bug 344, Bug 2681, Bug 463, Bug 1522.

<?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 <codeph>RProperty</codeph> 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>The Symbian build process 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>