home *** CD-ROM | disk | FTP | other *** search
/ Ragnaroek / Ragnaroek.img / OpponentApp / InvitationListener.m < prev    next >
Text File  |  1991-12-09  |  3KB  |  103 lines

  1. #import <appkit/appkit.h>
  2. #import "InvitationListener.h"
  3. #import <mach.h>
  4. #import <sys/message.h>
  5. #import <servers/netname.h>
  6. extern port_t name_server_port;
  7. extern id NXResponsibleDelegate();
  8. @implementation  InvitationListener :Listener
  9. {}
  10. static NXRemoteMethod *remoteMethods = NULL;
  11. #define REMOTEMETHODS 2
  12. + (void)initialize 
  13. /* */
  14. {
  15.     if (!remoteMethods) {
  16.     remoteMethods =
  17.     (NXRemoteMethod *) malloc((REMOTEMETHODS+1)*sizeof(NXRemoteMethod));
  18.     remoteMethods[0].key = 
  19.     @selector(invitationFrom:onHost:RSVP:Face:length:);
  20.     remoteMethods[0].types = "ccsb";
  21.     remoteMethods[1].key = 
  22.     @selector(Game:length:Side:YourPort:MyPort:MyFace:length:From:onHost:);
  23.     remoteMethods[1].types = "biSsbcc";
  24.     remoteMethods[REMOTEMETHODS].key = NULL;
  25.     }
  26. }
  27. -(int)invitationFrom : (char *) username
  28.     onHost : (char *) hostname
  29.     RSVP : (port_t) rsvpPort
  30.     Face : (char *) face
  31.     length : (int) length
  32. /* */
  33. {
  34.     id _NXd;
  35.     if (_NXd = NXResponsibleDelegate(self,
  36.     @selector(invitationFrom:onHost:RSVP:Face:length:)))
  37.     return [_NXd invitationFrom : username
  38.         onHost : hostname
  39.         RSVP : rsvpPort
  40.         Face : face
  41.         length : length];
  42.     return -1;
  43. }
  44.  
  45. -(int)Game : (char *) game
  46.     length : (int) length
  47.     Side : (int) side
  48.     YourPort : (port_t *) yourPort
  49.     MyPort : (port_t) myPort
  50.     MyFace : (char *) myFaceData
  51.     length : (int) mflen
  52.     From : (char *) username
  53.     onHost : (char *) hostname
  54. /* */
  55. {
  56.     id _NXd;
  57.     if (_NXd = NXResponsibleDelegate(self,
  58.     @selector(Game:length:Side:YourPort:MyPort:MyFace:length:From:onHost:)))
  59.     return [_NXd Game : game
  60.         length : length
  61.         Side : side
  62.         YourPort : yourPort
  63.         MyPort : myPort
  64.         MyFace : myFaceData
  65.         length : mflen
  66.         From : username
  67.         onHost : hostname];
  68.     return -1;
  69. }
  70.  
  71. - (int) performRemoteMethod : (NXRemoteMethod *) method
  72.                   paramList : (NXParamValue *) paramList {
  73. /* */
  74.     switch (method - remoteMethods) {
  75.     case 0:
  76.     return [self invitationFrom : paramList[0].bval.p
  77.         onHost : paramList[1].bval.p
  78.         RSVP : paramList[2].pval
  79.         Face : paramList[3].bval.p
  80.         length : paramList[3].bval.len];
  81.     case 1:
  82.     return [self Game : paramList[0].bval.p
  83.         length : paramList[0].bval.len
  84.         Side : paramList[1].ival
  85.         YourPort : ¶mList[2].pval
  86.         MyPort : paramList[3].pval
  87.         MyFace : paramList[4].bval.p
  88.         length : paramList[4].bval.len
  89.         From : paramList[5].bval.p
  90.         onHost : paramList[6].bval.p];
  91.     default:
  92.     return [super performRemoteMethod : method paramList : paramList];
  93.     }
  94. }
  95. - (NXRemoteMethod *) remoteMethodFor: (SEL) aSel {
  96. /* */
  97.     NXRemoteMethod *rm;
  98.     if (rm = NXRemoteMethodFromSel(aSel,remoteMethods))
  99.         return rm;
  100.     return [super remoteMethodFor : aSel];
  101. }
  102. @end
  103.