Пример #1
0
    void GateWayFinder::Start()
    {
        if (is_running_)
        {
            return;
        }

        is_running_ = true;
#ifdef PEER_PC_CLIENT
        if (!ping_client_)
        {
            ping_client_ = network::PingClientBase::create(io_svc_);
            
            if (!ping_client_)
            {
                return;
            }

            is_bind_success_ = ping_client_->Bind(cdnips[rand() % (sizeof(cdnips)/sizeof(cdnips[0]))]);
        }

        if (is_bind_success_)
        {
            Reset();
            StartSend();
        }
#endif
    }
Пример #2
0
void DoCustomPreloadStep( )
{
	struct Player * p = &Players[playerid];

//	printf( "Custom preload.\n" );
	SblockInternal( 16, 64, 16, 89, 0 );

	SblockInternal( 3, 64, 2, 63, 12 ); //create sign

	SignTextUp( 3, 64, 2, "Trigger", "<><" );

	SblockInternal( 3, 64, 1, 63, 12 ); //create sign

	StartSend();
	SignTextUp( 3, 64, 1, "Latch", "<><" );


	p->custom_preload_step = 0;


	//actually spawns
	p->x = (1<<FIXEDPOINT)/2;
	p->y = 100*(1<<FIXEDPOINT);
	p->stance = p->y + (1<<FIXEDPOINT);
	p->z = (1<<FIXEDPOINT)/2;
	p->need_to_send_lookupdate = 1;
}
Пример #3
0
    void GateWayFinder::HandleTimeOut(const boost::system::error_code& error)
    {
        if (!is_running_)
        {
            return;
        }

        if (error != boost::asio::error::operation_aborted)
        {
            DebugLog("GateWayFinder::HandleTimeOut\n");
            assert(!error);

            if (ttl_ < 10)
            {
                ttl_++;
            }
            else
            {
                ++time_out_num_;
            }

            ping_client_->Cancel(sequence_number_);
            //这里最多会有15次重试机会
            if (ttl_ < 10 || time_out_num_ < 5)
            {
                StartSend();
            }
        }
    }
Пример #4
0
void Connection::DispatchSend( std::vector< uint8_t > buffer )
{
	bool should_start_send = m_pending_sends.empty();
	m_pending_sends.push_back( buffer );
	if( should_start_send )
	{
		StartSend();
	}
}
Пример #5
0
DRIVER_ERROR HeaderLJMono::Send ()
{
    DRIVER_ERROR err;

    StartSend ();

    err = Graphics ();     // start raster graphics and set compression mode

    return err;
}
Пример #6
0
void Connection::HandleSend( const boost::system::error_code &  error, std::list< std::vector< uint8_t > >::iterator itr )
{
	if( error || HasError() || m_hive->HasStopped() )
	{
		StartError( error );
	}
	else
	{
		OnSend( *itr );
		m_pending_sends.erase( itr );
		StartSend();
	}
}
Пример #7
0
void GameTick()
{
	if( didflip )
	{
		StartSend();
		Sbyte( 0x29 ); //effect
		Sstring( "random.click", -1 );
		Sint( (uint16_t)(flipx<<3) );
		Sint( (uint16_t)(flipy<<3) );
		Sint( (uint16_t)(flipz<<3) );
		Sfloat( 32 ); //100% volume
		Sbyte( 63 ); //100% speed
		DoneSend();
		didflip = 0;
	}
}
Пример #8
0
void GameTick()
{


	if( didflip )
	{
		StartSend();
		Sbyte( 0x29 ); //effect
		Sstring( "random.click", -1 );
		Sint( (uint16_t)(4<<3) );
		Sint( (uint16_t)(64<<3) );
		Sint( (uint16_t)(sel<<3) );
		Sfloat( 32 ); //100% volume
		Sbyte( 63 ); //100% speed
		DoneSend();
		didflip = 0;

		SetManyWS( pgm_read_byte( &wools[sel*3+0] ), pgm_read_byte( &wools[sel*3+1] ), pgm_read_byte( &wools[sel*3+2] ), 20 );
	}
}
Пример #9
0
    void GateWayFinder::HandleReceive(unsigned char type, const string & src_ip,
        boost::uint32_t ping_rtt_for_win7)
    {
        if (!is_running_)
        {
            return;
        }

        if (type == icmp_header::time_exceeded)
        {
            DebugLog("received time_exceeded\n");

            time_out_num_ = 0;
            timer_.cancel();

            posix_time::ptime now = posix_time::microsec_clock::universal_time();
            DebugLog("from %s, ttl=%d, time=%dms\n", src_ip.c_str(),
                ttl_, (now - time_sent_).total_milliseconds());

            if (base::util::is_private_address(src_ip.c_str()))
            {
                DebugLog("received my time_exceeded from private_address\n");
                ++ttl_;
                StartSend();
            }
            else
            {
                DebugLog("get public gateway:%s\n", src_ip.c_str());
                listener_->OnGateWayFound(src_ip);
            }
        }
        else
        {
            assert(false);
        }
    }
Пример #10
0
DRIVER_ERROR Header6XX::Send()
{   DRIVER_ERROR err;

    StartSend();

    err = thePrinter->Send((const BYTE*)BlackExtractOff,
                        sizeof(BlackExtractOff)); // just pertains to 2-pen
    ERRCHECK;

    err = ConfigureRasterData();
    ERRCHECK;

    if (ResolutionY[0] == 600)
    {
        char uom[10];
        sprintf(uom,"%c%c%c%d%c",ESC,'&','u',thePrintMode->ResolutionY[K],'D');
        err=thePrinter->Send((const BYTE*)uom, 7 );
        ERRCHECK;
    }

    err=Graphics();     // start raster graphics and set compression mode

return err;
}
Пример #11
0
DRIVER_ERROR HeaderLJColor::Send ()
{
    DRIVER_ERROR err;
    char    uom[12];

    COLORMODE       eC = COLOR;
    MEDIATYPE       eM;
    QUALITY_MODE    eQ;
    BOOL            bD;

    ((LJColor *)thePrinter)->bGrey_K = FALSE;
    if ((thePrintContext->GetPrintModeSettings (eQ, eM, eC, bD)) == NO_ERROR &&
            eC == GREY_K)
    {
        ((LJColor *)thePrinter)->bGrey_K = TRUE;
    }

    StartSend ();

    if (eC != GREY_K)
    {

        /*
         *      Configure image data - ESC*v#W - # = 6 bytes
         *      02 - RGB colorspace (00 - Device RGB)
         *      03 - Direct pixel
         *      08 - bits per index - ignored for direct pixel
         *      08, 08, 08 - bits per primary each
         */

        err = thePrinter->Send ((const BYTE *) "\033*v6W\00\03\010\010\010\010", 11);
        ERRCHECK;

//      Continues tone dither
//      Logical operation - 0

//      err = thePrinter->Send ((const BYTE *) "\033*t18J\033*l204O", 13);
        err = thePrinter->Send ((const BYTE *) "\033*t18J", 6);

        ERRCHECK;

        /*
         *      Driver Configuration Command - ESC*#W - # = 3 bytes
         *      device id - 6 = color HP LaserJet Printer
         *      func index - 4 = Select Colormap
         *      argument - 2   = Vivid Graphics
         */

        err = thePrinter->Send ((const BYTE *) "\033*o3W\06\04\06", 8);
        ERRCHECK;

        /*
         *      Program color palette entries
         */
        err = thePrinter->Send ((const BYTE *) "\033*v255A\033*v255B\033*v255C\033*v0I", 26);
        ERRCHECK;

        err = thePrinter->Send ((const BYTE *) "\033*v255A\033*v0B\033*v0C\033*v6I", 22);
        ERRCHECK;
        err = thePrinter->Send ((const BYTE *) "\033*v0A\033*v255B\033*v0C\033*v5I", 22);
        ERRCHECK;
        err = thePrinter->Send ((const BYTE *) "\033*v0A\033*v0B\033*v255C\033*v3I", 22);
        ERRCHECK;
        err = thePrinter->Send ((const BYTE *) "\033*v255A\033*v255B\033*v0C\033*v4I", 24);
        ERRCHECK;
        err = thePrinter->Send ((const BYTE *) "\033*v255A\033*v0B\033*v255C\033*v2I", 24);
        ERRCHECK;
        err = thePrinter->Send ((const BYTE *) "\033*v0A\033*v255B\033*v255C\033*v1I", 24);
        ERRCHECK;
        err = thePrinter->Send ((const BYTE *) "\033*v0A\033*v0B\033*v0C\033*v7I", 20);
        ERRCHECK;
    }

    sprintf (uom, "\033*r%dS", thePrintContext->OutputPixelsPerRow ());
    err = thePrinter->Send ((const BYTE*)uom, strlen (uom));
    ERRCHECK;

    err = Graphics ();     // start raster graphics and set compression mode

    return err;
}