Solved

Windows RPC - Events/Callbacks

Posted on 2004-08-05
5
334 Views
Last Modified: 2010-04-01
Hi
We're developing a distributed computing app, wherein we use RPC for the communication between client and server. The server has two threads: One interacting with the client and the other waiting for user input. When there is an user input, the user thread should post a message to the server thread and the server thread should pass this on to the client as an event. Is this feasible to be implemented in RPC? If so, any idea on how to implement this?
Thanks.

Regards
Saravanan.
0
Comment
Question by:SaravananMP
  • 2
5 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 11739640
It is possible. Passing messages between threads is to be done the 'usual' way, the RPC implementation also is quite 'painless', e.g

[ uuid ([...]),
  version(1.0),
  pointer_default(unique)
]
interface IEventSink
{

unsigned int    PutEvent (  [in] unsigned int nEventId,
                                [in] unsigned int nSize,
                                [in, size_is(nSize), ] unsigned char* pAdditionalData
                             );
}

In your interacting thread, you'd now

// Bind to RPC server first

for (;;) {

    // wait for the user input thread to send something

    // ...

    // pass it over

    PutEvent ( nMsgId, 0, NULL); // no additional data

}
0
 

Author Comment

by:SaravananMP
ID: 11752752
Hi
Thanks for your response. The issue here is not passing data from one thread to the other. It's triggering an event from the Server to the Client.
In a COM interface, we declare an event as,
dispinterface _<InterfaceName>Events
{
methods:
[id(1), helpstring("method ValueChanged")] void ValueChanged (VARIANT varSelectedValue);
}

The server would invoke this by Fire_ValueChanged(varSel);
The client would implement something like OnValueChanged(VARIANT varSel)
{
}.

In the same way, does RPC provide some ways to trigger an event from the server to the client? Any special attribute to mentioned in the IDL to specify an event? Please clarify.
Thanks.

0
 
LVL 86

Accepted Solution

by:
jkr earned 250 total points
ID: 11753678
>>RPC provide some ways to trigger an event from the server to the client?

Well, the way is to call a remoted function that signals the event to the client/server, there's no special IDL attribute for that.
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question