fix android build + proxy work

This commit is contained in:
Benjamin Sergeant 2019-11-16 06:51:53 -08:00
parent 6e9f27d63c
commit 16c6f08e2d
7 changed files with 138 additions and 114 deletions

View File

@ -107,7 +107,7 @@ elseif (WIN32)
list( APPEND IXWEBSOCKET_SOURCES ixwebsocket/windows/IXSetThreadName_windows.cpp)
elseif (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
list( APPEND IXWEBSOCKET_SOURCES ixwebsocket/freebsd/IXSetThreadName_freebsd.cpp)
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
else()
list( APPEND IXWEBSOCKET_SOURCES ixwebsocket/linux/IXSetThreadName_linux.cpp)
list( APPEND IXWEBSOCKET_SOURCES ixwebsocket/IXSelectInterruptEventFd.cpp)
list( APPEND IXWEBSOCKET_HEADERS ixwebsocket/IXSelectInterruptEventFd.h)

View File

@ -1 +1 @@
7.3.0
7.3.1

View File

@ -6,4 +6,4 @@
#pragma once
#define IX_WEBSOCKET_VERSION "7.3.0"
#define IX_WEBSOCKET_VERSION "7.3.1"

View File

@ -8,9 +8,8 @@
#include "catch.hpp"
#include <iostream>
#include <string.h>
#include <ixsentry/IXSentryClient.h>
#include <string.h>
using namespace ix;
@ -21,7 +20,9 @@ namespace ix
SECTION("Attempt to index nil")
{
SentryClient sentryClient("");
std::string stack = "Attempt to index nil[overlay]!\nstack traceback:\n\tfoo.lua:2661: in function 'getFoo'\n\tfoo.lua:1666: in function 'onUpdate'\n\tfoo.lua:1751: in function <foo.lua:1728>";
std::string stack = "Attempt to index nil[overlay]!\nstack traceback:\n\tfoo.lua:2661: "
"in function 'getFoo'\n\tfoo.lua:1666: in function "
"'onUpdate'\n\tfoo.lua:1751: in function <foo.lua:1728>";
auto frames = sentryClient.parseLuaStackTrace(stack);
REQUIRE(frames.size() == 3);
@ -30,7 +31,8 @@ namespace ix
SECTION("Attempt to perform nil")
{
SentryClient sentryClient("");
std::string stack = "Attempt to perform nil - 1572111278.299\nstack traceback:\n\tfoo.lua:57: in function <foo.lua:53>";
std::string stack = "Attempt to perform nil - 1572111278.299\nstack "
"traceback:\n\tfoo.lua:57: in function <foo.lua:53>";
auto frames = sentryClient.parseLuaStackTrace(stack);
REQUIRE(frames.size() == 1);

View File

@ -128,13 +128,11 @@ namespace ix
{
spdlog::info("Subscriber authenticated");
conn.subscribe(channel,
conn.subscribe(
channel,
filter,
[&msgPerSeconds,
&msgCount,
&conditionVariableMutex,
&condition,
&queue](const Json::Value& msg) {
[&msgPerSeconds, &msgCount, &conditionVariableMutex, &condition, &queue](
const Json::Value& msg) {
{
std::unique_lock<std::mutex> lock(conditionVariableMutex);
queue.push(msg);

View File

@ -4,12 +4,12 @@
* Copyright (c) 2019 Machine Zone, Inc. All rights reserved.
*/
#include <ixsentry/IXSentryClient.h>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <iostream>
#include <ixcobra/IXCobraConnection.h>
#include <ixsentry/IXSentryClient.h>
#include <mutex>
#include <queue>
#include <spdlog/spdlog.h>

View File

@ -13,13 +13,29 @@ namespace ix
class ProxyConnectionState : public ix::ConnectionState
{
public:
ProxyConnectionState()
: _connected(false)
{
}
ix::WebSocket& webSocket()
{
return _serverWebSocket;
}
bool isConnected()
{
return _connected;
}
void setConnected()
{
_connected = true;
}
private:
ix::WebSocket _serverWebSocket;
bool _connected;
};
int ws_proxy_server_main(int port,
@ -38,14 +54,14 @@ namespace ix
};
server.setConnectionStateFactory(factory);
server.setOnConnectionCallback(
[remoteUrl, verbose](std::shared_ptr<ix::WebSocket> webSocket,
server.setOnConnectionCallback([remoteUrl,
verbose](std::shared_ptr<ix::WebSocket> webSocket,
std::shared_ptr<ConnectionState> connectionState) {
auto state = std::dynamic_pointer_cast<ProxyConnectionState>(connectionState);
// Server connection
state->webSocket().setOnMessageCallback(
[webSocket, state, verbose](const WebSocketMessagePtr& msg) {
state->webSocket().setOnMessageCallback([webSocket, state, verbose](
const WebSocketMessagePtr& msg) {
if (msg->type == ix::WebSocketMessageType::Open)
{
std::cerr << "New connection" << std::endl;
@ -56,6 +72,7 @@ namespace ix
{
std::cerr << it.first << ": " << it.second << std::endl;
}
state->setConnected();
}
else if (msg->type == ix::WebSocketMessageType::Close)
{
@ -86,8 +103,8 @@ namespace ix
});
// Client connection
webSocket->setOnMessageCallback(
[state, remoteUrl, verbose](const WebSocketMessagePtr& msg) {
webSocket->setOnMessageCallback([state, remoteUrl, verbose](
const WebSocketMessagePtr& msg) {
if (msg->type == ix::WebSocketMessageType::Open)
{
std::cerr << "New connection" << std::endl;
@ -104,6 +121,13 @@ namespace ix
url += msg->openInfo.uri;
state->webSocket().setUrl(url);
state->webSocket().start();
// we should sleep here for a bit until we've established the
// connection with the remote server
while (!state->isConnected())
{
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
}
else if (msg->type == ix::WebSocketMessageType::Close)
{