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>2008-07-16 22:55:07 +0000
committerStijn Buys <ingar@osirion.org>2008-07-16 22:55:07 +0000
commiteb075660e7cb61b138c2da337115c59857f89e17 (patch)
tree0fe031a8f3562b22f61d0f95b740fe5f2326fd7b /src/core/netconnection.cc
parentfecc54ad8c5a108831c2bc268f9dd7e16b511b7e (diff)
network protocol cleanup, radar test (doesn't work)
Diffstat (limited to 'src/core/netconnection.cc')
-rw-r--r--src/core/netconnection.cc90
1 files changed, 72 insertions, 18 deletions
diff --git a/src/core/netconnection.cc b/src/core/netconnection.cc
index bee0843..e415518 100644
--- a/src/core/netconnection.cc
+++ b/src/core/netconnection.cc
@@ -274,23 +274,7 @@ void NetConnection::frame(float seconds)
}
}
-void NetConnection::send(std::string const &msg)
-{
- sendq.append(msg);
-}
-
-void NetConnection::send_playerinfo()
-{
- localplayer()->update_info();
-
- std::ostringstream osstream;
- osstream << "pif ";
- localplayer()->serialize_client_update(osstream);
- osstream << '\n';
- send(osstream.str());
- localplayer()->player_dirty = false;
-}
-
+// transmit all queued messages
void NetConnection::transmit()
{
@@ -328,6 +312,73 @@ void NetConnection::transmit()
connection_keepalive = application()->time();
}
+// queue a mmessage to the server
+void NetConnection::send(std::string const &msg)
+{
+ sendq.append(msg);
+}
+
+// functions for outgoing messages
+/**
+ * the following outgoing messages can be send
+ *
+ * connect <protocol version>
+ * pif <player data>
+ * cup <id> <entity data>
+ * cmd <text>
+ * say <text>
+ */
+
+// send a "connect" message to the server
+void NetConnection::send_connect()
+{
+ std::ostringstream msg;
+ msg << "connect " << PROTOCOLVERSION << "\n";
+ this->send(msg.str());
+}
+
+// send a "pif" player info message to the server
+void NetConnection::send_playerinfo()
+{
+ localplayer()->update_info();
+
+ std::ostringstream msg;
+ msg << "pif ";
+ localplayer()->serialize_client_update(msg);
+ msg << '\n';
+ this->send(msg.str());
+ localplayer()->player_dirty = false;
+}
+
+// send a "cup" client update message to the server
+void NetConnection::send_clientupdate(Entity *entity)
+{
+ // cup <id> <entity data>
+ std::ostringstream msg;
+ msg << "cup " << entity->id() << " ";
+ entity->serialize_client_update(msg);
+ msg << '\n';
+ this->send(msg.str());
+}
+
+// send a "cmd" command line message to the server
+void NetConnection::send_command(std::string const &cmdline)
+{
+ std::string msg("cmd ");
+ msg.append(cmdline);
+ msg += '\n';
+ this->send(msg);
+}
+
+// send a "say" chat message message to the server
+void NetConnection::send_say(std::string const &text)
+{
+ std::string msg("say ");
+ msg.append(text);
+ msg += '\n';
+ this->send(msg);
+}
+
// parse incoming client messages
/**
* The following incoming messages are parsed;
@@ -442,9 +493,12 @@ void NetConnection::parse_incoming_message(const std::string & message)
//con_debug << "Received update entity id " << id << std::endl;
Entity *entity = Entity::find(id);
if (!entity) {
+ // FIXME request entity from the server
con_warn << "Update for unknown entity " << id << std::endl;
- } else
+ } else {
+ // FIXME check of the received update matches the actual entity
entity->recieve_server_update(msgstream);
+ }
}
}