bool Router::Send( char *data, BitSize_t bitLength, PacketPriority priority, PacketReliability reliability, char orderingChannel, SystemAddressList *recipients ) { RakAssert(data); RakAssert(bitLength); if (recipients->GetList()->Size()==0) return false; if (bitLength==0) return false; DataStructures::Tree<ConnectionGraph::SystemAddressAndGroupId> tree; SystemAddress root; root = rakPeerInterface->GetExternalID(rakPeerInterface->GetSystemAddressFromIndex(0)); if (root==UNASSIGNED_SYSTEM_ADDRESS) return false; DataStructures::List<ConnectionGraph::SystemAddressAndGroupId> recipientList; unsigned i; for (i=0; i < recipients->Size(); i++) recipientList.Insert(ConnectionGraph::SystemAddressAndGroupId(recipients->GetList()->operator [](i),0, UNASSIGNED_RAKNET_GUID), __FILE__, __LINE__); if (graph->GetSpanningTree(tree, &recipientList, ConnectionGraph::SystemAddressAndGroupId(root,0,UNASSIGNED_RAKNET_GUID), 65535)==false) return false; RakNet::BitStream out; // Write timestamp first, if the user had a timestamp if (data[0]==ID_TIMESTAMP && bitLength >= BYTES_TO_BITS(sizeof(MessageID)+sizeof(RakNetTime))) { out.Write(data, sizeof(MessageID)+sizeof(RakNetTime)); data+=sizeof(MessageID)+sizeof(RakNetTime); bitLength-=BYTES_TO_BITS(sizeof(MessageID)+sizeof(RakNetTime)); } SendTree(priority, reliability, orderingChannel, &tree, data, bitLength, &out, recipients); return true; }
void FbMasterInfoBase::MakeTree(wxEvtHandler *owner, FbThread * thread, FbSQLite3ResultSet &result) const { FbBookTreeModel * model = new FbBookTreeModel; FbParentData * root = new FbParentData(*model, NULL); FbAuthParentData * auth = NULL; FbAuthParentData * list = NULL; FbSeqnParentData * seqn = NULL; while (result.NextRow()) { if (thread->IsClosed()) break; int auth_id = result.GetInt(0); int seqn_id = result.GetInt(1); if (auth == NULL) { auth = new FbAuthParentData(*model, NULL, auth_id); list = new FbAuthParentData(*model, NULL, auth_id); } if (seqn == NULL) { seqn = new FbSeqnParentData(*model, auth, seqn_id); } if (auth->GetCode() != auth_id) { if (auth->Count(*model) == 1 && seqn->GetCode() == 0) { delete auth; list->SetParent(root); } else { auth->SetParent(root); auth->SortItems(); delete list; } auth = new FbAuthParentData(*model, NULL, auth_id); list = new FbAuthParentData(*model, NULL, auth_id); seqn = new FbSeqnParentData(*model, auth, seqn_id); } if (seqn->GetCode() != seqn_id) { seqn = new FbSeqnParentData(*model, auth, seqn_id); } new FbBookChildData(*model, seqn, result.GetInt(2), result.GetInt(3)); new FbBookChildData(*model, list, result.GetInt(2), result.GetInt(3)); } if (auth && list) { if (auth->Count(*model) == 1 && seqn->GetCode() == 0) { delete auth; list->SetParent(root); } else { auth->SetParent(root); auth->SortItems(); delete list; } } model->SetRoot(root); SendTree(owner, thread, model); }