Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Windows RPC - Events/Callbacks

Posted on 2004-08-05
5
Medium Priority
?
377 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 1000 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
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 additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

721 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