[58] | 1 | /* -*-c++-*- osgVisual - Copyright (C) 2009-2010 Torben Dannhauer |
---|
| 2 | * |
---|
| 3 | * This library is based on OpenSceneGraph, open source and may be redistributed and/or modified under |
---|
| 4 | * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or |
---|
| 5 | * (at your option) any later version. The full license is in LICENSE file |
---|
| 6 | * included with this distribution, and on the openscenegraph.org website. |
---|
| 7 | * |
---|
| 8 | * osgVisual requires for some proprietary modules a license from the correspondig manufacturer. |
---|
| 9 | * You have to aquire licenses for all used proprietary modules. |
---|
| 10 | * |
---|
| 11 | * This library is distributed in the hope that it will be useful, |
---|
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 14 | * OpenSceneGraph Public License for more details. |
---|
| 15 | */ |
---|
| 16 | |
---|
[62] | 17 | #include "dataIO_clusterAsioTcpIostream.h" |
---|
[58] | 18 | |
---|
| 19 | using namespace osgVisual; |
---|
| 20 | |
---|
[62] | 21 | using boost::asio::ip::tcp; |
---|
| 22 | |
---|
| 23 | dataIO_clusterAsioTcpIostream::dataIO_clusterAsioTcpIostream() |
---|
[58] | 24 | { |
---|
[62] | 25 | OSG_NOTIFY(osg::ALWAYS) << "dataIO_clusterAsioTcpIostream constructed" << std::endl; |
---|
| 26 | |
---|
| 27 | port = 5678; |
---|
| 28 | initialized = false; |
---|
[58] | 29 | } |
---|
| 30 | |
---|
[62] | 31 | dataIO_clusterAsioTcpIostream::~dataIO_clusterAsioTcpIostream() |
---|
[58] | 32 | { |
---|
[62] | 33 | OSG_NOTIFY(osg::ALWAYS) << "dataIO_clusterAsioTcpIostream destructed" << std::endl; |
---|
[58] | 34 | } |
---|
| 35 | |
---|
[59] | 36 | void dataIO_clusterAsioTcpIostream::init( osg::ArgumentParser& arguments_, clustermode clusterMode_, osgVisual::dataIO_transportContainer* sendContainer_, bool compressionEnabled_, bool asAscii_ ) |
---|
[58] | 37 | { |
---|
[62] | 38 | OSG_NOTIFY(osg::ALWAYS) << "dataIO_clusterAsioTcpIostream initialized" << std::endl; |
---|
| 39 | |
---|
| 40 | clusterMode = clusterMode_; |
---|
| 41 | |
---|
| 42 | if(clusterMode == osgVisual::dataIO_cluster::MASTER) |
---|
| 43 | { |
---|
| 44 | |
---|
| 45 | |
---|
| 46 | tcp::endpoint endpoint(tcp::v4(), port); |
---|
| 47 | tcp::acceptor acceptor(io_service, endpoint); |
---|
| 48 | |
---|
| 49 | tcp::iostream stream; |
---|
| 50 | |
---|
| 51 | acceptor.accept(*stream.rdbuf()); |
---|
| 52 | tcp::no_delay option(true); |
---|
| 53 | boost::system::error_code ec; |
---|
| 54 | stream.rdbuf()->set_option(option, ec); |
---|
| 55 | if (ec) |
---|
| 56 | { |
---|
| 57 | OSG_NOTIFY(osg::WARN) << "Error: Unable to set TCP_NODELAY option" << ec << std::endl; |
---|
| 58 | // An error occurred. |
---|
| 59 | } |
---|
| 60 | } |
---|
| 61 | |
---|
| 62 | if(clusterMode == osgVisual::dataIO_cluster::SLAVE) |
---|
| 63 | { |
---|
| 64 | |
---|
| 65 | } |
---|
| 66 | |
---|
| 67 | initialized = true; |
---|
[58] | 68 | } |
---|
| 69 | |
---|
| 70 | void dataIO_clusterAsioTcpIostream::shutdown() |
---|
| 71 | { |
---|
[62] | 72 | OSG_NOTIFY(osg::ALWAYS) << "dataIO_clusterAsioTcpIostream shut down" << std::endl; |
---|
| 73 | |
---|
| 74 | if(initialized) |
---|
| 75 | { |
---|
| 76 | |
---|
| 77 | } |
---|
[58] | 78 | } |
---|
| 79 | |
---|
| 80 | bool dataIO_clusterAsioTcpIostream::sendTO_OBJvaluesToSlaves() |
---|
| 81 | { |
---|
[62] | 82 | OSG_NOTIFY(osg::INFO) << "dataIO_clusterAsioTcpIostream::sendTO_OBJvaluesToSlaves()" << std::endl; |
---|
| 83 | |
---|
[58] | 84 | return true; |
---|
| 85 | } |
---|
| 86 | |
---|
| 87 | bool dataIO_clusterAsioTcpIostream::readTO_OBJvaluesFromMaster() |
---|
| 88 | { |
---|
[62] | 89 | OSG_NOTIFY(osg::INFO) << "dataIO_clusterAsioTcpIostream::readTO_OBJvaluesFromMaster()" << std::endl; |
---|
[58] | 90 | |
---|
| 91 | return true; |
---|
| 92 | } |
---|
| 93 | |
---|
| 94 | void dataIO_clusterAsioTcpIostream::reportAsReadyToSwap() |
---|
| 95 | { |
---|
[62] | 96 | OSG_NOTIFY(osg::INFO) << "dataIO_clusterAsioTcpIostream::reportAsReadyToSwap()" << std::endl; |
---|
[58] | 97 | } |
---|
| 98 | |
---|
| 99 | bool dataIO_clusterAsioTcpIostream::waitForSwap() |
---|
| 100 | { |
---|
[62] | 101 | OSG_NOTIFY(osg::INFO) << "dataIO_clusterAsioTcpIostream::waitForAllReadyToSwap()" << std::endl; |
---|
| 102 | |
---|
[58] | 103 | return true; |
---|
| 104 | } |
---|
| 105 | |
---|
| 106 | bool dataIO_clusterAsioTcpIostream::waitForAllReadyToSwap() |
---|
| 107 | { |
---|
[62] | 108 | OSG_NOTIFY(osg::INFO) << "dataIO_clusterAsioTcpIostream::waitForAllReadyToSwap()" << std::endl; |
---|
| 109 | |
---|
[58] | 110 | return true; |
---|
| 111 | } |
---|
| 112 | |
---|
| 113 | bool dataIO_clusterAsioTcpIostream::sendSwapCommand() |
---|
| 114 | { |
---|
[62] | 115 | OSG_NOTIFY(osg::INFO) << "dataIO_clusterAsioTcpIostream::sendSwapCommand()" << std::endl; |
---|
| 116 | |
---|
[58] | 117 | return true; |
---|
| 118 | } |
---|