From d6ee7ec642cc6b3097c8d321a1a00630e24027d1 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sat, 16 Feb 2008 12:22:33 +0000 Subject: initial client-to-server connection --- src/core/core.cc | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) (limited to 'src/core/core.cc') diff --git a/src/core/core.cc b/src/core/core.cc index e7aecaf..b1083a8 100644 --- a/src/core/core.cc +++ b/src/core/core.cc @@ -4,7 +4,12 @@ the terms of the GNU General Public License version 2. */ +#include +#include + #include "core/core.h" +#include "core/netclient.h" + namespace core { @@ -19,15 +24,35 @@ Application *application() return Application::instance(); } -bool connected() + +void net_broadcast(std::ostringstream &osstream, int ignoreplayer) { - return (GameInterface::instance() && GameInterface::instance()->connected); + if (!application()->netserver) + return; + + application()->netserver->broadcast(osstream, ignoreplayer); } -float time() +void net_send(Player &player, std::ostringstream &osstream) { - return Application::instance()->current_time; + if (!application()->netserver) + return; + + NetClient *client = application()->netserver->find_client(player); + if (client) + application()->netserver->send(client, osstream); } + +void net_send(Player &player, std::string message) +{ + if (!application()->netserver) + return; + + NetClient *client = application()->netserver->find_client(player); + if (client) + application()->netserver->send(client, message); } + +} -- cgit v1.2.3