diff options
author | Martijn Kaijser <machine.sanctum@gmail.com> | 2014-10-18 13:58:02 +0200 |
---|---|---|
committer | Martijn Kaijser <machine.sanctum@gmail.com> | 2014-10-18 13:58:02 +0200 |
commit | b3d686357d0912ce8c748bc013c93b0b6a47cd9b (patch) | |
tree | 1c50d6c49876613aba227ea3c70da4401ce924a4 /lib | |
parent | 31ce9876ffd7a4990946c0257452f68b4e92f8dc (diff) | |
parent | 25c5ffe9eb2213fc18ab498320fbf9af79e1250d (diff) |
Merge pull request #5282 from maksqwe/slingboxlib_fix
SlingboxLib: Fix alternative CSlingbox constructor
Diffstat (limited to 'lib')
-rw-r--r-- | lib/SlingboxLib/SlingboxLib.cpp | 32 | ||||
-rw-r--r-- | lib/SlingboxLib/SlingboxLib.h | 1 |
2 files changed, 20 insertions, 13 deletions
diff --git a/lib/SlingboxLib/SlingboxLib.cpp b/lib/SlingboxLib/SlingboxLib.cpp index f2d7017de1..0632e6f8e8 100644 --- a/lib/SlingboxLib/SlingboxLib.cpp +++ b/lib/SlingboxLib/SlingboxLib.cpp @@ -41,24 +41,16 @@ typedef int socklen_t; // Default constructor. CSlingbox::CSlingbox() { - // Set all variables to default/invalid values - m_socCommunication = INVALID_SOCKET; - m_socStream = INVALID_SOCKET; - memset(m_szAddress, 0, sizeof(m_szAddress)); - m_uiPort = 0; - m_usCode = 0; - m_usSequence = 0; - m_iChannel = -1; - m_iInput = -1; - memset(&m_receivedMessages, 0, sizeof(m_receivedMessages)); + // initialize all members + init(); } // Alternative constructor used to set the address (IP or hostname) and port of the -// Slingbox we want to connect to. If no port is specified default port 5001 is used. +// Slingbox we want to connect to. If no port is specified default port 5001 is used. CSlingbox::CSlingbox(const char * szAddress, unsigned int uiPort /* = 5001 */) { - // Call default constructor - CSlingbox(); + // initialize all members + init(); // Set address and port variables to passed values SetAddress(szAddress, uiPort); @@ -74,6 +66,20 @@ CSlingbox::~CSlingbox() CloseSocket(m_socCommunication); } +// Function used to initialize class members +void CSlingbox::init() +{ + // Set all variables to default/invalid values + m_socCommunication = INVALID_SOCKET; + m_socStream = INVALID_SOCKET; + memset(m_szAddress, 0, sizeof(m_szAddress)); + m_uiPort = 0; + m_usCode = 0; + m_usSequence = 0; + m_iChannel = -1; + m_iInput = -1; + memset(&m_receivedMessages, 0, sizeof(m_receivedMessages)); +} // Function used to find a Slingbox. Address and port of found Slingbox can be // retrieved with the GetAddress function afterwards. bool CSlingbox::FindSlingbox(unsigned int uiTimeout /* = 10 */) diff --git a/lib/SlingboxLib/SlingboxLib.h b/lib/SlingboxLib/SlingboxLib.h index ad368f00f1..a8835bc02b 100644 --- a/lib/SlingboxLib/SlingboxLib.h +++ b/lib/SlingboxLib/SlingboxLib.h @@ -91,6 +91,7 @@ public: bool SendIRCommand(uint8_t ucCommand); protected: + void init(); // Function used to send and receive messages to and from the Slingbox struct MessageHeader; bool SendReceiveMessage(SOCKET socSocket, MessageHeader * pHeader, |