Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/netconnection.cc')
-rw-r--r--src/core/netconnection.cc38
1 files changed, 25 insertions, 13 deletions
diff --git a/src/core/netconnection.cc b/src/core/netconnection.cc
index 39a25a3..2975bc5 100644
--- a/src/core/netconnection.cc
+++ b/src/core/netconnection.cc
@@ -403,6 +403,7 @@ void NetConnection::send_private_message(std::string const &text)
}
// send a ping reply
+// ping timestamp
void NetConnection::send_ping_reply(unsigned long timestamp)
{
std::ostringstream msg;
@@ -411,10 +412,11 @@ void NetConnection::send_ping_reply(unsigned long timestamp)
}
// send an info record request
+// inf type.label info.label
void NetConnection::send_info_request(Info *info)
{
std::ostringstream msg;
- msg << "inf " << '"' << info->label() << '"' << '\n';
+ msg << "inf " << ' ' << info->type()->label() << ' ' << info->label() << '\n';
this->send_raw(msg.str());
info->set_timestamp(application()->timestamp());
@@ -690,20 +692,30 @@ void NetConnection::parse_incoming_message(const std::string & message)
} else if (command == "inf") {
// incoming info record
- unsigned int id;
- if (msgstream >> id) {
-
- Info *info = Info::find(id);
- if (!info) {
- info = new Info(id);
- }
+ std::string typelabelstr;
+ std::string infolabelstr;
- info->receive_server_update(msgstream);
- info->clear_timestamp();
-
- } else {
- con_warn << "Received empty information record!" << std::endl;
+ if (!(msgstream >> typelabelstr)) {
+ con_warn << "Received invalid info record message!" << std::endl;
+ return;
}
+ InfoType *infotype = InfoType::find(typelabelstr);
+ if (!infotype) {
+ infotype = new InfoType(typelabelstr.c_str());
+ }
+
+ if (!(msgstream >> infolabelstr)) {
+ con_warn << "Received invalid info record message for type '" << typelabelstr << "'!" << std::endl;
+ return;
+ }
+ Info *info = Info::find(infotype, infolabelstr);
+ if (!info) {
+ info = new Info(infotype);
+ info->set_label(infolabelstr);
+ }
+
+ info->receive_server_update(msgstream);
+ info->clear_timestamp();
} else if (command == "sup") {