[Orxonox-commit 2930] r7630 - in code/branches/masterserver/src: libraries/network modules/masterserver
smerkli at orxonox.net
smerkli at orxonox.net
Wed Nov 10 14:19:44 CET 2010
Author: smerkli
Date: 2010-11-10 14:19:44 +0100 (Wed, 10 Nov 2010)
New Revision: 7630
Added:
code/branches/masterserver/src/libraries/network/WANDiscovery.cc
code/branches/masterserver/src/libraries/network/WANDiscovery.h
Modified:
code/branches/masterserver/src/modules/masterserver/MasterServer.cc
code/branches/masterserver/src/modules/masterserver/MasterServerComm.cc
Log:
initiated WANDiscovery code, now implementing...
Copied: code/branches/masterserver/src/libraries/network/WANDiscovery.cc (from rev 7629, code/branches/masterserver/src/libraries/network/LANDiscovery.cc)
===================================================================
--- code/branches/masterserver/src/libraries/network/WANDiscovery.cc (rev 0)
+++ code/branches/masterserver/src/libraries/network/WANDiscovery.cc 2010-11-10 13:19:44 UTC (rev 7630)
@@ -0,0 +1,66 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Fabian 'x3n' Landau
+ * Co-authors:
+ * ...
+ *
+ */
+
+#include "WANDiscovery.h"
+
+#include <enet/enet.h>
+#include <cstring>
+
+#include "util/ScopedSingletonManager.h"
+#include "core/CoreIncludes.h"
+
+
+namespace orxonox
+{
+ ManageScopedSingleton(WANDiscovery, ScopeID::Root, true);
+
+ WANDiscovery::WANDiscovery()
+ {
+ }
+
+ WANDiscovery::~WANDiscovery()
+ {
+ }
+
+ void WANDiscovery::discover()
+ {
+ this->servers_.clear();
+ }
+
+ std::string WANDiscovery::getServerListItemName(unsigned int index)
+ {
+
+ }
+
+ std::string WANDiscovery::getServerListItemIP(unsigned int index)
+ {
+
+ }
+
+
+} // namespace orxonox
Copied: code/branches/masterserver/src/libraries/network/WANDiscovery.h (from rev 7629, code/branches/masterserver/src/libraries/network/LANDiscovery.h)
===================================================================
--- code/branches/masterserver/src/libraries/network/WANDiscovery.h (rev 0)
+++ code/branches/masterserver/src/libraries/network/WANDiscovery.h 2010-11-10 13:19:44 UTC (rev 7630)
@@ -0,0 +1,63 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Fabian 'x3n' Landau (original)
+ * Co-authors:
+ * Sandro 'smerkli' Merkli (copied and adapted to WAN)
+ *
+ */
+
+#ifndef WANDISCOVERY_H
+#define WANDISCOVERY_H
+
+#include "NetworkPrereqs.h"
+#include "packet/ServerInformation.h"
+#include "util/Singleton.h"
+
+#include <vector>
+
+// tolua_begin
+namespace orxonox
+{
+
+ class _NetworkExport WANDiscovery
+// tolua_end
+ : public Singleton<WANDiscovery>
+ { // tolua_export
+ friend class Singleton<WANDiscovery>;
+ public:
+ WANDiscovery();
+ ~WANDiscovery();
+ void discover(); // tolua_export
+ std::string getServerListItemName( unsigned int index ); // tolua_export
+ std::string getServerListItemIP( unsigned int index ); // tolua_export
+ static WANDiscovery& getInstance(){ return Singleton<WANDiscovery>::getInstance(); } // tolua_export
+
+ private:
+ static WANDiscovery* singletonPtr_s;
+ ENetHost* host_;
+ std::vector<packet::ServerInformation> servers_;
+ }; // tolua_export
+
+} // tolua_export
+
+#endif // WANDISCOVERY_H
Modified: code/branches/masterserver/src/modules/masterserver/MasterServer.cc
===================================================================
--- code/branches/masterserver/src/modules/masterserver/MasterServer.cc 2010-11-10 09:46:04 UTC (rev 7629)
+++ code/branches/masterserver/src/modules/masterserver/MasterServer.cc 2010-11-10 13:19:44 UTC (rev 7630)
@@ -115,27 +115,29 @@
<< " on channel "
<< event->channelID << "\n";
- /* send some packet back for testing */
- /* TESTING */
+ //[> send some packet back for testing <]
+ //[> TESTING <]
- /* Create a reliable reply of size 7 containing "reply\0" */
- ENetPacket * reply = enet_packet_create ("reply",
- strlen ("reply") + 1,
- ENET_PACKET_FLAG_RELIABLE);
+ //[> Create a reliable reply of size 7 containing "reply\0" <]
+ //ENetPacket * reply = enet_packet_create ("reply",
+ //strlen ("reply") + 1,
+ //ENET_PACKET_FLAG_RELIABLE);
- /* Send the reply to the peer over channel id 0. */
- enet_peer_send( event->peer, 0, reply );
+ //[> Send the reply to the peer over channel id 0. <]
+ //enet_peer_send( event->peer, 0, reply );
- /* One could just use enet_host_service() instead. */
- enet_host_flush( this->server );
+ //[> One could just use enet_host_service() instead. <]
+ //enet_host_flush( this->server );
- /* /TESTING */
+ //[> /TESTING <]
- /* game server or client connection? */
- /* game server */
+ /* GAME SERVER OR CLIENT CONNECTION? */
+
+ /* Game server */
/* parse data */
/* start actions */
/* and send reply */
+
/* client */
/* parse data */
/* start actions */
Modified: code/branches/masterserver/src/modules/masterserver/MasterServerComm.cc
===================================================================
--- code/branches/masterserver/src/modules/masterserver/MasterServerComm.cc 2010-11-10 09:46:04 UTC (rev 7629)
+++ code/branches/masterserver/src/modules/masterserver/MasterServerComm.cc 2010-11-10 13:19:44 UTC (rev 7630)
@@ -75,7 +75,8 @@
if (this->peer == NULL )
{ fprintf( stderr,
"No available peers for initiating an ENet connection.\n");
- exit (EXIT_FAILURE);
+ //exit (EXIT_FAILURE);
+ return -1;
}
/* Wait up to 2 seconds for the connection attempt to succeed. */
@@ -86,7 +87,8 @@
{
enet_peer_reset (this->peer);
fprintf( stdout, "Connection to %s failed.", address );
- exit(EXIT_FAILURE);
+ //exit(EXIT_FAILURE);
+ return -1;
}
return 0;
@@ -170,7 +172,8 @@
{
/* setup object and connect */
MasterServerComm msc = MasterServerComm();
- msc.connect( argv[1], 1234 );
+ if( msc.connect( argv[1], 1234 ) )
+ exit(EXIT_FAILURE);
/* send some data and poll for replies */
char *theinput = (char *)calloc( 100,1 );
More information about the Orxonox-commit
mailing list