home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1994 June / NEBULA_SE.ISO / SourceCode / Broadcast / Lib / BroadcastListener.m < prev    next >
Encoding:
Text File  |  1992-12-22  |  1.3 KB  |  56 lines

  1. #import <appkit/appkit.h>
  2. #import "BroadcastListener.h"
  3. #import <mach/mach.h>
  4. #import <mach/message.h>
  5. #import <servers/netname.h>
  6. extern port_t name_server_port;
  7. extern id NXResponsibleDelegate();
  8. @implementation  BroadcastListener :Listener
  9. {}
  10. static NXRemoteMethod *remoteMethods = NULL;
  11. #define REMOTEMETHODS 1
  12. + initialize 
  13. /* */
  14. {
  15.     if (!remoteMethods) {
  16.     remoteMethods =
  17.     (NXRemoteMethod *) malloc((REMOTEMETHODS+1)*sizeof(NXRemoteMethod));
  18.     remoteMethods[0].key = 
  19.     @selector(broadcast:from:);
  20.     remoteMethods[0].types = "cc";
  21.     remoteMethods[REMOTEMETHODS].key = NULL;
  22.     }
  23.     return self;
  24. }
  25. -(int)broadcast : (char *) message
  26.     from : (char *) user
  27. /* */
  28. {
  29.     id _NXd;
  30.     if (_NXd = NXResponsibleDelegate(self,
  31.     @selector(broadcast:from:)))
  32.     return [_NXd broadcast : message
  33.         from : user];
  34.     return -1;
  35. }
  36.  
  37. - (int) performRemoteMethod : (NXRemoteMethod *) method
  38.                   paramList : (NXParamValue *) paramList {
  39. /* */
  40.     switch (method - remoteMethods) {
  41.     case 0:
  42.     return [self broadcast : paramList[0].bval.p
  43.         from : paramList[1].bval.p];
  44.     default:
  45.     return [super performRemoteMethod : method paramList : paramList];
  46.     }
  47. }
  48. - (NXRemoteMethod *) remoteMethodFor: (SEL) aSel {
  49. /* */
  50.     NXRemoteMethod *rm;
  51.     if (rm = NXRemoteMethodFromSel(aSel,remoteMethods))
  52.         return rm;
  53.     return [super remoteMethodFor : aSel];
  54. }
  55. @end
  56.