Sample remote notification setup

The following code sample shows a derived class of MRemoteDispatcher that has mixed in MRemoteDispatcherNotifier. It illustrates the boilerplate code that is included in all derived classes of MRemoteNotifierDispatcher.

The relevant part of the declaration for TShapeListDispatcher appears below.

      class TShapeListDispatcher: public MRemoteDispatcher, public MRemoteDispatcherNotifier {
      public:
                              TShapeListDispatcher();
          virtual             ~TShapeListDispatcher();
      
          void                FwdAddRemoteInterest(TStream& args, TStream& results);
          void                FwdRemoveRemoteInterest(TStream& args, TStream& results);
      
          void                HandleAdoptShape(TStream& args, TStream& results);
          void                HandleOrphanShape(TStream& args, TStream& results);
          / ...
      };
The code for TShapeListDispatcher's constructor looks like this. First the notifier request entries are defined to call the forwarding functions and registered. Then comes the standard setup specific to this class.

      TShapeListDispatcher::TShapeListDispatcher()
          : MRemoteDispatcher(), MRemoteDispatcherNotifier()
      {
          static RequestEntry notifierRequests[] = {
              {MRemoteCallerNotifier::kAddRemoteInterest, 
                  (RemoteFnPtr)&TShapeListDispatcher::FwdAddRemoteInterest},
              {MRemoteCallerNotifier::kRemoveRemoteInterest,
                  (RemoteFnPtr)&TShapeListDispatcher::FwdRemoveRemoteInterest},
              {MRemoteCaller::kUnknownRequest}
          };
      
          RegisterRequests(TStandardText("MRemoteDispatcherNotifier"),
              MRemoteCallerNotifier::kLastRequest, notifierRequests);
      
          static RequestEntry shapeListRequests[] = {
              {TShapeListCaller::kAdoptShape, 
                  (RemoteFnPtr)&TShapeListDispatcher::HandleAdoptShape},
              {TShapeListCaller::kOrphanShape, 
                  (RemoteFnPtr)&TShapeListDispatcher::HandleOrphanShape},
              {MRemoteCaller::kUnknownRequest}
          };
      
          RegisterRequests(TStandardText("TShapeListDispatcher"), 
              TShapeListDispatcher::kLastRequest, shapeListRequests);
      }
The following code illustrates the implementation of the calls that forward requests for adding and removing interests. It is straightforward.

      TShapeListDispatcher::FwdAddRemoteInterest(TStream& args, TStream& results)
      {
          AddRemoteInterest(args, results);
          ReturnSuccess(results);
      }
      TShapeListDispatcher::FwdRemoveRemoteInterest(TStream& args, TStream& results)
      {
          RemoveRemoteInterest(args, results);
          ReturnSuccess(results);
      }


[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker