|
From: <spo...@us...> - 2007-05-10 17:55:50
|
Revision: 453
http://svn.sourceforge.net/opengate/?rev=453&view=rev
Author: spom_spom
Date: 2007-05-10 10:55:52 -0700 (Thu, 10 May 2007)
Log Message:
-----------
Added Paths:
-----------
branches/ogsector/src/opengateclient.cpp
branches/ogsector/src/opengateserver.cpp
Added: branches/ogsector/src/opengateclient.cpp
===================================================================
--- branches/ogsector/src/opengateclient.cpp (rev 0)
+++ branches/ogsector/src/opengateclient.cpp 2007-05-10 17:55:52 UTC (rev 453)
@@ -0,0 +1,80 @@
+
+#ifdef WIN32
+#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
+#define WIN32_LEAN_AND_MEAN
+#include "windows.h"
+#endif
+#endif
+
+#include "LogManager.h"
+#include "networkProtocol.h"
+#include "networkClient.h"
+#include "GameStateManager.h"
+#include "DockedState.h"
+#include "UnDockedState.h"
+
+int main( int argc, char * argv[ ] ) {
+
+ OpenGate::LogManager *log = new OpenGate::LogManager();
+ log->setLogFile( "OpenGate.log" );
+ log->setChatLogFile( "OpenGateChat.log" );
+
+ std::string username = "testuser";
+ std::string hostname = "localhost";
+ std::string password = "";
+ bool dialog = true;
+
+ if ( argc > 1 ){
+ username = argv[ 1 ];
+ }
+ if ( argc > 2 ){
+ username = argv[ 1 ];
+ hostname = argv[ 2 ];
+ }
+ if ( argc > 3 ){
+ std::string dialogStr( argv[ 3 ] );
+ if ( dialogStr.find( "--ogreconfig=0", 0 ) != std::string::npos ) dialog = false;
+ }
+
+ log->info( std::string( "User: " + username + " looking for host: " + hostname ) );
+
+ asio::io_service io_service;
+ OpenGate::NetworkClient nw( io_service, hostname );
+
+ if ( nw.online() ){
+ // //** waiting for userid;
+ asio::thread t( boost::bind( & asio::io_service::run, & io_service ) );
+
+ while( nw.online() && nw.userID() == 0 ){
+ myMSleep( 100 );
+ }
+
+ log->info( std::string( "Userid: " + toStr(nw.userID() ) ) );
+ log->info( std::string( "Login user: " + username + " to: " + nw.hostname() ) );
+ nw.login( username );
+ } else {
+ nw.setUserName( username );
+ log->info( "Offline mode." );
+ }
+
+ try {
+ OpenGate::GameStateManager gameStateMgr( nw, dialog );
+ OpenGate::DockedState::create( &gameStateMgr, "DockedState" );
+ // OpenGate::UnDockedState::create( &gameStateMgr, "UnDockedState" );
+
+ gameStateMgr.start( gameStateMgr.findByName( "DockedState" ) );
+
+ } catch( Ogre::Exception& e ) {
+
+#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
+ MessageBox( NULL, e.getFullDescription().c_str(),
+ "An exception has occured!", MB_OK | MB_ICONERROR | MB_TASKMODAL);
+#else
+ log->fatal( std::string("An exception has occured: ") + e.getFullDescription().c_str() );
+#endif
+ }
+ nw.close();
+
+ delete log;
+ return EXIT_SUCCESS;
+}
Added: branches/ogsector/src/opengateserver.cpp
===================================================================
--- branches/ogsector/src/opengateserver.cpp (rev 0)
+++ branches/ogsector/src/opengateserver.cpp 2007-05-10 17:55:52 UTC (rev 453)
@@ -0,0 +1,58 @@
+/***************************************************************************
+ * Copyright (C) 2006 by Christoph Brill *
+ * eg...@us... *
+ * 2007 spom_spom@.sourceforge.net *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <iostream>
+
+#include "common.h"
+#include "networkServer.h"
+#include "LogManager.h"
+
+using namespace OpenGate;
+
+int main( int argc, char *argv[] ) {
+ LogManager *log = new LogManager( );
+ log->setLogFile( "OGserver.log" );
+ log->setChatLogFile( "OGserverChat.log" );
+
+ std::cout << "Starting up" << std::endl;
+ std::cout << "-----------" << std::endl;
+
+ try {
+ asio::io_service io_service;
+ tcp::endpoint endpoint( tcp::v4(), OG_PORT );
+ Server server( io_service, endpoint );
+
+ io_service.run();
+ }
+ catch ( asio::error & e ) {
+ log->fatal( e.what() );
+ }
+ catch ( std::exception & e ) {
+ log->fatal( std::string("Exception: ") + e.what() );
+ }
+
+ return EXIT_SUCCESS;
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|