00001 /* 00002 Copyright (c) 2010, Dan Bethell, Johannes Saam. 00003 All rights reserved. 00004 00005 Redistribution and use in source and binary forms, with or without modification, 00006 are permitted provided that the following conditions are met: 00007 00008 * Redistributions of source code must retain the above copyright notice, 00009 this list of conditions and the following disclaimer. 00010 00011 * Redistributions in binary form must reproduce the above copyright notice, 00012 this list of conditions and the following disclaimer in the documentation 00013 and/or other materials provided with the distribution. 00014 00015 * Neither the name of RmanConnect nor the names of its contributors may be 00016 used to endorse or promote products derived from this software without 00017 specific prior written permission. 00018 00019 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 00020 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 00021 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00022 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 00023 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00024 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00025 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 00026 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00027 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00028 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00029 */ 00030 00031 #ifndef RMAN_CONNECT_CLIENT_H_ 00032 #define RMAN_CONNECT_CLIENT_H_ 00033 00034 #include "Data.h" 00035 #include <boost/asio.hpp> 00036 #include <string> 00037 00039 namespace rmanconnect 00040 { 00049 class Client 00050 { 00051 friend class Server; 00052 public: 00058 Client( std::string hostname, int port ); 00059 00061 ~Client(); 00062 00068 void openImage( Data &header ); 00069 00077 void sendPixels( Data &data ); 00078 00084 void closeImage(); 00085 00086 private: 00087 void connect( std::string host, int port ); 00088 void disconnect(); 00089 void quit(); 00090 00091 // store the port we should connect to 00092 std::string mHost; 00093 int mPort, mImageId; 00094 bool mIsConnected; 00095 00096 // tcp stuff 00097 boost::asio::io_service mIoService; 00098 boost::asio::ip::tcp::socket mSocket; 00099 }; 00100 } 00101 00102 #endif // RMAN_CONNECT_CLIENT_H_