Solved

Windows RPC - Events/Callbacks

Posted on 2004-08-05
5
328 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Would like to move button in a function 3 71
C++ finding a sting in a char* string from a text file 3 99
Least Squares Curve Fitting 4 57
Why isn't object file created? 6 39
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

932 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now