mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
added packet slicing for large broadcast chat items, and output warning when chat of serialised item is too big. Also fixed a couple of bugs in the handling of chat packets
This commit is contained in:
parent
1b5d31ff7f
commit
59aef8ab7b
@ -95,49 +95,51 @@ int p3ChatService::tick()
|
|||||||
|
|
||||||
void p3ChatService::sendPublicChat(const std::string &msg)
|
void p3ChatService::sendPublicChat(const std::string &msg)
|
||||||
{
|
{
|
||||||
/* go through all the peers */
|
/* go through all the peers */
|
||||||
|
|
||||||
std::set<RsPeerId> ids;
|
std::set<RsPeerId> ids;
|
||||||
std::set<RsPeerId>::iterator it;
|
std::set<RsPeerId>::iterator it;
|
||||||
mServiceCtrl->getPeersConnected(getServiceInfo().mServiceType, ids);
|
mServiceCtrl->getPeersConnected(getServiceInfo().mServiceType, ids);
|
||||||
|
|
||||||
/* add in own id -> so get reflection */
|
/* add in own id -> so get reflection */
|
||||||
RsPeerId ownId = mServiceCtrl->getOwnId();
|
RsPeerId ownId = mServiceCtrl->getOwnId();
|
||||||
ids.insert(ownId);
|
ids.insert(ownId);
|
||||||
|
|
||||||
#ifdef CHAT_DEBUG
|
#ifdef CHAT_DEBUG
|
||||||
std::cerr << "p3ChatService::sendChat()";
|
std::cerr << "p3ChatService::sendChat()";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for(it = ids.begin(); it != ids.end(); ++it)
|
for(it = ids.begin(); it != ids.end(); ++it)
|
||||||
{
|
{
|
||||||
RsChatMsgItem *ci = new RsChatMsgItem();
|
RsChatMsgItem *ci = new RsChatMsgItem();
|
||||||
|
|
||||||
ci->PeerId(*it);
|
ci->PeerId(*it);
|
||||||
ci->chatFlags = RS_CHAT_FLAG_PUBLIC;
|
ci->chatFlags = RS_CHAT_FLAG_PUBLIC;
|
||||||
ci->sendTime = time(NULL);
|
ci->sendTime = time(NULL);
|
||||||
ci->recvTime = ci->sendTime;
|
ci->recvTime = ci->sendTime;
|
||||||
ci->message = msg;
|
ci->message = msg;
|
||||||
|
|
||||||
#ifdef CHAT_DEBUG
|
#ifdef CHAT_DEBUG
|
||||||
std::cerr << "p3ChatService::sendChat() Item:";
|
std::cerr << "p3ChatService::sendChat() Item:";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
ci->print(std::cerr);
|
ci->print(std::cerr);
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (*it == ownId) {
|
if (*it == ownId)
|
||||||
//mHistoryMgr->addMessage(false, RsPeerId(), ownId, ci);
|
{
|
||||||
ChatMessage message;
|
//mHistoryMgr->addMessage(false, RsPeerId(), ownId, ci);
|
||||||
initChatMessage(ci, message);
|
ChatMessage message;
|
||||||
message.incoming = false;
|
initChatMessage(ci, message);
|
||||||
message.online = true;
|
message.incoming = false;
|
||||||
RsServer::notify()->notifyChatMessage(message);
|
message.online = true;
|
||||||
mHistoryMgr->addMessage(message);
|
RsServer::notify()->notifyChatMessage(message);
|
||||||
}
|
mHistoryMgr->addMessage(message);
|
||||||
sendItem(ci);
|
}
|
||||||
}
|
else
|
||||||
|
checkSizeAndSendMessage(ci);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -567,10 +569,10 @@ uint32_t p3ChatService::getMaxMessageSecuritySize(int type)
|
|||||||
{
|
{
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case RS_CHAT_TYPE_PUBLIC:
|
|
||||||
case RS_CHAT_TYPE_LOBBY:
|
case RS_CHAT_TYPE_LOBBY:
|
||||||
return MAX_MESSAGE_SECURITY_SIZE;
|
return MAX_MESSAGE_SECURITY_SIZE;
|
||||||
|
|
||||||
|
case RS_CHAT_TYPE_PUBLIC:
|
||||||
case RS_CHAT_TYPE_PRIVATE:
|
case RS_CHAT_TYPE_PRIVATE:
|
||||||
case RS_CHAT_TYPE_DISTANT:
|
case RS_CHAT_TYPE_DISTANT:
|
||||||
return 0; // unlimited
|
return 0; // unlimited
|
||||||
|
@ -58,7 +58,10 @@ bool RsServiceSerialiser::serialise(RsItem *i, void *data, uint32_t *pktsize)
|
|||||||
return false; /* not enough space */
|
return false; /* not enough space */
|
||||||
|
|
||||||
if (tlvsize > getRsPktMaxSize())
|
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;
|
*pktsize = tlvsize;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user