Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2009-01-10 16:08:02 +0000
committerStijn Buys <ingar@osirion.org>2009-01-10 16:08:02 +0000
commit67a73b90a4c0f91ddf9322cf0ecfc6c99016e384 (patch)
tree3f36be57d9c7c548172bd598b4d128c5efc2d565
parentd0d4bd189e2654b61be7740edd15d96b6cab968d (diff)
ping issues
-rw-r--r--src/core/netconnection.cc8
-rw-r--r--src/core/netconnection.h2
-rw-r--r--src/core/netserver.cc2
3 files changed, 5 insertions, 7 deletions
diff --git a/src/core/netconnection.cc b/src/core/netconnection.cc
index 267ff8f..a3a2a43 100644
--- a/src/core/netconnection.cc
+++ b/src/core/netconnection.cc
@@ -401,10 +401,10 @@ void NetConnection::send_private_message(std::string const &text)
}
// send a ping reply
-void NetConnection::send_ping_reply()
+void NetConnection::send_ping_reply(unsigned long timestamp)
{
std::ostringstream msg;
- msg << "ping " << timestamp() << '\n';
+ msg << "ping " << timestamp << '\n';
this->send_raw(msg.str());
}
@@ -476,14 +476,14 @@ void NetConnection::parse_incoming_message(const std::string & message)
} else if (command == "ping") {
unsigned long timestamp;
if ((msgstream >> timestamp)) {
-
+ send_ping_reply(timestamp);
}
} else if (command == "frame") {
unsigned long timestamp;
if ((msgstream >> timestamp)) {
+ send_ping_reply(timestamp);
connection_timestamp = timestamp;
- send_ping_reply();
}
} else if (command == "die") {
diff --git a/src/core/netconnection.h b/src/core/netconnection.h
index 371ab04..a17b35d 100644
--- a/src/core/netconnection.h
+++ b/src/core/netconnection.h
@@ -101,7 +101,7 @@ public:
protected:
/// send a ping reply
- void send_ping_reply();
+ void send_ping_reply(unsigned long timestamp);
/// add a raw network message to the send queue
void send_raw(std::string const &msg);
diff --git a/src/core/netserver.cc b/src/core/netserver.cc
index e6e85f8..0854692 100644
--- a/src/core/netserver.cc
+++ b/src/core/netserver.cc
@@ -594,8 +594,6 @@ void NetServer::parse_incoming_message(NetClient *client, const std::string & me
unsigned long timestamp;
if (msgstream >> timestamp) {
client->player()->set_ping(server()->timestamp() - timestamp);
- } else {
- client->player()->set_ping(-1);
}
return;
}