IXWebSocket/test/IXTest.h

50 lines
996 B
C
Raw Normal View History

2018-12-30 03:33:15 +01:00
/*
* IXTest.h
* Author: Benjamin Sergeant
* Copyright (c) 2018 Machine Zone. All rights reserved.
*/
#pragma once
#include <string>
#include <vector>
#include <sstream>
2019-01-08 03:04:28 +01:00
#include <iostream>
#include <mutex>
2019-05-14 02:32:57 +02:00
#include <spdlog/spdlog.h>
2018-12-30 03:33:15 +01:00
namespace ix
{
// Sleep for ms milliseconds.
void msleep(int ms);
// Generate a relatively random string
std::string generateSessionId();
// Record and report websocket traffic
void setupWebSocketTrafficTrackerCallback();
void reportWebSocketTraffic();
2019-01-08 03:04:28 +01:00
struct Logger
{
public:
template <typename T>
Logger& operator<<(T const& obj)
{
std::lock_guard<std::mutex> lock(_mutex);
2019-05-14 02:32:57 +02:00
std::stringstream ss;
ss << obj;
spdlog::info(ss.str());
2019-01-08 03:04:28 +01:00
return *this;
}
private:
static std::mutex _mutex;
};
void log(const std::string& msg);
int getFreePort();
2018-12-30 03:33:15 +01:00
}