void TcpServer::RecvMsg() { char buffer[MAXSIZE]; memset(buffer, 0, MAXSIZE); int len = 0; // cout<<"准备开始接收数据..."<<endl; while (((len = recv(client_fd, buffer, MAXSIZE, 0)) > 0) && (heartCondition == true)) { // cout<<"接收数据大小: "<<len<<endl; RecieveData(buffer, len, client_fd); memset(buffer, 0, MAXSIZE); // cout<<"接收完毕: "<<endl; } ClearAllTmpData(); //cout<<"退出断开连接"<<endl; }
// does all the networking stuff void Game::DoNetworking() { // constant packet generation if(m_packetTransferState == CONSTANT) { // send the data every frame while constant SendMyCarData(); }// end of constant packet generation else if(m_packetTransferState == INTERPOLATE) { // only send a packet if its time to if(GetTickCount() > m_lastPacketSentTime + INTERPOLATE_SENDTIME) { SendMyCarData(); } } else if(m_packetTransferState == DEADRECKONING) { // if we have exceeded the threshold then send our info, or if our car has just stopped if(m_pMyCar->Position().Distance(m_pMyCarRemote->Position()) > DEADRECKONING_THRESHOLD || m_carHasJustStopped) { // send a packet SendMyCarData(); // now update our local representation of the remote side m_pMyCarRemote->SetX(m_pMyCar->X()); m_pMyCarRemote->SetY(m_pMyCar->Y()); m_pMyCarRemote->SetDirectionX(m_pMyCar->DirectionX()); m_pMyCarRemote->SetDirectionY(m_pMyCar->DirectionY()); m_pMyCarRemote->SetAngleY(m_pMyCar->GetAngleY()); m_pMyCarRemote->SetTopSpeed(m_pMyCar->TopSpeed()); m_pMyCarRemote->SetSpeed(m_pMyCar->Speed()); m_pMyCarRemote->SetFriction(m_pMyCar->Friction()); } } // now recieve date RecieveData(); }
ISTBOOL FitModel(Sphere *self, ISTFLOAT data[3]) { struct sphere *s; s = (struct sphere *)self; RecieveData(&s->model, data); if (!GetAvailableVectorNum(&s->model)) { goto EXIT; } Get4Points(&s->model); if (!GetSphereFrom4Points(&s->model)) { goto EXIT; } return ISTTRUE; EXIT: return ISTFALSE; }