Commit 2affe0ab3e69ffc91abb78ae13c3195849332ed9

Authored by Jürgen Knödlseder
1 parent 7e89bba1

connect() and disconnect() methods do nothing if no Hub was found

src/vo/GVOClient.cpp
... ... @@ -175,11 +175,16 @@ GVOClient* GVOClient::clone(void) const
175 175 ***************************************************************************/
176 176 void GVOClient::connect(void)
177 177 {
178   - // Register to Hub
179   - register_to_hub();
  178 + // Continue only if we have a Hub
  179 + if (has_hub()) {
  180 +
  181 + // Register to Hub
  182 + register_to_hub();
  183 +
  184 + // Send meta data
  185 + send_metadata();
180 186  
181   - // Send meta data
182   - send_metadata();
  187 + } // endif: we had a Hub
183 188  
184 189 // Return
185 190 return;
... ... @@ -194,14 +199,19 @@ void GVOClient::connect(void)
194 199 ***************************************************************************/
195 200 void GVOClient::disconnect(void)
196 201 {
197   - // Unregister from Hub
198   - unregister_from_hub();
  202 + // Continue only if we have a Hub
  203 + if (has_hub()) {
199 204  
200   - // Close socket
201   - if (m_socket != -1) {
202   - close(m_socket);
203   - m_socket = -1;
204   - }
  205 + // Unregister from Hub
  206 + unregister_from_hub();
  207 +
  208 + // Close socket
  209 + if (m_socket != -1) {
  210 + close(m_socket);
  211 + m_socket = -1;
  212 + }
  213 +
  214 + } // endif: we had a Hub
205 215  
206 216 // Return
207 217 return;
... ...
test/test_GVO.cpp
1 1 /***************************************************************************
2 2 * test_GVO.hpp - Test VO module *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2013 by Juergen Knoedlseder *
  4 + * copyright (C) 2013-2015 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -69,7 +69,7 @@ void TestGVO::test_GVOClient(void)
69 69 test_try("GVOClient empty constructor");
70 70 try {
71 71 GVOClient client;
72   - std::cout << client << std::endl;
  72 + //std::cout << client << std::endl;
73 73 test_try_success();
74 74 }
75 75 catch (std::exception &e) {
... ... @@ -81,9 +81,9 @@ void TestGVO::test_GVOClient(void)
81 81 try {
82 82 GVOClient client;
83 83 client.connect();
84   - std::cout << client << std::endl;
  84 + //std::cout << client << std::endl;
85 85 client.disconnect();
86   - std::cout << client << std::endl;
  86 + //std::cout << client << std::endl;
87 87 test_try_success();
88 88 }
89 89 catch (std::exception &e) {
... ...