Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 27, 2009, 9:39:38 PM (16 years ago)
Author:
scheusso
Message:

it is now possible to send packets/network function calls to all clients by passing CLIENTID_UNKNOWN as clientID

Location:
code/trunk/src/network
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/network/ConnectionManager.cc

    r3084 r3093  
    143143  }
    144144
    145   bool ConnectionManager::addPacket(ENetPacket *packet, int clientID) {
    146     ClientInformation *temp = ClientInformation::findClient(clientID);
    147     if(!temp){
    148       COUT(3) << "C.Man: addPacket findClient failed" << std::endl;
    149       return false;
    150     }
    151     return addPacket(packet, temp->getPeer());
     145  bool ConnectionManager::addPacket(ENetPacket *packet, unsigned int clientID) {
     146    if ( clientID == CLIENTID_UNKNOWN )
     147    {
     148      return addPacketAll(packet);
     149    }
     150    else
     151    {
     152      ClientInformation *temp = ClientInformation::findClient(clientID);
     153      if(!temp){
     154        COUT(3) << "C.Man: addPacket findClient failed" << std::endl;
     155        return false;
     156      }
     157      return addPacket(packet, temp->getPeer());
     158    }
    152159  }
    153160
     
    156163      return false;
    157164    boost::recursive_mutex::scoped_lock lock(enet_mutex_g);
    158     for(ClientInformation *i=ClientInformation::getBegin()->next(); i!=0; i=i->next()){
    159       COUT(3) << "adding broadcast packet for client: " << i->getID() << std::endl;
    160       if(enet_peer_send(i->getPeer(), 0, packet)!=0)
    161         return false;
    162     }
     165//    for(ClientInformation *i=ClientInformation::getBegin()->next(); i!=0; i=i->next()){
     166//      COUT(3) << "adding broadcast packet for client: " << i->getID() << std::endl;
     167//      if(enet_peer_send(i->getPeer(), 0, packet)!=0)
     168//        return false;
     169//    }
     170    enet_host_broadcast( instance_->server, 0, packet);
    163171    return true;
    164172  }
  • code/trunk/src/network/ConnectionManager.h

    r3084 r3093  
    7676    bool quitListener();
    7777    static bool addPacket(ENetPacket *packet, ENetPeer *peer);
    78     static bool addPacket(ENetPacket *packet, int ID);
     78    static bool addPacket(ENetPacket *packet, unsigned int ID);
    7979    static bool addPacketAll(ENetPacket *packet);
    8080    bool sendPackets();
Note: See TracChangeset for help on using the changeset viewer.