Solved

Windows RPC - Events/Callbacks

Posted on 2004-08-05
5
367 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

630 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