| 26 | #include <boost/filesystem.hpp> |
| 27 | |
| 28 | bool ODSocketClient::connect(const std::string& host, const int port, uint32_t timeout, const std::string& outputReplayFilename) |
| 29 | { |
| 30 | mSource = ODSource::none; |
| 31 | |
| 32 | // As we use selector, there is no need to set the socket as not-blocking |
| 33 | sf::Socket::Status status = mSockClient.connect(host, port, sf::milliseconds(timeout)); |
| 34 | if (status != sf::Socket::Done) |
| 35 | { |
| 36 | OD_LOG_ERR("Could not connect to distant server status=" |
| 37 | + Helper::toString(status)); |
| 38 | mSockClient.disconnect(); |
| 39 | return false; |
| 40 | } |
| 41 | mSockSelector.add(mSockClient); |
| 42 | OD_LOG_INF("Connected to server successfully"); |
| 43 | |
| 44 | mOutputReplayFilename = outputReplayFilename; |
| 45 | |
| 46 | mReplayOutputStream.open(mOutputReplayFilename, std::ios::out | std::ios::binary); |
| 47 | mGameClock.restart(); |
| 48 | mSource = ODSource::network; |
| 49 | return true; |
| 50 | } |
| 51 | |
| 52 | bool ODSocketClient::replay(const std::string& filename) |
| 53 | { |
nothing calls this directly
no test coverage detected