void WebClientApp::setup()
{
	gl::enable( GL_TEXTURE_2D );
	
	mFont			= Font( "Georgia", 24 );
	mFrameRate		= 0.0f;
	mFullScreen		= false;
	mHost			= "libcinder.org";
	mPort			= 80;
	
	mHttpRequest = HttpRequest( "GET", "/", HttpVersion::HTTP_1_0 );
	mHttpRequest.setHeader( "Host", mHost );
	mHttpRequest.setHeader( "Accept", "*/*" );
	mHttpRequest.setHeader( "Connection", "close" );

	mParams = params::InterfaceGl::create( "Params", ivec2( 200, 150 ) );
	mParams->addParam( "Frame rate",	&mFrameRate,					"", true );
	mParams->addParam( "Full screen",	&mFullScreen ).key( "f" );
	mParams->addParam( "Host",			&mHost );
	mParams->addParam( "Port",			&mPort,							"min=0 max=65535 step=1 keyDecr=p keyIncr=P" );
	mParams->addButton( "Write", bind(	&WebClientApp::write, this ),	"key=w" );
	mParams->addButton( "Quit", bind(	&WebClientApp::quit, this ),	"key=q" );
	
	mClient = TcpClient::create( io_service() );
	mClient->connectConnectEventHandler( &WebClientApp::onConnect, this );
	mClient->connectErrorEventHandler( &WebClientApp::onError, this );
	mClient->connectResolveEventHandler( &WebClientApp::onResolve, this );
}
void HttpClientApp::setup()
{
	gl::enable( GL_TEXTURE_2D );
	
	mBytesRead		= 0;
	mContentLength	= 0;
	mFont			= Font( "Georgia", 24 );
	mFrameRate		= 0.0f;
	mFullScreen		= false;
	mHost			= "127.0.0.1";
	mIndex			= 0;
	
	mHttpRequest = HttpRequest( "GET", "/", HttpVersion::HTTP_1_1 );
	mHttpRequest.setHeader( "Host",			mHost );
	mHttpRequest.setHeader( "Accept",		"*/*" );

	mParams = params::InterfaceGl::create( "Params", ivec2( 200, 150 ) );
	mParams->addParam( "Frame rate",	&mFrameRate,			"", true );
	mParams->addParam( "Full screen",	&mFullScreen ).key( "f" );
	mParams->addParam( "Image index",	&mIndex,				"min=0 max=3 step=1 keyDecr=i keyIncr=I" );
	mParams->addParam( "Host",			&mHost );
	mParams->addButton( "Write",		[ & ]() { write(); },	"key=w" );
	mParams->addButton( "Quit",			[ & ]() { quit(); },	"key=q" );
	
	mClient = TcpClient::create( io_service() );
	mClient->connectConnectEventHandler( &HttpClientApp::onConnect, this );
	mClient->connectErrorEventHandler( &HttpClientApp::onError, this );
	mClient->connectResolveEventHandler( &HttpClientApp::onResolve, this );
}
void TcpClientApp::setup()
{	
	gl::enableAlphaBlending();
	gl::enable( GL_TEXTURE_2D );
	
	mFont		= Font( "Georgia", 24 );
	mFrameRate	= 0.0f;
	mFullScreen	= false;
	mHost		= "localhost";
	mPort		= 2000;
	mRequest	= "echo";
		
	mParams = params::InterfaceGl::create( "Params", Vec2i( 200, 150 ) );
	mParams->addParam( "Frame rate",	&mFrameRate,					"", true );
	mParams->addParam( "Full screen",	&mFullScreen,					"key=f" );
	mParams->addParam( "Host",			&mHost );
	mParams->addParam( "Port",			&mPort,
					  "min=0 max=65535 step=1 keyDecr=p keyIncr=P" );
	mParams->addParam( "Request",		&mRequest );
	mParams->addButton( "Write", bind(	&TcpClientApp::write, this ),	"key=w" );
	mParams->addButton( "Quit", bind(	&TcpClientApp::quit, this ),	"key=q" );
	
	// Initialize a client by passing a boost::asio::io_service to it.
	// ci::App already has one that it polls on update, so we'll use that.
	// You can use your own io_service, but you will have to manage it 
	// manually (i.e., call poll(), poll_one(), run(), etc).
	mClient = TcpClient::create( io_service() );

	// Add callbacks to work with the client asynchronously.
	// Note that you can use lambdas.
	mClient->connectConnectEventHandler( &TcpClientApp::onConnect, this );
	mClient->connectErrorEventHandler( &TcpClientApp::onError, this );
	mClient->connectResolveEventHandler( [ & ]()
	{
		mText.push_back( "Endpoint resolved" );
	} );
}