Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/network/src/network/Host.cc @ 1675

Last change on this file since 1675 was 1675, checked in by rgrieder, 16 years ago

Please always set svn property eol-style to 'native'. That avoids problems with line endings on different platforms.

  • Property svn:eol-style set to native
File size: 900 bytes
Line 
1#include <assert.h>
2
3#include "Host.h"
4#include "packet/Packet.h"
5
6namespace network {
7
8Host *Host::instance_=0;
9 
10Host::Host()
11{
12  assert(instance_==0);
13  instance_=this;
14}
15
16
17Host::~Host()
18{
19  instance_=0;
20}
21
22bool Host::addPacket(ENetPacket *packet, int clientID){
23  if(instance_)
24    return instance_->queuePacket(packet, clientID);
25  else
26    return false;
27}
28
29
30bool Host::chat(std::string& message){
31  if(!instance_)
32    return false;
33  packet::Chat *c = new packet::Chat(message);
34  return instance_->sendChat(c);
35}
36
37bool Host::receiveChat(network::packet::Chat *message, unsigned int clientID){
38  if(instance_)
39    return instance_->processChat(message, clientID);
40  else
41    return false;
42}
43
44int Host::getPlayerID(){ 
45  if(!instance_)
46    return 0;
47  return instance_->playerID();
48}
49
50int Host::getShipID(){ 
51  if(!instance_)
52    return 0;
53  return instance_->shipID();
54}
55
56}//namespace network
Note: See TracBrowser for help on using the repository browser.