diff --git a/jenkins/create_build.sh b/jenkins/create_build.sh index 50a4896..2fa4f16 100755 --- a/jenkins/create_build.sh +++ b/jenkins/create_build.sh @@ -58,7 +58,7 @@ function compile_native() { [[ ! -z "$traroot_library" ]] && _arguments="${_arguments} -DLIBRARY_PATH=\"$traroot_library\"" local _generator="" - [[ ${build_os_type} == "win32" ]] && _generator='-G"Visual Studio 15 2017 Win64"' + [[ ${build_os_type} == "win32" ]] && _generator='-G"Visual Studio 16 2019"' _command="cmake ../../ ${_generator} -DCMAKE_BUILD_TYPE=RelWithDebInfo ${_arguments}" echo "Executing cmake command $_command" @@ -117,8 +117,8 @@ function deploy_client() { end_task "${project_name}_package" "Client successfully deployed!" } -install_npm -compile_scripts +#install_npm +#compile_scripts compile_native package_client deploy_client diff --git a/native/CMakeLists.txt b/native/CMakeLists.txt index 6dda7ce..6484066 100644 --- a/native/CMakeLists.txt +++ b/native/CMakeLists.txt @@ -110,6 +110,7 @@ if (MSVC) foreach(CompilerFlag ${CompilerFlags}) string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}") endforeach() + add_compile_options("/MTd") add_compile_options("/EHsc") #We require exception handling else() #This is a bad thing here! diff --git a/native/crash_handler/binding.cc b/native/crash_handler/binding.cc index c559015..00b3c1f 100644 --- a/native/crash_handler/binding.cc +++ b/native/crash_handler/binding.cc @@ -44,9 +44,6 @@ NAN_METHOD(finalize) { tc::signal::finalize(); } -#include -namespace fs = std::experimental::filesystem; - NAN_METHOD(crash) { std::thread([] { while (true) { diff --git a/native/crash_handler/src/crash_handler.cpp b/native/crash_handler/src/crash_handler.cpp index e4d2cb9..317d035 100644 --- a/native/crash_handler/src/crash_handler.cpp +++ b/native/crash_handler/src/crash_handler.cpp @@ -2,11 +2,14 @@ #ifdef WIN32 #include + #include + namespace fs = std::filesystem; #else #include + #include + namespace fs = std::experimental::filesystem; #endif -#include #include #include #include "base64.h" @@ -14,7 +17,6 @@ using namespace std; using namespace tc; using namespace tc::signal; -namespace fs = std::experimental::filesystem; #ifndef WIN32 unique_ptr global_crash_handler; diff --git a/native/crash_handler/src/crash_handler.h b/native/crash_handler/src/crash_handler.h index eb0ae8a..e8701bd 100644 --- a/native/crash_handler/src/crash_handler.h +++ b/native/crash_handler/src/crash_handler.h @@ -1,6 +1,5 @@ #pragma once - #include #include diff --git a/native/crash_handler/src/win_crash_generator.cpp b/native/crash_handler/src/win_crash_generator.cpp index 19b8974..fb9501c 100644 --- a/native/crash_handler/src/win_crash_generator.cpp +++ b/native/crash_handler/src/win_crash_generator.cpp @@ -4,10 +4,14 @@ #include #include #include -#include -#include -namespace fs = std::experimental::filesystem; +#ifdef WIN32 + #include + namespace fs = std::filesystem; +#else + #include + namespace fs = std::experimental::filesystem; +#endif using namespace std; extern void win_crash_callback(const fs::path& source_file, const std::string& error, bool success); diff --git a/native/dist/ext_nan/include/NanStrings.h b/native/dist/ext_nan/include/NanStrings.h index 820571d..96c3a78 100644 --- a/native/dist/ext_nan/include/NanStrings.h +++ b/native/dist/ext_nan/include/NanStrings.h @@ -9,7 +9,7 @@ namespace Nan { inline v8::Local LocalStringUTF8(std::string_view buffer) { auto isolate = Nan::GetCurrentContext()->GetIsolate(); v8::EscapableHandleScope scope{isolate}; - auto data = v8::String::NewFromUtf8(isolate, buffer.data(), v8::NewStringType::kNormal, buffer.length()); + auto data = v8::String::NewFromUtf8(isolate, buffer.data(), v8::NewStringType::kNormal, (int) buffer.length()); v8::Local response{}; if(!data.ToLocal(&response)) @@ -34,7 +34,7 @@ namespace Nan { inline v8::Local LocalString(std::string_view buffer) { auto isolate = Nan::GetCurrentContext()->GetIsolate(); //v8::EscapableHandleScope scope{isolate}; - auto data = v8::String::NewFromOneByte(isolate, (uint8_t*) buffer.data(), v8::NewStringType::kNormal, buffer.length()); + auto data = v8::String::NewFromOneByte(isolate, (uint8_t*) buffer.data(), v8::NewStringType::kNormal, (int) buffer.length()); v8::Local response{}; if(!data.ToLocal(&response)) @@ -60,7 +60,7 @@ namespace Nan { inline v8::Local LocalString(std::wstring_view buffer) { auto isolate = Nan::GetCurrentContext()->GetIsolate(); v8::EscapableHandleScope scope{isolate}; - auto data = v8::String::NewFromTwoByte(isolate, (uint16_t*) buffer.data(), v8::NewStringType::kNormal, buffer.length()); + auto data = v8::String::NewFromTwoByte(isolate, (uint16_t*) buffer.data(), v8::NewStringType::kNormal, (int) buffer.length()); v8::Local response{}; if(!data.ToLocal(&response)) diff --git a/native/dist/ext_nan/test/main.cpp b/native/dist/ext_nan/test/main.cpp index ac7e70c..de7aecd 100644 --- a/native/dist/ext_nan/test/main.cpp +++ b/native/dist/ext_nan/test/main.cpp @@ -4,5 +4,5 @@ #include "include/NanGet.h" int main() { - auto str = Nan::StringUTF8("Hello World"); + auto str = Nan::StringUTF8("Hello World"); } \ No newline at end of file diff --git a/native/serverconnection/src/EventLoop.h b/native/serverconnection/src/EventLoop.h index d249891..598a0b9 100644 --- a/native/serverconnection/src/EventLoop.h +++ b/native/serverconnection/src/EventLoop.h @@ -21,10 +21,11 @@ namespace tc { return std::unique_lock(this->_execute_mutex); else { auto lock = std::unique_lock(this->_execute_mutex, std::defer_lock); - if(this->execute_lock_timeout.count() > 0) - lock.try_lock_for(this->execute_lock_timeout); - else - lock.try_lock(); + if(this->execute_lock_timeout.count() > 0) { + (void) lock.try_lock_for(this->execute_lock_timeout); + } else { + (void) lock.try_lock(); + } return lock; } } diff --git a/native/serverconnection/src/connection/Socket.cpp b/native/serverconnection/src/connection/Socket.cpp index 1629631..0738d77 100644 --- a/native/serverconnection/src/connection/Socket.cpp +++ b/native/serverconnection/src/connection/Socket.cpp @@ -30,14 +30,14 @@ bool UDPSocket::initialize() { if(this->file_descriptor > 0) return false; - this->file_descriptor = socket(this->_remote_address.ss_family, SOCK_DGRAM | SOCK_NONBLOCK, 0); + this->file_descriptor = (int) socket(this->_remote_address.ss_family, SOCK_DGRAM | SOCK_NONBLOCK, 0); if(this->file_descriptor < 2) { this->file_descriptor = 0; return false; } #ifdef WIN32 - u_long enabled = 0; + u_long enabled = 1; auto non_block_rs = ioctlsocket(this->file_descriptor, FIONBIO, &enabled); if (non_block_rs != NO_ERROR) { log_warn(category::connection, tr("Failed to enable noblock!")); @@ -130,8 +130,9 @@ void UDPSocket::_io_execute(void *_ptr_socket) { void UDPSocket::io_execute() { while(this->io_base) { - event_base_loop(this->io_base, 0); + event_base_loop(this->io_base, EVLOOP_NO_EXIT_ON_EMPTY); } + logger::trace(category::socket, tr("Socket IO loop exited")); } void UDPSocket::callback_read(evutil_socket_t fd) { sockaddr source_address{}; @@ -144,7 +145,7 @@ void UDPSocket::callback_read(evutil_socket_t fd) { size_t read_count = 0; while(true) { //TODO: Some kind of timeout source_address_length = sizeof(sockaddr); - read_length = recvfrom(fd, (char*) buffer, buffer_length, MSG_DONTWAIT, &source_address, &source_address_length); + read_length = recvfrom(fd, (char*) buffer, (int) buffer_length, MSG_DONTWAIT, &source_address, &source_address_length); if(read_length <= 0) { if(errno == EAGAIN) break; @@ -153,6 +154,7 @@ void UDPSocket::callback_read(evutil_socket_t fd) { break; /* this should never happen! */ } + //logger::trace(category::socket, tr("Read {} bytes"), read_length); read_count++; if(this->on_data) this->on_data(pipes::buffer_view{buffer, (size_t) read_length}); @@ -168,7 +170,7 @@ void UDPSocket::callback_write(evutil_socket_t fd) { this->write_queue.pop_front(); lock.unlock(); - auto written = sendto(fd, buffer.data_ptr(), buffer.length(), MSG_DONTWAIT, (sockaddr*) &this->_remote_address, sizeof(this->_remote_address)); + auto written = sendto(fd, buffer.data_ptr(), (int) buffer.length(), MSG_DONTWAIT, (sockaddr*) &this->_remote_address, sizeof(this->_remote_address)); if(written != buffer.length()) { if(errno == EAGAIN) { lock.lock(); @@ -179,7 +181,9 @@ void UDPSocket::callback_write(evutil_socket_t fd) { } return; /* this should never happen! */ - } + } else { + //logger::trace(category::socket, tr("Wrote {} bytes"), buffer.length()); + } lock.lock(); if(!this->write_queue.empty() && this->event_write) @@ -191,6 +195,9 @@ void UDPSocket::send_message(const pipes::buffer_view &buffer) { unique_lock lock(this->io_lock); this->write_queue.push_back(buf); - if(this->event_write) - event_add(this->event_write, nullptr); + if(this->event_write) { + event_add(this->event_write, nullptr); + } else { + logger::warn(category::socket, tr("Dropping write event schedule because we have no write event.")); + } } \ No newline at end of file diff --git a/native/serverconnection/src/connection/audio/AudioSender.cpp b/native/serverconnection/src/connection/audio/AudioSender.cpp index 1ba2230..8361e0b 100644 --- a/native/serverconnection/src/connection/audio/AudioSender.cpp +++ b/native/serverconnection/src/connection/audio/AudioSender.cpp @@ -14,7 +14,7 @@ using namespace tc::connection; VoiceSender::VoiceSender(tc::connection::VoiceConnection *handle) : handle(handle) {} VoiceSender::~VoiceSender() { - audio::encode_event_loop->cancel(static_pointer_cast(this->_ref.lock())); + audio::encode_event_loop->cancel(dynamic_pointer_cast(this->_ref.lock())); this->clear_buffer(); /* buffer might be accessed within encode_raw_frame, but this could not be trigered while this will be deallocated! */ } @@ -81,7 +81,7 @@ void VoiceSender::send_data(const void *data, size_t samples, size_t rate, size_ this->raw_audio_buffers.push_back(move(frame)); } - audio::encode_event_loop->schedule(static_pointer_cast(this->_ref.lock())); + audio::encode_event_loop->schedule(dynamic_pointer_cast(this->_ref.lock())); } void VoiceSender::send_stop() { @@ -104,7 +104,7 @@ void VoiceSender::send_stop() { this->raw_audio_buffers.push_back(move(frame)); } - audio::encode_event_loop->schedule(static_pointer_cast(this->_ref.lock())); + audio::encode_event_loop->schedule(dynamic_pointer_cast(this->_ref.lock())); } void VoiceSender::finalize() { @@ -137,7 +137,7 @@ void VoiceSender::event_execute(const std::chrono::system_clock::time_point &poi if(reschedule) { log_warn(category::voice_connection, tr("Audio data decode will take longer than {} us. Enqueueing for later"), chrono::duration_cast(max_time).count()); - audio::decode_event_loop->schedule(static_pointer_cast(this->_ref.lock())); + audio::decode_event_loop->schedule(dynamic_pointer_cast(this->_ref.lock())); } } diff --git a/native/serverconnection/src/connection/audio/VoiceClient.cpp b/native/serverconnection/src/connection/audio/VoiceClient.cpp index cf793c8..69cc1d3 100644 --- a/native/serverconnection/src/connection/audio/VoiceClient.cpp +++ b/native/serverconnection/src/connection/audio/VoiceClient.cpp @@ -227,7 +227,7 @@ VoiceClient::VoiceClient(const std::shared_ptr&, uint16_t clien this->set_state(state::buffering); } - audio::decode_event_loop->schedule(static_pointer_cast(this->ref())); + audio::decode_event_loop->schedule(dynamic_pointer_cast(this->ref())); } } @@ -368,7 +368,7 @@ void VoiceClient::process_packet(uint16_t packet_id, const pipes::buffer_view& b codec_data.process_pending = true; } - audio::decode_event_loop->schedule(static_pointer_cast(this->ref())); + audio::decode_event_loop->schedule(dynamic_pointer_cast(this->ref())); } void VoiceClient::cancel_replay() { @@ -376,7 +376,7 @@ void VoiceClient::cancel_replay() { this->output_source->clear(); this->set_state(state::stopped); - audio::decode_event_loop->cancel(static_pointer_cast(this->ref())); + audio::decode_event_loop->cancel(dynamic_pointer_cast(this->ref())); auto execute_lock = this->execute_lock(true); for(auto& codec : this->codec) { @@ -549,7 +549,7 @@ void VoiceClient::event_execute(const std::chrono::system_clock::time_point &sch if(reschedule) { log_warn(category::voice_connection, tr("Audio data decode will take longer than {} us. Enqueueing for later"), chrono::duration_cast(max_time).count()); - audio::decode_event_loop->schedule(static_pointer_cast(this->ref())); + audio::decode_event_loop->schedule(dynamic_pointer_cast(this->ref())); } } diff --git a/native/serverconnection/src/connection/ft/FileTransferObject.cpp b/native/serverconnection/src/connection/ft/FileTransferObject.cpp index 2923ea9..0f954cd 100644 --- a/native/serverconnection/src/connection/ft/FileTransferObject.cpp +++ b/native/serverconnection/src/connection/ft/FileTransferObject.cpp @@ -2,9 +2,14 @@ #include "../../logger.h" #include -#include +#ifdef WIN32 + #include + namespace fs = std::filesystem; +#else + #include + namespace fs = std::experimental::filesystem; +#endif -namespace fs = std::experimental::filesystem; using namespace tc; using namespace tc::ft; using namespace std; diff --git a/native/updater/file.cpp b/native/updater/file.cpp index 83a3663..327503f 100644 --- a/native/updater/file.cpp +++ b/native/updater/file.cpp @@ -7,12 +7,14 @@ #endif using namespace std; -#define EXPERIMENTAL_FS +#ifndef WIN32 + #define EXPERIMENTAL_FS +#endif + #ifdef EXPERIMENTAL_FS #include -#include - -namespace fs = std::experimental::filesystem; + #include + namespace fs = std::experimental::filesystem; #else #include namespace fs = std::filesystem; diff --git a/package.json b/package.json index 2f9fb15..b5b9b90 100644 --- a/package.json +++ b/package.json @@ -37,9 +37,14 @@ "asar": "^2.0.1", "cmake-js": "^4.0.1", "ejs": "^2.7.1", + "electron-installer-windows": "^1.1.1", "electron-packager": "8.7.2", + "electron-winstaller": "^2.7.0", + "electron-wix-msi": "^2.2.0", "nodemon": "^1.19.4", "platform-dependent-modules": "0.0.14", + "rc": "^1.2.8", + "rcedit": "^1.1.2", "sass": "^1.23.2", "typescript": "^3.7.2" }, @@ -52,11 +57,8 @@ "aws-sign2": "^0.7.0", "aws4": "^1.8.0", "electron": "7.1.2", - "electron-installer-windows": "^1.1.1", "electron-navigation": "^1.5.8", "electron-rebuild": "^1.8.6", - "electron-winstaller": "^2.7.0", - "electron-wix-msi": "^2.2.0", "extend": "^3.0.2", "extsprintf": "^1.4.0", "fs-extra": "^8.1.0", @@ -70,8 +72,6 @@ "only": "0.0.2", "psl": "^1.4.0", "pure-uuid": "^1.5.7", - "rc": "^1.2.8", - "rcedit": "^1.1.2", "request": "^2.47.1", "request-progress": "^3.0.0", "request-promise": "^4.2.5",