Propagate ROT and VEL
This commit is contained in:
1 parent
ff95163bcd
commit
fbc420e894
3 files changed
+76
-31
No files matched your search
@@ -74,10 +74,12 @@ class Session : public std::enable_shared_from_this<Session> {
|
||||
state_.discreteAngle = std::stoi(parts[2]);
|
||||
state_.discreteMag = std::stof(parts[3]);
|
||||
state_.apply_lag_compensation(now_server);
|
||||
retranslateMessage(msg);
|
||||
}
|
||||
else if (parts[0] == "VEL") {
|
||||
state_.selectedVelocity = std::stoi(parts[2]);
|
||||
state_.apply_lag_compensation(now_server);
|
||||
retranslateMessage(msg);
|
||||
}
|
||||
else if (parts[0] == "PING") {
|
||||
state_.handle_full_sync(parts);
|
||||
@@ -85,7 +87,17 @@ class Session : public std::enable_shared_from_this<Session> {
|
||||
}
|
||||
}
|
||||
|
||||
void retranslateMessage(const std::string& msg)
|
||||
{
|
||||
std::string event_msg = "EVENT:" + std::to_string(id_) + ":" + msg;
|
||||
|
||||
std::lock_guard<std::mutex> lock(g_sessions_mutex);
|
||||
for (auto& session : g_sessions) {
|
||||
if (session->get_id() != id_) { // Íå øëåì îòïðàâèòåëþ
|
||||
session->send_message(event_msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public:
|
||||
@@ -141,6 +153,10 @@ public:
|
||||
ws_.async_write(net::buffer(*ss), [ss](beast::error_code, std::size_t) {});
|
||||
}
|
||||
|
||||
int get_id() const {
|
||||
return id_;
|
||||
}
|
||||
|
||||
private:
|
||||
void do_read() {
|
||||
ws_.async_read(buffer_, [self = shared_from_this()](beast::error_code ec, std::size_t) {
|
||||
|
||||
Reference in new issue
Block a user