Example #1
0
void RoomService::start()
{
  InternalMessage *imsg;

  this->_run = true;
  Logging::Message l("Service is running...", "RoomService", Logging::Message::NOTICE);
  this->_log << l;
  while (this->_run)
    {
      while (!this->_q.isEmpty())
	{
	  imsg = this->_q.pop();
	  APacket *pck = imsg->getPacket();
	  Message *msg = reinterpret_cast<Message *>(pck->getData());
	  if (imsg->getProto() == ISocket::TCP)
	    (this->*_mfuncTCP[msg->getID()])(imsg->getFromTCP(), msg);
	  else
	    {
	      unsigned short id_room;
		  unsigned short id;
	      UDPPacket *pudp = reinterpret_cast<UDPPacket *>(pck);
		  UDPPacket::unpackID(pudp->getID(), id_room, id);
	      Room *room = Core::room_manager->getRoom(id_room);
	      if (room)
			room->notify(new InternalMessage(pudp, imsg->getFromUDP()));
	    }
	  /* check delete */
	  delete imsg;

	}
           Ultra::Sleep::usleep(300);
    }
}
Example #2
0
	Packet(const APacket& other) : APacket(other.getDirection(), other.getType())
	{
		std::memcpy(_dataPtr, other.getData(), other.getSize());
	}