Skip to content

Commit

Permalink
updated client
Browse files Browse the repository at this point in the history
  • Loading branch information
smasherprog committed Oct 25, 2017
1 parent 5b2f03c commit 587afc4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
13 changes: 7 additions & 6 deletions src/server/Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ namespace RAT_Server {
RAT_Lite::Server_Status Status_ = RAT_Lite::Server_Status::SERVER_STOPPED;
std::shared_mutex ClientsLock;
std::vector<std::shared_ptr<Client>> Clients;
std::vector<Screen_Capture::Monitor> AllMonitors;

RAT_Lite::ClipboardSharing ShareClip = RAT_Lite::ClipboardSharing::NOT_SHARED;
int ImageCompressionSettingRequested = 70;
Expand All @@ -55,15 +56,15 @@ namespace RAT_Server {

ScreenCaptureManager_ =
Screen_Capture::CreateCaptureConfiguration([&]() {
auto monitors = Screen_Capture::GetMonitors();
AllMonitors = Screen_Capture::GetMonitors();
if (!IServerDriver_)
return monitors;
SendtoAll(IServerDriver_->PrepareMonitorsChanged(monitors));
return AllMonitors;
SendtoAll(IServerDriver_->PrepareMonitorsChanged(AllMonitors));
// add everyone to the list!

std::unique_lock<std::shared_mutex> lock(ClientsLock);
onGetMonitors(Clients, monitors);
return monitors;
onGetMonitors(Clients, AllMonitors);
return AllMonitors;
})
->onNewFrame([&](const SL::Screen_Capture::Image &img, const SL::Screen_Capture::Monitor &monitor) {
if (!IServerDriver_)
Expand Down Expand Up @@ -240,7 +241,7 @@ namespace RAT_Server {
[&](const std::string &text) { onClipboardChanged(ShareClip == RAT_Lite::ClipboardSharing::SHARED, text, Clipboard_); })
->onClientSettingsChanged([&](const std::shared_ptr<WS_LITE::IWSocket> &socket, const RAT_Lite::ClientSettings &clientsettings) {
std::unique_lock<std::shared_mutex> lock(ClientsLock);
onClientSettingsChanged(socket.get(), Clients, clientsettings);
onClientSettingsChanged(socket.get(), Clients, AllMonitors, clientsettings);
})
->Build(clientctx);
clientctx->listen();
Expand Down
7 changes: 3 additions & 4 deletions src/server/ServerFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ namespace RAT_Server {
return imagecompressionactual;
}
void onClientSettingsChanged(WS_LITE::IWSocket *socket, std::vector<std::shared_ptr<Client>> &clients,
const RAT_Lite::ClientSettings &clientsettings)
const std::vector<Screen_Capture::Monitor> &monitors, const RAT_Lite::ClientSettings &clientsettings)
{
auto found = std::find_if(std::begin(clients), std::end(clients), [socket](const auto &client) { return client->Socket.get() == socket; });
if (found != std::end(clients)) {
Expand All @@ -60,9 +60,8 @@ namespace RAT_Server {
}
(*found)->ShareClip = clientsettings.ShareClip;
for (auto &m : clientsettings.MonitorsToWatch) {
auto newmonitor = std::find_if(std::begin(clientsettings.MonitorsToWatch), std::end(clientsettings.MonitorsToWatch),
[&m](const auto &mon) { return mon.Id == m.Id; });
if (newmonitor == std::end(clientsettings.MonitorsToWatch)) {
auto newmonitor = std::find_if(std::begin(monitors), std::end(monitors), [&m](const auto &mon) { return mon.Id == m.Id; });
if (newmonitor == std::end(monitors)) {
(*found)->MonitorsNeeded.push_back(m);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/server/ServerFunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace RAT_Server {
int GetNewImageCompression(size_t memoryused, size_t maxmemoryused, int imagecompressionactual, int imagecompressionrequested);

void onClientSettingsChanged(WS_LITE::IWSocket *socket, std::vector<std::shared_ptr<Client>> &clients,
const RAT_Lite::ClientSettings &clientsettings);
const std::vector<Screen_Capture::Monitor> &monitors, const RAT_Lite::ClientSettings &clientsettings);
void onGetMonitors(std::vector<std::shared_ptr<Client>> &clients, const std::vector<Screen_Capture::Monitor> &monitors);

void onKeyUp(bool ignoreIncomingKeyboardEvents, const std::shared_ptr<WS_LITE::IWSocket> &socket, const Input_Lite::KeyCodes &keycode);
Expand Down

0 comments on commit 587afc4

Please sign in to comment.