void CTSGetIp::Handle(void* Buffer, int Size) { //解包 CReGetUserIpPacket opPacket; opPacket.Unpack(Buffer, Size); int count = opPacket.UserList.size(); int TaskId = opPacket.nTaskId; int SeqNumber = opPacket.Header.nSeqNumber; Tracker.Back(SeqNumber); //消包 CTask *Task; for(int i = 0; i < count; i++) { if(! TaskPool.GetTask(TaskId,Task)) break; int UserIp = opPacket.UserList.at(i).nUserIp; int TcpPort = opPacket.UserList.at(i).wTcpPort; string FileCode = opPacket.strHashValue; Task->SetCode(FileCode); CResource *Resource = new CResource(IpToString(UserIp), TcpPort); CResourcePool* ResourcePool = Task->GetResourcePool(); ResourcePool->AddResource(Resource); } }
void CTSGetUrl::Handle(void* Buffer, int Size) { //解包 CReGetUrlPacket opPacket; opPacket.Unpack(Buffer, Size); //得到包中的资源 string strUrl = opPacket.strUrl; string strRef = opPacket.strReference; string FileCode = opPacket.strHashValue; int TaskId = opPacket.nTaskId; int SeqNumber = opPacket.Header.nSeqNumber; Tracker.Back(SeqNumber); CTask *Task; if(TaskPool.GetTask(TaskId,Task)) { Task->SetCode(FileCode); CResource *Resource = new CResource(strUrl, strRef, true); CResourcePool* ResourcePool = Task->GetResourcePool(); ResourcePool->AddResource(Resource); } }