Index: trunk/src/subprojects/network/Makefile.am
===================================================================
--- trunk/src/subprojects/network/Makefile.am	(revision 7841)
+++ trunk/src/subprojects/network/Makefile.am	(revision 7954)
@@ -1,16 +1,21 @@
 MAINSRCDIR=../..
 include $(MAINSRCDIR)/defs/include_paths.am
+
+LIB_PREFIX=$(MAINSRCDIR)/lib
+include $(MAINSRCDIR)/lib/BuildLibs.am
+
 
 bin_PROGRAMS = network
 
 
-network_CPPFLAGS = -DNO_SHELL -DNO_SHELL_COMMAND
+network_CPPFLAGS = 
+#-DNO_SHELL -DNO_SHELL_COMMAND
 
-DEPENDENCIES = \
+network_DEPENDENCIES = \
 		$(MAINSRCDIR)/world_entities/libORXwe.a \
 		$(libORXlibs_a_LIBRARIES_) \
 		$(MAINSRCDIR)/util/libORXutils.a
 
-LDADD = \
+network_LDADD = \
 		$(MAINSRCDIR)/util/libORXutils.a \
 		$(libORXlibs_a_LIBRARIES_) \
Index: trunk/src/subprojects/network/network_unit_test.cc
===================================================================
--- trunk/src/subprojects/network/network_unit_test.cc	(revision 7841)
+++ trunk/src/subprojects/network/network_unit_test.cc	(revision 7954)
@@ -9,7 +9,13 @@
 #include "network_socket.h"
 #include "server_socket.h"
+#include "udp_server_socket.h"
+#include "udp_socket.h"
 #include "network_stream.h"
 #include "synchronizeable.h"
 #include "converter.h"
+#include "state.h"
+#include "shared_network_data.h"
+#include "message_manager.h"
+#include "network_log.h"
 
 #include "simple_sync.h"
@@ -36,16 +42,25 @@
 int testSocket(int argc, char** argv)
 {
-  IPaddress ip;
-  SDLNet_ResolveHost(&ip, "127.0.0.1", 9999);
-  ServerSocket server;
-  server.listen(9999);
-
-  NetworkSocket* client1 = new NetworkSocket(ip);
-
-  NetworkSocket* server1 = server.getNewSocket();
-
-  NetworkSocket* client2 = new NetworkSocket(ip);
-
-  NetworkSocket* server2 = server.getNewSocket();
+  UdpServerSocket server(9999);
+
+  NetworkSocket* client1 = new UdpSocket("localhost", 9999);
+
+  NetworkSocket* server1 = NULL;
+  while ( server1 == NULL )
+  {
+    server.update();
+    server1 = server.getNewSocket();
+  }
+  
+  assert( server1->isOk() );
+
+  NetworkSocket* client2 = new UdpSocket("localhost", 9999);
+
+  NetworkSocket* server2 = NULL;
+  while ( server2 == NULL )
+  {
+    server.update();
+    server2 = server.getNewSocket();
+  }
 
   char buf[1024];
@@ -70,5 +85,7 @@
   n = server2->writePacket((byte*)str4, strlen(str4)+1);
   printf("%d bytes send from server2\n", n);
-  SDL_Delay(1000);
+  SDL_Delay(10);
+  
+  server.update();
 
   printf("read from server1\n");
@@ -103,7 +120,53 @@
 
   printf("data: '%s'\n", buf);
+  
+  
+  //22222222222222222222222222222222222222222
+  n = client1->writePacket((byte*)str1, strlen(str1)+1);
+  printf("%d bytes send from client1\n", n);
+  n = server1->writePacket((byte*)str2, strlen(str2)+1);
+  printf("%d bytes send from server1\n", n);
+  n = client2->writePacket((byte*)str3, strlen(str3)+1);
+  printf("%d bytes send from client2\n", n);
+  n = server2->writePacket((byte*)str4, strlen(str4)+1);
+  printf("%d bytes send from server2\n", n);
+  SDL_Delay(10);
+  
+  server.update();
+
+  printf("read from server1\n");
+  n = server1->readPacket((byte*)buf, 1024);
+  printf("read %d bytes\n", n);
+  if (n<0)
+    return -1;
+
+  printf("data: '%s'\n", buf);
+
+  printf("read from server2\n");
+  n = server2->readPacket((byte*)buf, 1024);
+  printf("read %d bytes\n", n);
+  if (n<0)
+    return -1;
+
+  printf("data: '%s'\n", buf);
+
+  printf("read from client1\n");
+  n = client1->readPacket((byte*)buf, 1024);
+  printf("read %d bytes\n", n);
+  if (n<0)
+    return -1;
+
+  printf("data: '%s'\n", buf);
+
+  printf("read from client2\n");
+  n = client2->readPacket((byte*)buf, 1024);
+  printf("read %d bytes\n", n);
+  if (n<0)
+    return -1;
+
+  printf("data: '%s'\n", buf);
 
   //sending bigger packets than 255 is not supported
-
+#if 0
   printf("try to send more than 255 bytes\n");
   printf("result: %d\n", client1->writePacket((byte*)buf, 1000));
@@ -113,5 +176,11 @@
   printf("try to read with a too small buffer\n");
   printf("result: %d\n", client1->readPacket((byte*)buf, strlen(str1)));
-
+#endif
+
+  delete client1;
+  delete client2;
+  delete server1;
+  delete server2; 
+  
   return 0;
 }
@@ -124,6 +193,6 @@
   printf("=================\n");
 
-  Synchronizeable* clientSync = new SimpleSync("Client\0");
-  Synchronizeable* serverSync = new SimpleSync("Server\0");
+  Synchronizeable* clientSync = new SimpleSync( std::string("Client") );
+  Synchronizeable* serverSync = new SimpleSync( std::string("Server") );
 
   unsigned int port = 9999;
@@ -144,5 +213,6 @@
   if(error == -1)
     printf("\n\nerror on address resolution, program inconsistancy\n\n");
-  nm->establishConnection(ip, *clientSync);
+  nm->establishConnection("localhost", port);
+  nm->connectSynchronizeable( *clientSync );
   /* adding some break for connection setup */
   SDL_Delay(20);
@@ -151,5 +221,5 @@
   for( int i = 0; i < 3; i++)
   {
-    nm->synchronize();
+    nm->synchronize( 1000 );
     /* simulate the network delay */
     SDL_Delay(50);
@@ -168,5 +238,9 @@
 }
 
-
+bool testCB( MessageId messageId, byte * data, int dataLength, void * someData, int userId )
+{
+  printf("GOT MESSAGE: %s\n", data);
+  return true;
+}
 
 /**
@@ -178,24 +252,32 @@
 int startServer(int argc, char** argv)
 {
-  if( argc <= 2)
-  {
-    printf(" Wrong arguments try following notations:\n");
-    printf("   --server [port number]\n");
-    return 0;
-  }
-
-  int port = atoi(argv[2]);
-  printf("Starting Server on port %i\n", port);
+
+
+  State::setOnline(true);
+  SharedNetworkData::getInstance()->setGameServer( true );
+  printf("Starting Server on port %i\n", 9999);
 
   NetworkManager* netMan = NetworkManager::getInstance();
-  Synchronizeable* ss = new SimpleSync("Server\0");
-
-  netMan->createServer(/**ss, */port);
+  
+  netMan->initialize();
+  
+  netMan->createServer(/**ss, */ 9999);
+  
+  SimpleSync* ss = new SimpleSync("Server");
+  ss->setSynchronized( true );
+  
+  NetworkLog::getInstance()->listen( 8888 );
+
+  //MessageManager::getInstance()->initUser( 1 );
+  MessageManager::getInstance()->registerMessageHandler( TESTMESSAGEID, testCB, NULL );
+  
   SDL_Delay(20);
 
   for(;;)
   {
-    netMan->synchronize();
-    SDL_Delay(1000);
+    MessageManager::getInstance()->sendMessage( TESTMESSAGEID, (byte*)"server to client", 18, RT_ALL, 0, MP_HIGHBANDWIDTH );
+    netMan->synchronize( 100 );
+    SDL_Delay(100);
+    ss->debug();
   }
 
@@ -210,9 +292,58 @@
 int startClient(int argc, char** argv)
 {
+
+
+  State::setOnline(true);
+  NetworkManager* netMan = NetworkManager::getInstance();
+  
+
+  netMan->initialize();
+  
+  std::string host;
+  
+  if ( argc > 2 )
+    host = argv[2];
+  else
+    host = "localhost";
+  
+  netMan->establishConnection(host, 9999);
+  
+//  SimpleSync* ss = new SimpleSync("SimpleSync");
+//  ss->setSynchronized( true );
+//  netMan->connectSynchronizeable( *ss );
+  
+  NetworkLog::getInstance()->listen( 7777 );
+
+  SimpleSync * ss = NULL;
+  
+  //MessageManager::getInstance()->initUser( 0 );
+  MessageManager::getInstance()->registerMessageHandler( TESTMESSAGEID, testCB, NULL );
+  
+  for(;;)
+  {
+    netMan->synchronize( 100 );
+    MessageManager::getInstance()->sendMessage( TESTMESSAGEID, (byte*)"client to server", 18, RT_ALL, 0, MP_HIGHBANDWIDTH );
+    ss = dynamic_cast<SimpleSync*>(ClassList::getObject( "Server", CL_SIMPLE_SYNC ) );
+    SDL_Delay(100);
+    if (ss)
+      ss->debug();
+  }
+
+
+  delete netMan;
+  delete ss;
+
+  return 0;
+}
+
+
+
+int startListen(int argc, char** argv)
+{
   if( argc < 3)
   {
     printf(" Wrong arguments try following notations:\n");
-    printf("   --client [server ip] [port number]\n");
-    printf("   --client [server name] [port number]\n");
+    printf("   --listen [server ip] [port number]\n");
+    printf("   --listen [server name] [port number]\n");
     return 0;
   }
@@ -228,12 +359,13 @@
 
   NetworkManager* netMan = NetworkManager::getInstance();
-  Synchronizeable* ss = new SimpleSync("Client\0");
-
-  netMan->establishConnection((const char*)"localhost", port/*,ip, *ss*/);
+  Synchronizeable* ss = new SimpleSync("SimpleSync\0");
+
+  netMan->establishConnection( name, port );
+  netMan->connectSynchronizeable( *ss );
 
   for(;;)
   {
-    netMan->synchronize();
-    SDL_Delay(500);
+    netMan->synchronize( 1000 );
+    SDL_Delay(10);
   }
 
@@ -245,45 +377,7 @@
 }
 
-
-
-int startListen(int argc, char** argv)
-{
-  if( argc < 3)
-  {
-    printf(" Wrong arguments try following notations:\n");
-    printf("   --listen [server ip] [port number]\n");
-    printf("   --listen [server name] [port number]\n");
-    return 0;
-  }
-
-  char* name = argv[2];
-  int port = atoi(argv[3]);
-  printf("Connecting to %s, on port %i\n", name, port);
-
-  IPaddress ip;
-  int error = SDLNet_ResolveHost(&ip, name, port);
-  if(error == -1)
-    printf("\n\nerror on address resolution, program inconsistancy\n\n");
-
-  NetworkManager* netMan = NetworkManager::getInstance();
-  Synchronizeable* ss = new ReadSync("WriteSync\0");
-
-  netMan->establishConnection(ip, *ss);
-
-  for(;;)
-  {
-    netMan->synchronize();
-    SDL_Delay(10);
-  }
-
-
-  delete netMan;
-  delete ss;
-
-  return 0;
-}
-
 void testFloatConverter(float f)
 {
+#if 0
   char* s = Converter::floatToBinString(f);
   printf("%f = ", f);
@@ -293,13 +387,15 @@
   printf("Byte Array: ");
   for (int i = 0; i < 4; i++)
-    printf("%i  ", res[i]);
+//    printf("%i  ", res[i]);
   printf("\n");
 
   float b = Converter::byteArrayToFloat(res);
   printf("ReConvert: %f \n", b);
+#endif
 }
 
 void testFloatConverter2(float f)
 {
+#if 0
   char* s = Converter::floatToBinString(f);
   printf("### %f = ", f);
@@ -314,4 +410,5 @@
   float b = Converter::_byteArrayToFloat(res);
   printf("ReConvert: %f \n", b);
+#endif
 }
 int converter(int argc, char** argv)
@@ -435,8 +532,8 @@
 
 
-bool ShellBuffer::addBufferLineStatic(const char* line, ...)
-{
+//bool ShellBuffer::addBufferLineStatic(const char* line, ...)
+//{
   //va_list arguments;
   //vprintf(line, arguments);
-  printf("%s", line);
-}
+  //  printf("%s", line);
+//}
Index: trunk/src/subprojects/network/simple_sync.cc
===================================================================
--- trunk/src/subprojects/network/simple_sync.cc	(revision 7841)
+++ trunk/src/subprojects/network/simple_sync.cc	(revision 7954)
@@ -22,5 +22,11 @@
 #include "simple_sync.h"
 
+#include "class_id.h"
+#include "fast_factory.h"
+#include "lib/util/loading/factory.h"
+
 #include "debug.h"
+
+CREATE_FACTORY(SimpleSync, CL_SIMPLE_SYNC);
 
 
@@ -28,24 +34,13 @@
  *  default constructor
  */
-SimpleSync::SimpleSync(const char* name)
-  : Synchronizeable()
+SimpleSync::SimpleSync( std::string name )
 {
-  /* define the local buffer size */
-  this->outLength = 10;
-  this->recLength = 0;
-  this->inLength = 40;
-  this->outData = new byte[this->outLength];
-  this->inData = new byte[this->inLength];
-
-  /* init the buffer data */
-  for( int i = 0; i < this->outLength; i++)
-  {
-    this->outData[i] = i;
-  }
-  for( int i = 0; i < this->inLength; i++)
-  {
-    this->inData[i] = 0;
-  }
-
+  setName( name );
+  this->setClassID( CL_SIMPLE_SYNC, "SimpleSync" );
+  in = 0;
+  out = 1;
+  syncStr = "hallo test test";
+  id = this->registerVarId( new SynchronizeableInt( &in, &out, "var", PERMISSION_ALL ) );
+  registerVar( new SynchronizeableString( &syncStr, &syncStr, "syncStr" ) );
 }
 
@@ -56,68 +51,24 @@
 SimpleSync::~SimpleSync()
 {
-  if( this->outData)
-    delete[] this->outData;
-  if( this->inData)
-    delete[] this->inData;
+}
+
+void SimpleSync::debug( )
+{
+  printf("IN: %d OUT: %d\n", in, out);
+  printf("str: %s\n", syncStr.c_str());
+}
+
+SimpleSync::SimpleSync( const TiXmlElement * root )
+{
+  setName( "" );
+  this->setClassID( CL_SIMPLE_SYNC, "SimpleSync" );
+  in = 0;
+  out = 1;
+  syncStr = "hallo test test";
+  id = this->registerVarId( new SynchronizeableInt( &in, &out, "var", PERMISSION_ALL ) );
+  registerVar( new SynchronizeableString( &syncStr, &syncStr, "syncStr" ) );
 }
 
 
-/**
- *  write data to Synchronizeable
- */
-int SimpleSync::writeBytes(const byte* data, int length, int sender)
-{
-  PRINTF(0)("SimpleSync: got %i bytes of data\n", length);
-  this->recLength = length;
-  if(this->inLength < length)
-    PRINTF(0)("ERROR: local buffer is smaller than the data to receive.\n");
-
-  /* copy the data localy */
-  for( int i = 0; i < length; i++)
-  {
-    this->inData[i] = data[i];
-  }
-  /* and debug output */
-  this->writeDebug();
-}
 
 
-/**
- *  read data from Synchronizeable
- */
-int SimpleSync::readBytes(byte* data, int maxLength, int * reciever)
-{
-  PRINTF(0)("SimpleSync: sent %i bytes of data\n", this->outLength);
-
-  /* debug msg */
-  this->readDebug();
-
-  /* write the test message */
-  for( int i = 0; i < this->outLength; i++)
-    data[i] = this->outData[i];
-
-  /* return the length of the test */
-  return this->outLength;
-}
-
-
-void SimpleSync::writeDebug() const
-{
-  PRINTF(0)("Write in bytes: \t(0 <-) |");
-  for(int i = 0; i < this->recLength; i++)
-  {
-    PRINT(0)(" [%u] ",this->inData[i]);
-  }
-  PRINT(0)("|\n");
-}
-
-
-void SimpleSync::readDebug() const
-{
-  PRINTF(0)("Read out bytes: \t(0 ->) |");
-  for(int i = 0; i < this->outLength; i++)
-  {
-    PRINT(0)(" [%u] ",this->outData[i]);
-  }
-  PRINT(0)("|\n");
-}
Index: trunk/src/subprojects/network/simple_sync.h
===================================================================
--- trunk/src/subprojects/network/simple_sync.h	(revision 7841)
+++ trunk/src/subprojects/network/simple_sync.h	(revision 7954)
@@ -13,22 +13,16 @@
   {
   public:
-    SimpleSync(const char* name);
+    SimpleSync( std::string name);
+    SimpleSync(const TiXmlElement* root = NULL);
     virtual ~SimpleSync();
-
-    virtual int writeBytes(const byte* data, int length, int sender);
-    virtual int readBytes(byte* data, int maxLength, int * reciever);
+    
+    void debug();
 
 
   private:
-    virtual void writeDebug() const;
-    virtual void readDebug() const;
-
-
-  private:
-    byte* inData;
-    int   inLength;
-    int   recLength;
-    byte* outData;
-    int   outLength;
+    int in;
+    int out;
+    std::string syncStr;
+    int id;
   };
 
