From: <eg...@us...> - 2006-08-27 12:53:54
|
Revision: 147 Author: egore Date: 2006-08-27 05:53:34 -0700 (Sun, 27 Aug 2006) ViewCVS: http://svn.sourceforge.net/opengate/?rev=147&view=rev Log Message: ----------- update config-files make use of pkgconfig in more places play around with controls and destroy them on the way (will be fixed soon) add networking Modified Paths: -------------- ChangeLog config.guess config.sub configure.in opengate.kdevelop src/client/network.cpp src/client/network.h src/client/ui/ActionConfig.cpp src/client/ui/avatar.h src/opengate_client.cpp src/opengate_server.cpp src/server/network.cpp src/server/network.h Modified: ChangeLog =================================================================== --- ChangeLog 2006-08-05 22:06:37 UTC (rev 146) +++ ChangeLog 2006-08-27 12:53:34 UTC (rev 147) @@ -1,3 +1,15 @@ +2006-08-27 Christoph Brill <eg...@us...> + + * configure.in: add support for libgrapple, add support for libxml2 + + * src/client/network.h, src/client/network.cpp, src/server/network.h, + src/server/network.cpp: drop SDL_net in favour of libgrapple + + * src/opengate-server.cpp: add polling server (1s interval for test + purposes) + + * src/opengate-client.cpp: connect to the server and send a message + 2006-07-30 Christoph Brill <eg...@us...> * src/client/input: drop old handmade inputsystem Modified: config.guess =================================================================== --- config.guess 2006-08-05 22:06:37 UTC (rev 146) +++ config.guess 2006-08-27 12:53:34 UTC (rev 147) @@ -4,7 +4,7 @@ # 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, # Inc. -timestamp='2006-02-27' +timestamp='2006-07-02' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -228,7 +228,7 @@ echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} exit ;; macppc:MirBSD:*:*) - echo powerppc-unknown-mirbsd${UNAME_RELEASE} + echo powerpc-unknown-mirbsd${UNAME_RELEASE} exit ;; *:MirBSD:*:*) echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} @@ -788,6 +788,8 @@ case ${UNAME_MACHINE} in pc98) echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + amd64) + echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; *) echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; esac @@ -798,9 +800,6 @@ i*:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit ;; - i*:MSYS_NT-*:*:*) - echo ${UNAME_MACHINE}-pc-mingw32 - exit ;; i*:windows32*:*) # uname -m includes "-pc" on this system. echo ${UNAME_MACHINE}-mingw32 @@ -808,10 +807,10 @@ i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit ;; - x86:Interix*:[345]*) + x86:Interix*:[3456]*) echo i586-pc-interix${UNAME_RELEASE} exit ;; - EM64T:Interix*:[345]*) + EM64T:Interix*:[3456]*) echo x86_64-unknown-interix${UNAME_RELEASE} exit ;; [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) @@ -849,6 +848,9 @@ arm*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; + avr32*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; cris:Linux:*:*) echo cris-axis-linux-${LIBC} exit ;; @@ -951,7 +953,7 @@ echo ${UNAME_MACHINE}-ibm-linux exit ;; sh64*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; sh*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} @@ -1009,7 +1011,7 @@ LIBC=gnulibc1 # endif #else - #if defined(__INTEL_COMPILER) || defined(__PGI) || defined(__sun) + #if defined(__INTEL_COMPILER) || defined(__PGI) || defined(__SUNPRO_C) || defined(__SUNPRO_CC) LIBC=gnu #else LIBC=gnuaout Modified: config.sub =================================================================== --- config.sub 2006-08-05 22:06:37 UTC (rev 146) +++ config.sub 2006-08-27 12:53:34 UTC (rev 147) @@ -4,7 +4,7 @@ # 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, # Inc. -timestamp='2006-02-27' +timestamp='2006-07-02' # This file is (in principle) common to ALL GNU software. # The presence of a machine in this file suggests that SOME GNU software @@ -241,7 +241,7 @@ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | am33_2.0 \ - | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \ + | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \ | bfin \ | c4x | clipper \ | d10v | d30v | dlx | dsp16xx | dvp \ @@ -249,7 +249,8 @@ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | i370 | i860 | i960 | ia64 \ | ip2k | iq2000 \ - | m32r | m32rle | m68000 | m68k | m88k | maxq | mb | microblaze | mcore \ + | m32c | m32r | m32rle | m68000 | m68k | m88k \ + | maxq | mb | microblaze | mcore \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ @@ -275,11 +276,11 @@ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ | pyramid \ - | sh | sh[1234] | sh[24]a | sh[24]a*eb | sh[23]e | sh[34]eb | shbe | sheb | shle | sh[1234]le | sh3ele \ + | sh | sh[1234] | sh[24]a | sh[24]a*eb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ - | strongarm \ + | spu | strongarm \ | tahoe | thumb | tic4x | tic80 | tron \ | v850 | v850e \ | we32k \ @@ -287,9 +288,6 @@ | z8k) basic_machine=$basic_machine-unknown ;; - m32c) - basic_machine=$basic_machine-unknown - ;; m6811 | m68hc11 | m6812 | m68hc12) # Motorola 68HC11/12. basic_machine=$basic_machine-unknown @@ -319,7 +317,7 @@ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ - | avr-* \ + | avr-* | avr32-* \ | bfin-* | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ | clipper-* | craynv-* | cydra-* \ @@ -330,7 +328,7 @@ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | i*86-* | i860-* | i960-* | ia64-* \ | ip2k-* | iq2000-* \ - | m32r-* | m32rle-* \ + | m32c-* | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ | m88110-* | m88k-* | maxq-* | mcore-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ @@ -359,7 +357,7 @@ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ | pyramid-* \ | romp-* | rs6000-* \ - | sh-* | sh[1234]-* | sh[24]a-* | sh[24]a*eb-* | sh[23]e-* | sh[34]eb-* | shbe-* | sheb-* \ + | sh-* | sh[1234]-* | sh[24]a-* | sh[24]a*eb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ | sparclite-* \ @@ -374,8 +372,6 @@ | ymp-* \ | z8k-*) ;; - m32c-*) - ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 386bsd) @@ -1236,7 +1232,7 @@ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ - | -skyos* | -haiku* | -rdos* | -irx*) + | -skyos* | -haiku* | -rdos* | -toppers* | -irx*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) @@ -1388,6 +1384,9 @@ # system, and we'll never get to this point. case $basic_machine in + spu-*) + os=-elf + ;; *-acorn) os=-riscix1.2 ;; @@ -1397,9 +1396,9 @@ arm*-semi) os=-aout ;; - c4x-* | tic4x-*) - os=-coff - ;; + c4x-* | tic4x-*) + os=-coff + ;; # This must come before the *-dec entry. pdp10-*) os=-tops20 Modified: configure.in =================================================================== --- configure.in 2006-08-05 22:06:37 UTC (rev 146) +++ configure.in 2006-08-27 12:53:34 UTC (rev 147) @@ -26,6 +26,17 @@ AM_CXXFLAGS="$AM_CXXFLAGS $OIS_CFLAGS" AM_LDFLAGS="$AM_LDFLAGS $OIS_LIBS" +#libgrapple - http://grapple.linuxgamepublishing.com/grapple.php +PKG_CHECK_MODULES(GRAPPLE, [grapple >= 0.9]) +AM_CXXFLAGS="$AM_CXXFLAGS $GRAPPLE_CFLAGS" +AM_LDFLAGS="$AM_LDFLAGS $GRAPPLE_LIBS" + +#libxml2 - http://www.xmlsoft.org/ +PKG_CHECK_MODULES(LIBXML2, [libxml2 >= 2.6]) +AM_CXXFLAGS="$AM_CXXFLAGS $LIBXML2_CFLAGS" +AM_LDFLAGS="$AM_LDFLAGS $LIBXML2_LIBS" + + AC_SUBST(AM_CXXFLAGS, "$AM_CXXFLAGS") AC_SUBST(AM_LDFLAGS, "$AM_LDFLAGS") Modified: opengate.kdevelop =================================================================== --- opengate.kdevelop 2006-08-05 22:06:37 UTC (rev 146) +++ opengate.kdevelop 2006-08-27 12:53:34 UTC (rev 147) @@ -13,7 +13,7 @@ <ignoreparts/> <projectdirectory>.</projectdirectory> <absoluteprojectpath>false</absoluteprojectpath> - <description/> + <description></description> <versioncontrol>kdevsubversion</versioncontrol> </general> <kdevautoproject> @@ -32,7 +32,7 @@ <opengate-client/> </runarguments> <customdirectory>/</customdirectory> - <programargs/> + <programargs></programargs> <autocompile>true</autocompile> <envvars/> </run> @@ -62,14 +62,14 @@ <f77compiler>kdevg77options</f77compiler> <cxxflags>-O0 -g3</cxxflags> <envvars/> - <topsourcedir/> - <cppflags>`xml2-config --cflags` `sdl-config --cflags`</cppflags> - <ldflags>`xml2-config --libs` `sdl-config --libs` -lSDL_net</ldflags> - <ccompilerbinary/> - <cxxcompilerbinary/> - <f77compilerbinary/> - <cflags/> - <f77flags/> + <topsourcedir></topsourcedir> + <cppflags></cppflags> + <ldflags></ldflags> + <ccompilerbinary></ccompilerbinary> + <cxxcompilerbinary></cxxcompilerbinary> + <f77compilerbinary></f77compilerbinary> + <cflags></cflags> + <f77flags></f77flags> </debug> <default> <envvars/> @@ -224,12 +224,12 @@ </kdevcppsupport> <kdevdebugger> <general> - <programargs/> - <gdbpath/> + <programargs></programargs> + <gdbpath></gdbpath> <dbgshell>libtool</dbgshell> - <configGdbScript/> - <runShellScript/> - <runGdbScript/> + <configGdbScript></configGdbScript> + <runShellScript></runShellScript> + <runGdbScript></runGdbScript> <breakonloadinglibs>true</breakonloadinglibs> <separatetty>false</separatetty> <floatingtoolbar>false</floatingtoolbar> Modified: src/client/network.cpp =================================================================== --- src/client/network.cpp 2006-08-05 22:06:37 UTC (rev 146) +++ src/client/network.cpp 2006-08-27 12:53:34 UTC (rev 147) @@ -22,38 +22,29 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + #include "network.h" -#include "../common/exception.h" -#include <SDL/SDL.h> -#include <iostream> +#include <string.h> + Network::Network() { - if (SDLNet_Init () < 0) { - printf ("ERR Net: %s\n", SDLNet_GetError ()); - exit (-1); - } - client_udp_port = 37601; + client = grapple_client_init(PACKAGE_NAME, VERSION); + grapple_client_address_set(client, "localhost"); + grapple_client_port_set(client, 1234); + grapple_client_protocol_set(client, GRAPPLE_PROTOCOL_UDP); + grapple_client_start(client, 0); + //TODO:grapple_client_name_set(client, name); } -void Network::open_connection(char* hostname, Uint16 port) { - if (SDLNet_ResolveHost (server_ip, hostname, port) < 0) { - printf ("SDLNet_ResolveHost: %s\n", SDLNet_GetError ()); - SDLNet_Quit(); - exit (-1); - } - client = SDLNet_TCP_Open (server_ip); - if (client == NULL) { - printf ("ERR TCP_Open: %s\n", SDLNet_GetError ()); - SDLNet_Quit (); - exit (-1); - } - client_udp = SDLNet_UDP_Open (client_udp_port); - if (client_udp == NULL) { - printf ("ERR UDP_Open: %s\n", SDLNet_GetError ()); - SDLNet_Quit (); - exit (-1); - } +Network::~Network() { + grapple_client_stop(client); + grapple_client_destroy(client); } -Network::~Network() { +void Network::send() { + char* data = "opengate_test_message"; + grapple_confirmid confirm = grapple_client_send(client, GRAPPLE_SERVER, GRAPPLE_RELIABLE, data, strlen(data)); } Modified: src/client/network.h =================================================================== --- src/client/network.h 2006-08-05 22:06:37 UTC (rev 146) +++ src/client/network.h 2006-08-27 12:53:34 UTC (rev 147) @@ -25,19 +25,15 @@ #ifndef _OPENGATE_NETWORK_ #define _OPENGATE_NETWORK_ -#include <SDL/SDL_net.h> +#include <grapple.h> class Network { +private: + grapple_client client; public: Network(); ~Network(); - void open_connection(char* hostname, Uint16 port); -private: - IPaddress* server_ip; - TCPsocket client; - UDPsocket client_udp; - Uint16 client_udp_port; - + void send(); }; #endif Modified: src/client/ui/ActionConfig.cpp =================================================================== --- src/client/ui/ActionConfig.cpp 2006-08-05 22:06:37 UTC (rev 146) +++ src/client/ui/ActionConfig.cpp 2006-08-27 12:53:34 UTC (rev 147) @@ -562,12 +562,10 @@ mRotYScale = 0.0f; } -//--------------------------------------------------------------------------------// -bool ActionConfig::frameStarted(const Ogre::FrameEvent& evt) -{ +bool ActionConfig::frameStarted(const Ogre::FrameEvent& evt) { if (mChar) { - //FIXME:mChar->update (evt.timeSinceLastFrame, mInputDevice); + mChar->update (evt.timeSinceLastFrame, mRotXScale, mRotYScale, 0, mTranslateVector); if (mExCamera) { switch (mMode) { @@ -590,14 +588,14 @@ } } - Ogre::Camera *cam = mSceneMgr->getCamera("PlayerCam"); // Move about 100 units per second, mMoveScale = 100 * evt.timeSinceLastFrame; - cam->yaw(Ogre::Degree(mRotXScale)); - cam->pitch(Ogre::Degree(mRotYScale)); - cam->moveRelative(mTranslateVector); + //Ogre::Camera *cam = mSceneMgr->getCamera("PlayerCam"); + //cam->yaw(Ogre::Degree(mRotXScale)); + //cam->pitch(Ogre::Degree(mRotYScale)); + //cam->moveRelative(mTranslateVector); return true; } @@ -750,10 +748,14 @@ if( axis->absOnly == false ) { //Move using relative Axis - Ogre::Camera *cam = mSceneMgr->getCamera("PlayerCam"); + //Ogre::Camera *cam = mSceneMgr->getCamera("PlayerCam"); - cam->yaw(Ogre::Radian(Ogre::Degree(-axis->relX * 0.13f))); - cam->pitch(Ogre::Radian(Ogre::Degree(-axis->relY * 0.13f))); + /*if (mChar) { + mChar->update (evt.timeSinceLastFrame, mRotXScale, mRotYScale, 0, mTranslateVector); + }*/ + + //cam->yaw(Ogre::Radian(Ogre::Degree(-axis->relX * 0.13f))); + //cam->pitch(Ogre::Radian(Ogre::Degree(-axis->relY * 0.13f))); } else { Modified: src/client/ui/avatar.h =================================================================== --- src/client/ui/avatar.h 2006-08-05 22:06:37 UTC (rev 146) +++ src/client/ui/avatar.h 2006-08-27 12:53:34 UTC (rev 147) @@ -40,7 +40,7 @@ protected: public: // Updates the character (movement...) - virtual void update (Ogre::Real elapsedTime, Ogre::InputReader *input) = 0; + virtual void update (Ogre::Real elapsedTime, float rotXScale, float rotYScale, float rotZScale, Ogre::Vector3 translateVector) = 0; // The three methods below returns the two camera-related nodes, // and the current position of the character (for the 1st person camera) Ogre::SceneNode *getSightNode () { @@ -84,10 +84,14 @@ mSceneMgr->destroySceneNode (mName); } - void update (Ogre::Real elapsedTime, Ogre::InputReader *input) { - // Handle movement - if (input->isKeyDown (Ogre::KC_W)) { - mMainNode->translate (mMainNode->getOrientation () * Ogre::Vector3 (0, 0, 100 * elapsedTime)); + void update (Ogre::Real elapsedTime, float rotXScale, float rotYScale, float rotZScale, Ogre::Vector3 translateVector) { + + mMainNode->yaw(Ogre::Degree(rotXScale)); + mMainNode->pitch(Ogre::Degree(rotYScale)); + mMainNode->roll(Ogre::Degree(rotZScale)); + mMainNode->translate(mMainNode->getOrientation () * translateVector); + + /*mMainNode->translate (mMainNode->getOrientation () * Ogre::Vector3 (0, 0, 100 * elapsedTime)); } if (input->isKeyDown (Ogre::KC_S)) { mMainNode->translate (mMainNode->getOrientation () * Ogre::Vector3 (0, 0, -50 * elapsedTime)); @@ -97,7 +101,7 @@ } if (input->isKeyDown (Ogre::KC_D)) { mMainNode->yaw (Ogre::Radian (-2 * elapsedTime)); - } + }*/ } // Change visibility - Useful for 1st person view ;) Modified: src/opengate_client.cpp =================================================================== --- src/opengate_client.cpp 2006-08-05 22:06:37 UTC (rev 146) +++ src/opengate_client.cpp 2006-08-27 12:53:34 UTC (rev 147) @@ -39,6 +39,8 @@ #include "client/ui/application.h" #include "common/equipment/capacitor.h" +#include "client/network.h" + #include <OISException.h> using namespace std; @@ -66,6 +68,10 @@ cout << "-----------" << std::endl; cout << "Statring up" << std::endl; cout << "-----------" << std::endl; + + Network* nw = new Network(); + nw->send(); + /* Loader* loader = new Loader(); loader->parse_file("money.xml"); cout << loader->get_option("/equipment/name") << std::endl; @@ -146,6 +152,7 @@ delete(f_storage); delete(loader); + delete(nw); cout << "-------------" << std::endl; cout << "Shutting down" << std::endl; Modified: src/opengate_server.cpp =================================================================== --- src/opengate_server.cpp 2006-08-05 22:06:37 UTC (rev 146) +++ src/opengate_server.cpp 2006-08-27 12:53:34 UTC (rev 147) @@ -25,14 +25,40 @@ #include <iostream> #include <cstdlib> +#include <signal.h> -using namespace std; +#include "server/network.h" +bool done; + +/*! @brief a signal handler + * + * This method catches the SIGINT for the server to perform clean shutdown. + * + * @param sig the signal's number (see "man 7 signal") + */ +void shutdown_server(int sig) { + printf("Signal %d caught, starting shutdown.\n", sig); + done = true; +} + int main(int argc, char *argv[]) { - cout << "Statring up" << std::endl; - cout << "-----------" << std::endl; + std::cout << "Statring up" << std::endl; + std::cout << "-----------" << std::endl; - cout << "Shutting down" << std::endl; - cout << "-------------" << std::endl; + signal(SIGINT, shutdown_server); + + done = false; + Network* nw = new Network(2); + while (!done) { + nw->pull(); + sleep(1); + } + + std::cout << "Shutting down" << std::endl; + std::cout << "-------------" << std::endl; + + delete(nw); + return EXIT_SUCCESS; } Modified: src/server/network.cpp =================================================================== --- src/server/network.cpp 2006-08-05 22:06:37 UTC (rev 146) +++ src/server/network.cpp 2006-08-27 12:53:34 UTC (rev 147) @@ -22,39 +22,52 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "network.h" -#include "../common/exception.h" -#include <SDL/SDL.h> +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + #include <iostream> -Network::Network() { - if (SDLNet_Init () < 0) { - printf ("ERR Net: %s\n", SDLNet_GetError ()); - exit (-1); - } - server_udp_port = 37605; - server_tcp_port = 37701; -} +#include "network.h" -void Network::open_connection() { - if (SDLNet_ResolveHost (server_ip, NULL, server_tcp_port) < 0) { - printf ("SDLNet_ResolveHost: %s\n", SDLNet_GetError ()); - SDLNet_Quit(); - exit (-1); - } - server = SDLNet_TCP_Open (server_ip); - if (server == NULL) { - printf ("ERR TCP_Open: %s\n", SDLNet_GetError ()); - SDLNet_Quit (); - exit (-1); - } - server_udp = SDLNet_UDP_Open (server_udp_port); - if (server_udp == NULL) { - printf ("ERR UDP_Open: %s\n", SDLNet_GetError ()); - SDLNet_Quit (); - exit (-1); - } +Network::Network(int max_users) { + server = grapple_server_init(PACKAGE_NAME, VERSION); + grapple_server_port_set(server, 1234); + grapple_server_protocol_set(server, GRAPPLE_PROTOCOL_UDP); + grapple_server_session_set(server, "Opengate Test Server"); + grapple_server_start(server); + grapple_server_maxusers_set(server, max_users); } Network::~Network() { + //TODO: disconnect all clients + grapple_server_stop(server); + grapple_server_destroy(server); } + +void Network::pull() { + std::cout << "pulling" << std::endl; + grapple_message* message = 0; + if (grapple_server_messages_waiting(server)) { + message = grapple_server_message_pull(server); + switch (message->type) { + case GRAPPLE_MSG_NEW_USER: + std::cout << "new user!" << std::endl; + //Your code to handle this message + break; + case GRAPPLE_MSG_USER_NAME: + std::cout << "username!" << std::endl; + //Your code to handle this message + break; + case GRAPPLE_MSG_USER_MSG: + std::cout << "message!" << std::endl; + //Your code to handle this message + break; + case GRAPPLE_MSG_USER_DISCONNECTED: + std::cout << "disconnected!" << std::endl; + //Your code to handle this message + break; + } + grapple_message_dispose(message); + } +} Modified: src/server/network.h =================================================================== --- src/server/network.h 2006-08-05 22:06:37 UTC (rev 146) +++ src/server/network.h 2006-08-27 12:53:34 UTC (rev 147) @@ -25,19 +25,15 @@ #ifndef _OPENGATE_NETWORK_ #define _OPENGATE_NETWORK_ -#include <SDL/SDL_net.h> +#include <grapple.h> class Network { +private: + grapple_server server; public: - Network(); + Network(int max_users); ~Network(); - void open_connection(); -private: - IPaddress* server_ip; - TCPsocket server; - UDPsocket server_udp; - Uint16 server_udp_port; - Uint16 server_tcp_port; + void pull(); }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |