ENet.cpp 385 B

12345678910111213141516171819202122
  1. #define ENET_IMPLEMENTATION
  2. #include "network/ENet.h"
  3. static int enetCounter = 0;
  4. bool ENet::add() {
  5. if(enetCounter == 0 && enet_initialize() != 0) {
  6. return true;
  7. }
  8. enetCounter++;
  9. return false;
  10. }
  11. void ENet::remove() {
  12. if(enetCounter > 0 && --enetCounter == 0) {
  13. enet_deinitialize();
  14. }
  15. }
  16. bool ENet::hasError() {
  17. return enetCounter <= 0;
  18. }