Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 1711 was 1711, checked in by scheusso, 16 years ago

we use enetcallback for destroying packets now (unfortunately there are still some problems)

  • Property svn:eol-style set to native
File size: 960 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
30// bool Host::chat(std::string& message){
31//   if(!instance_)
32//     return false;
33//   packet::Chat *c = new packet::Chat(message, getPlayerID());
34//   return instance_->sendChat(c);
35// }
36
37// bool 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
50unsigned int 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.