diff --git a/libretroshare/src/chat/p3chatservice.cc b/libretroshare/src/chat/p3chatservice.cc index bafdb575c..72fc3fde5 100644 --- a/libretroshare/src/chat/p3chatservice.cc +++ b/libretroshare/src/chat/p3chatservice.cc @@ -95,49 +95,51 @@ int p3ChatService::tick() void p3ChatService::sendPublicChat(const std::string &msg) { - /* go through all the peers */ + /* go through all the peers */ - std::set ids; - std::set::iterator it; - mServiceCtrl->getPeersConnected(getServiceInfo().mServiceType, ids); + std::set ids; + std::set::iterator it; + mServiceCtrl->getPeersConnected(getServiceInfo().mServiceType, ids); - /* add in own id -> so get reflection */ - RsPeerId ownId = mServiceCtrl->getOwnId(); - ids.insert(ownId); + /* add in own id -> so get reflection */ + RsPeerId ownId = mServiceCtrl->getOwnId(); + ids.insert(ownId); #ifdef CHAT_DEBUG - std::cerr << "p3ChatService::sendChat()"; - std::cerr << std::endl; + std::cerr << "p3ChatService::sendChat()"; + std::cerr << std::endl; #endif - for(it = ids.begin(); it != ids.end(); ++it) - { - RsChatMsgItem *ci = new RsChatMsgItem(); + for(it = ids.begin(); it != ids.end(); ++it) + { + RsChatMsgItem *ci = new RsChatMsgItem(); - ci->PeerId(*it); - ci->chatFlags = RS_CHAT_FLAG_PUBLIC; - ci->sendTime = time(NULL); - ci->recvTime = ci->sendTime; - ci->message = msg; + ci->PeerId(*it); + ci->chatFlags = RS_CHAT_FLAG_PUBLIC; + ci->sendTime = time(NULL); + ci->recvTime = ci->sendTime; + ci->message = msg; #ifdef CHAT_DEBUG - std::cerr << "p3ChatService::sendChat() Item:"; - std::cerr << std::endl; - ci->print(std::cerr); - std::cerr << std::endl; + std::cerr << "p3ChatService::sendChat() Item:"; + std::cerr << std::endl; + ci->print(std::cerr); + std::cerr << std::endl; #endif - if (*it == ownId) { - //mHistoryMgr->addMessage(false, RsPeerId(), ownId, ci); - ChatMessage message; - initChatMessage(ci, message); - message.incoming = false; - message.online = true; - RsServer::notify()->notifyChatMessage(message); - mHistoryMgr->addMessage(message); - } - sendItem(ci); - } + if (*it == ownId) + { + //mHistoryMgr->addMessage(false, RsPeerId(), ownId, ci); + ChatMessage message; + initChatMessage(ci, message); + message.incoming = false; + message.online = true; + RsServer::notify()->notifyChatMessage(message); + mHistoryMgr->addMessage(message); + } + else + checkSizeAndSendMessage(ci); + } } @@ -567,10 +569,10 @@ uint32_t p3ChatService::getMaxMessageSecuritySize(int type) { switch (type) { - case RS_CHAT_TYPE_PUBLIC: case RS_CHAT_TYPE_LOBBY: return MAX_MESSAGE_SECURITY_SIZE; + case RS_CHAT_TYPE_PUBLIC: case RS_CHAT_TYPE_PRIVATE: case RS_CHAT_TYPE_DISTANT: return 0; // unlimited diff --git a/libretroshare/src/serialiser/rsserviceserialiser.cc b/libretroshare/src/serialiser/rsserviceserialiser.cc index 247b2281e..d99d03de1 100644 --- a/libretroshare/src/serialiser/rsserviceserialiser.cc +++ b/libretroshare/src/serialiser/rsserviceserialiser.cc @@ -58,7 +58,10 @@ bool RsServiceSerialiser::serialise(RsItem *i, void *data, uint32_t *pktsize) return false; /* not enough space */ if (tlvsize > getRsPktMaxSize()) - return false; /* packet too big */ + { + std::cerr << "(EE) Serialised packet is too big. Maximum allowed size is " << getRsPktMaxSize() << ". Serialised size is " << tlvsize << ". Please tune your service to correctly split packets" << std::endl; + return false; /* packet too big */ + } *pktsize = tlvsize;