/* -*- Objc -*- */ /* * $Id: NetClient.m,v 1.1 2003/05/26 10:22:12 thunder Exp $ * * Copyright (C) 2003 Free Software Foundation, Inc. * * This file is part of GNU Hégémonie. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include #include #include #include "Network/NetClient.h" #include "Network/NetInfosClient.h" #include "GameEngine/HgPlayerState.h" #include "GameEngine/HgGame.h" /** * NetClient class * Adopt the NetClient protocol */ @implementation NetClient /** * Initialise NetClient with a proxy that represents this client on the server * */ - (id) initWithProxy: (NSDistantObject *)proxy withGame: (HgGame *)game { NSParameterAssert (proxy); NSParameterAssert (game); self = [super init]; if (self != nil) { _proxy = RETAIN(proxy); _game = RETAIN(game); } return self; } /** * Release NetClient. */ - (void) dealloc { RELEASE(_proxy); RELEASE(_game); [super dealloc]; } /** * This will create object */ - (void) createObject: (HgObject *)object { NSParameterAssert(object); [_game addObject: object]; } /** * This will destroy object */ - (void) destroyObject: (HgObject *)object { NSParameterAssert(object); [_game removeObject: object]; } /** * This will update object */ - (void) updateObject: (HgObject *)object { NSParameterAssert(object); /** * ----- FIXME ----- * voir avec dam pour updater un objet */ } /** * This will create player */ - (void) createPlayer: (HgPlayer *)player { NSParameterAssert(player); //HgPlayerState *state = [[HgPlayerState alloc] initWithPlayer: player]; [_game addPlayer: player]; } /** * This will destroy player */ - (void) destroyPlayer: (HgPlayer *)player { NSParameterAssert(player); [_game removePlayer: player]; } /** * This will update player */ - (void) updatePlayer: (HgPlayer *)player { NSParameterAssert(player); } /** * This will create team */ - (void) createTeam: (HgTeam *)team { NSParameterAssert(team); [_game addTeam: team]; } /** * This will destroy team */ - (void) destroyTeam: (HgTeam *)team { NSParameterAssert(team); [_game removeTeam: team]; } /** * This will update team */ - (void) updateTeam: (HgTeam *)team { NSParameterAssert(team); } /** * Send a request to the server to be disconnect */ - (void) disconnect { [_proxy disconnect]; } /** * Send a request to the server to update the player's state */ - (void) updatePlayerState: (HgPlayerState *)playerState { NSParameterAssert(playerState); [_proxy updatePlayerState: playerState]; } /** * Send a request to the server to execute command */ - (NSString *) execCommand: (NSString *)command { NSParameterAssert(command); return [_proxy execCommand: command]; } /** * Send to the server message to be print */ - (void) talk: (NSString *)message { NSParameterAssert(message); [_proxy talk: message]; } /** * Returns the player's state */ - (HgPlayerState *) playerState { return _playerState; } @end