Changeset 6822 for source/ariba/utility
- Timestamp:
- Nov 4, 2009, 11:20:00 AM (15 years ago)
- Location:
- source/ariba/utility/visual
- Files:
-
- 4 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
source/ariba/utility/visual/OvlVis.cpp
r6584 r6822 42 42 namespace utility { 43 43 44 //*****************************************************45 //*****************************************************46 //*****************************************************47 48 44 use_logging_cpp(OvlVis); 49 45 50 OvlVis::OvlVis() : socket(io_service), socketOpened(false) { 51 52 if( ! Configuration::haveConfig() ) return; 53 if( ! Configuration::instance().exists("DEMO_OvlVisIP") ) return; 54 if( ! Configuration::instance().exists("DEMO_OvlVisPort") ) return; 55 56 string serverIP = Configuration::instance().read<string>("DEMO_OvlVisIP"); 57 string serverPort = Configuration::instance().read<string>("DEMO_OvlVisPort"); 58 if( serverIP.length() == 0 || serverPort.length() == 0) return; 59 60 logging_debug( "connecting to ovlvis " + serverIP + " on " + serverPort ); 61 62 tcp::resolver resolver(io_service); 63 tcp::resolver::query query( 64 serverIP, 65 serverPort, 66 tcp::resolver::query::passive | 67 tcp::resolver::query::address_configured | 68 tcp::resolver::query::numeric_service); 69 70 tcp::resolver::iterator endpoint_iterator = resolver.resolve(query); 71 tcp::resolver::iterator end; 72 73 boost::system::error_code error = boost::asio::error::host_not_found; 74 while (error && endpoint_iterator != end){ 75 socket.close(); 76 socket.connect(*endpoint_iterator++, error); 77 } 78 79 if (error){ 80 logging_warn( "OvlVis could not connect to GUI" ); 81 } else { 82 socketOpened = true; 83 } 46 OvlVis::OvlVis() { 84 47 } 85 48 86 49 OvlVis::~OvlVis(){ 87 88 socket.close();89 90 50 } 91 51 … … 115 75 // } 116 76 117 }118 119 void OvlVis::sendSocket(const string msg){120 if( socket.is_open() && socketOpened )121 socket.send( boost::asio::buffer(msg) );122 77 } 123 78 … … 665 620 } 666 621 667 //*****************************************************668 //*****************************************************669 //*****************************************************670 671 622 }} // namespace ariba, common -
source/ariba/utility/visual/OvlVis.h
r6584 r6822 45 45 #include <map> 46 46 #include <boost/utility.hpp> 47 #include <boost/asio.hpp>48 #include "ariba/utility/types/NodeID.h"49 #include "ariba/utility/logging/Logging.h"50 47 #include "ariba/utility/system/Timer.h" 51 48 #include "ariba/utility/misc/Helper.h" 52 49 #include "ariba/utility/misc/KeyMapping.hpp" 53 #include "ariba/utility/ configuration/Configuration.h"50 #include "ariba/utility/visual/ServerVis.h" 54 51 55 52 using std::string; … … 59 56 using std::cout; 60 57 using std::ostringstream; 61 using boost::asio::ip::tcp;62 using ariba::utility::NodeID;63 using ariba::utility::Configuration;64 58 using ariba::utility::KeyMapping; 65 59 using ariba::utility::Timer; … … 68 62 namespace utility { 69 63 70 class OvlVis : p rivate boost::noncopyable {64 class OvlVis : public ServerVis, private boost::noncopyable { 71 65 use_logging_h(OvlVis); 72 66 public: 73 67 static OvlVis& instance() { static OvlVis the_inst; return the_inst; } 74 68 75 typedef enum _NETWORK_ID {76 NETWORK_ID_BASE_COMMUNICATION = 1,77 NETWORK_ID_BASE_OVERLAY = 2,78 NETWORK_ID_EONSON = 3,79 NETWORK_ID_MCPO = 4,80 NETWORK_ID_CLIO = 5,81 NETWORK_ID_VIDEOSTREAM = 6,82 NETWORK_ID_GAME = 7,83 NETWORK_ID_SECURITY = 8,84 } NETWORK_ID;85 86 69 //**************************************************************** 87 70 // Node creation, node connections, status, node deletion, ... … … 162 145 unsigned char b 163 146 ); 164 165 typedef enum _NODE_COLORS {166 NODE_COLORS_GREY,167 NODE_COLORS_GREEN,168 NODE_COLORS_RED,169 } NODE_COLORS;170 147 171 148 /** … … 385 362 protected: 386 363 OvlVis(); 387 ~OvlVis();364 virtual ~OvlVis(); 388 365 389 366 private: 390 367 void sendMessage( const string msg, NETWORK_ID nid ); 391 void sendSocket( const string msg );392 393 /**394 * boost asio stuff for connecting to ovlvis395 */396 boost::asio::io_service io_service;397 tcp::socket socket;398 volatile bool socketOpened;399 368 400 369 typedef pair<NodeID, NodeID> NodePair;
Note:
See TracChangeset
for help on using the changeset viewer.