#import <appkit/appkit.h>
#import "InvitationListener.h"
#import <mach.h>
#import <sys/message.h>
#import <servers/netname.h>
extern port_t name_server_port;
extern id NXResponsibleDelegate();
@implementation  InvitationListener :Listener
{}
static NXRemoteMethod *remoteMethods = NULL;
#define REMOTEMETHODS 2
+ (void)initialize 
/* */
{
    if (!remoteMethods) {
	remoteMethods =
	(NXRemoteMethod *) malloc((REMOTEMETHODS+1)*sizeof(NXRemoteMethod));
	remoteMethods[0].key = 
	@selector(invitationFrom:onHost:RSVP:Face:length:);
	remoteMethods[0].types = "ccsb";
	remoteMethods[1].key = 
	@selector(Game:length:Side:YourPort:MyPort:MyFace:length:From:onHost:);
	remoteMethods[1].types = "biSsbcc";
	remoteMethods[REMOTEMETHODS].key = NULL;
    }
}
-(int)invitationFrom : (char *) username
	onHost : (char *) hostname
	RSVP : (port_t) rsvpPort
	Face : (char *) face
	length : (int) length
/* */
{
    id _NXd;
    if (_NXd = NXResponsibleDelegate(self,
	@selector(invitationFrom:onHost:RSVP:Face:length:)))
	return [_NXd invitationFrom : username
		onHost : hostname
		RSVP : rsvpPort
		Face : face
		length : length];
    return -1;
}

-(int)Game : (char *) game
	length : (int) length
	Side : (int) side
	YourPort : (port_t *) yourPort
	MyPort : (port_t) myPort
	MyFace : (char *) myFaceData
	length : (int) mflen
	From : (char *) username
	onHost : (char *) hostname
/* */
{
    id _NXd;
    if (_NXd = NXResponsibleDelegate(self,
	@selector(Game:length:Side:YourPort:MyPort:MyFace:length:From:onHost:)))
	return [_NXd Game : game
		length : length
		Side : side
		YourPort : yourPort
		MyPort : myPort
		MyFace : myFaceData
		length : mflen
		From : username
		onHost : hostname];
    return -1;
}

- (int) performRemoteMethod : (NXRemoteMethod *) method
                  paramList : (NXParamValue *) paramList {
/* */
    switch (method - remoteMethods) {
    case 0:
	return [self invitationFrom : paramList[0].bval.p
		onHost : paramList[1].bval.p
		RSVP : paramList[2].pval
		Face : paramList[3].bval.p
		length : paramList[3].bval.len];
    case 1:
	return [self Game : paramList[0].bval.p
		length : paramList[0].bval.len
		Side : paramList[1].ival
		YourPort : &paramList[2].pval
		MyPort : paramList[3].pval
		MyFace : paramList[4].bval.p
		length : paramList[4].bval.len
		From : paramList[5].bval.p
		onHost : paramList[6].bval.p];
    default:
	return [super performRemoteMethod : method paramList : paramList];
    }
}
- (NXRemoteMethod *) remoteMethodFor: (SEL) aSel {
/* */
    NXRemoteMethod *rm;
    if (rm = NXRemoteMethodFromSel(aSel,remoteMethods))
        return rm;
    return [super remoteMethodFor : aSel];
}
@end
