File indexing completed on 2024-05-05 05:40:33
0001 /************************************************************************* 0002 * Copyright (C) 2015 by Renaud Guezennec * 0003 * Copyright (C) 2011 by Joseph Boudou * 0004 * * 0005 * https://rolisteam.org/ * 0006 * * 0007 * Rolisteam is free software; you can redistribute it and/or modify * 0008 * it under the terms of the GNU General Public License as published * 0009 * by the Free Software Foundation; either version 2 of the License, * 0010 * or (at your option) any later version. * 0011 * * 0012 * This program is distributed in the hope that it will be useful, * 0013 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0015 * GNU General Public License for more details. * 0016 * * 0017 * You should have received a copy of the GNU General Public License * 0018 * along with this program; if not, write to the * 0019 * Free Software Foundation, Inc., * 0020 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 0021 *************************************************************************/ 0022 0023 #include "network/networkmessage.h" 0024 0025 MessageSenderInterface* NetworkMessage::m_sender= nullptr; 0026 0027 MessageSenderInterface::~MessageSenderInterface()= default; 0028 0029 NetworkMessage::NetworkMessage() {} 0030 0031 NetworkMessage::~NetworkMessage() {} 0032 0033 void NetworkMessage::sendToServer() 0034 { 0035 if(nullptr == m_sender) 0036 return; 0037 0038 m_sender->sendMessage(this); 0039 } 0040 0041 quint64 NetworkMessage::getSize() const 0042 { 0043 if(buffer() == nullptr) 0044 return 0; 0045 0046 NetworkMessageHeader* header= buffer(); 0047 return header->dataSize + sizeof(NetworkMessageHeader); 0048 } 0049 0050 void NetworkMessage::setMessageSender(MessageSenderInterface* sender) 0051 { 0052 m_sender= sender; 0053 }