Пример #1
0
			void Query::Run()
			{
				m_Response.Clear();

				Time::Timer timer;
				unsigned int iLastData = 0;

				try
				{
					Lock();
					happyhttp::Connection conn( m_strHost.c_str(), m_iPort );
					conn.setcallbacks( NULL, OnData, NULL, (void*) this );

					conn.putrequest( m_strMethod.c_str(), m_strRequest.c_str() );
						conn.putheader( "Accept", "*/*" );
						conn.putheader( "User-Agent", "Agent:Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.116 Safari/537.36" );

						if ( !m_PostParams.empty() )
						{
							conn.putheader( "Content-Length", m_PostParams.length() );
							conn.putheader( "Content-type", "application/x-www-form-urlencoded" );
						}

					conn.endheaders();

					conn.send( (const unsigned char*) m_PostParams.c_str(), m_PostParams.length() );
					Unlock();

					while( conn.outstanding() )
					{
						conn.pump();
						Bootil::Platform::Sleep( 10 );

						//
						// Time out connection after x seconds of no activity
						//
						if ( timer.Seconds() > 5 ) break;

						//
						// Don't time out if we got data this frame
						//
						if ( GetResponse().GetWritten() != iLastData )
						{
							timer.Reset();
							iLastData = GetResponse().GetWritten();
						}
					}
				}
				catch ( happyhttp::Wobbly& e )
				{
					// Failed for some reason.
				}
			}
Пример #2
0
    double Test(const Time::Milliseconds& duration, uint_t soundFreq)
    {
      const typename Sound::FixedChannelsMixer<Channels>::Ptr mixer = Sound::FixedChannelsMatrixMixer<Channels>::Create();

      typename Sound::MultichannelSample<Channels>::Type input;
      const Time::Timer timer;
      const uint_t totalFrames = uint64_t(duration.Get()) * soundFreq / duration.PER_SECOND;
      for (uint_t frame = 0; frame != totalFrames; ++frame)
      {
        mixer->ApplyData(input);
      }
      const Time::Nanoseconds elapsed = timer.Elapsed();
      const Time::Nanoseconds emulated(duration);
      return double(emulated.Get()) / elapsed.Get();
    }
Пример #3
0
 void AddMissed(const PluginType& plug, const Time::Timer& scanTimer)
 {
   StatItem& item = GetStat(plug);
   ++item.Missed;
   item.MissedTime += scanTimer.Elapsed() + item.ScanTime;
   item.ScanTime = Stamp(0);
 }
Пример #4
0
			void Query::Run()
			{
				m_bError = false;
				m_strError = "";

				m_Response.Clear();

				unsigned int iLastData = 0;

				try
				{
					Lock();

						happyhttp::Connection conn( m_strHost.c_str(), m_iPort );
						conn.setcallbacks( NULL, OnData, NULL, (void*) this );

						conn.putrequest( m_strMethod.c_str(), m_strRequest.c_str() );
						conn.putheader( "Accept", "*/*" );
						conn.putheader( "User-Agent", "Agent:Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.116 Safari/537.36" );

						if ( m_PostBody.GetWritten() > 0 )
						{
							// Finish off the post body
							m_PostBody.WriteString( "\r\n--" + m_strBoundary + "--\r\n\r\n", false );

							// Add headers
							conn.putheader( "Content-Type", ("multipart/form-data; boundary=" + m_strBoundary).c_str() );
							conn.putheader( "Content-Length", m_PostBody.GetWritten() );
							conn.putheader( "Connection", "Close" );
							conn.putheader( "Cache-Control", "no-cache" );
						}

						conn.endheaders();

						if ( m_PostBody.GetWritten() > 0 )
						{
							conn.send( (const unsigned char*) m_PostBody.GetBase(), m_PostBody.GetWritten() );
						}
						else
						{
							BString strEmpty;
							conn.send( (const unsigned char*) strEmpty.c_str(), strEmpty.length() );
						}
			
					Unlock();
					
					Time::Timer timer;

					while( conn.outstanding() )
					{
						conn.pump();

						//
						// Don't time out if we got data this frame
						//
						if ( GetResponse().GetWritten() != iLastData )
						{
							timer.Reset();
							iLastData = GetResponse().GetWritten();
						}

						//
						// Time out connection after x seconds of no activity
						//
						if ( timer.Seconds() > (60 * 3) ) break;

						//
						// Breathe
						//
						Bootil::Platform::Sleep( 10 );
					}
				}
				catch ( happyhttp::Wobbly& e )
				{
					m_bError = true;
					m_strError = e.what();
				}
			}
Пример #5
0
 void AddScanned(const PluginType& plug, const Time::Timer& scanTimer)
 {
   StatItem& item = GetStat(plug);
   item.ScanTime += scanTimer.Elapsed();
 }