Index: /code/branches/network/src/network/PacketDecoder.cc
===================================================================
--- /code/branches/network/src/network/PacketDecoder.cc	(revision 199)
+++ /code/branches/network/src/network/PacketDecoder.cc	(revision 199)
@@ -0,0 +1,98 @@
+#include "enet/enet.h"
+#include "PacketManager.h"
+#include <iostream>
+
+using namespace std;
+using namespace network;
+
+PacketDecoder::PacketDecoder(){}
+
+bool PacketDecoder::elaborate( ENetEvent* event )
+{
+	int id = (int)*event->packet->data;
+	switch( id ) {
+	case ACK:
+		acknowledgement( event->packet );
+		return true;
+		break;
+	case MOUSE:
+		mousem( event->packet );
+		return true;
+		break;
+	case KEYBOARD:
+		keystrike( event->packet );
+		return true;
+		break;
+	case CHAT:
+		chatMessage( event->packet );
+		return true;
+		break;
+	}
+	return false;
+}
+
+void PacketDecoder::acknowledgement( ENetPacket* packet )
+{
+	ack* a = new ack;
+	*a = *(ack*)packet->data;
+	printAck( a );
+}
+
+void PacketDecoder::mousem( ENetPacket* packet )
+{
+	mouse* mouseMove = new mouse;
+	*mouseMove = *(mouse*)packet->data;
+	printMouse( mouseMove );
+}
+
+void PacketDecoder::keystrike( ENetPacket* packet )
+{
+	keyboard* key = new keyboard;
+	*key = *(keyboard*)packet->data;
+	printKey( key );
+}
+
+void PacketDecoder::chatMessage( ENetPacket* packet )
+{
+	chat* chatting = new chat;
+	chatting->id = (int)*packet->data;
+	char* reserve = new char[packet->dataLength-4];
+	memcpy( &reserve[0], packet->data+sizeof(int), packet->dataLength-4 );
+	chatting->message = reserve;
+	printChat( chatting );
+}
+
+void PacketDecoder::printPeer( ENetPeer* peer )
+{
+	cout << "number of chanels:   " << peer->channelCount << endl;
+	cout << "incomming bandwidth: " << peer->incomingBandwidth << endl;
+	cout << "outgoing bandwidth:  " << peer->outgoingBandwidth << endl;
+	cout << "peer id:             " << peer->sessionID << endl;
+	cout << "outgoing peer id:    " << peer->outgoingPeerID << endl;
+	cout << "incomming peer id:   " << peer->incomingPeerID << endl;
+	cout << "state of peer:       " << peer->state << endl;
+}
+
+void PacketDecoder::printAck( ack* data )
+{
+	cout << "data id: " << data->id << endl;
+	cout << "data:    " << data->a << endl;
+}
+
+void PacketDecoder::printMouse( mouse* data )
+{
+	cout << "data id: " << data->id << endl;
+	cout << "data:    " << data->x << " " << data->y << endl;
+}
+
+void PacketDecoder::printKey( keyboard* data )
+{
+	cout << "data id: " << data->id << endl;
+	cout << "data:    " << (char)data->press << endl;
+}
+
+void PacketDecoder::printChat( chat* data )
+{
+	cout << "data id: " << data->id << endl;
+	cout << "data:    " << data->message << endl;
+}
Index: /code/branches/network/src/network/PacketGenerator.cc
===================================================================
--- /code/branches/network/src/network/PacketGenerator.cc	(revision 199)
+++ /code/branches/network/src/network/PacketGenerator.cc	(revision 199)
@@ -0,0 +1,59 @@
+#include "PacketManager.h"
+#include "enet/enet.h"
+#include <iostream>
+#include <list>
+#include <string>
+#include <cstring>
+
+using namespace std;
+using namespace network;
+
+PacketGenerator::PacketGenerator() {}
+
+ENetPacket* PacketGenerator::acknowledgement( int state, int reliable )
+{
+	cout << "generating new acknowledgement" << endl;
+	ack* ackreq = new ack;
+	ackreq->id = ACK;
+	ackreq->a = state;
+	
+	ENetPacket *packet = enet_packet_create( ackreq , sizeof( *ackreq ), reliable );
+	
+	return packet;
+}
+
+ENetPacket* PacketGenerator::mousem( double x, double y, int reliable )
+{
+	cout << "generating new mouse" << endl;
+	mouse* mousemove = new mouse;
+	mousemove->id = MOUSE;
+	mousemove->x = x;
+	mousemove->y = y;
+	
+	ENetPacket *packet = enet_packet_create( mousemove , sizeof( *mousemove ), reliable );
+	
+	return packet;
+}
+
+ENetPacket* PacketGenerator::keystrike( char press, int reliable )
+{
+	cout << "generating new keyboard" << endl;
+	keyboard* key = new keyboard;
+	key->id = KEYBOARD;
+	key->press = press;
+	
+	ENetPacket *packet = enet_packet_create( key , sizeof( *key ), reliable );
+	
+	return packet;
+}
+
+ENetPacket* PacketGenerator::chatMessage( const char* message, int reliable )
+{
+	int* trans = new int[sizeof(int) + strlen(message) + 1];
+	*trans = CHAT;
+	memcpy( &trans[1], (const void*)message, strlen( message ) + 1);
+	ENetPacket *packet = enet_packet_create( trans , sizeof( int ) + strlen( message ) + 1, reliable );
+	
+	return packet;
+}
+
Index: /code/branches/network/src/network/PacketManager.h
===================================================================
--- /code/branches/network/src/network/PacketManager.h	(revision 199)
+++ /code/branches/network/src/network/PacketManager.h	(revision 199)
@@ -0,0 +1,85 @@
+#ifndef PACKETMANAGER_H_
+#define PACKETMANAGER_H_
+
+#include <enet/enet.h>
+
+namespace network
+{
+enum packet_id {
+	ACK,
+	MOUSE,
+	KEYBOARD,
+	CHAT
+};
+
+class PacketGenerator
+{
+public:
+	PacketGenerator();
+	ENetPacket* acknowledgement( int state, int reliable = ENET_PACKET_FLAG_RELIABLE );
+	ENetPacket* mousem( double x, double y, int reliable = ENET_PACKET_FLAG_RELIABLE );
+	ENetPacket* keystrike( char press, int reliable = ENET_PACKET_FLAG_RELIABLE );
+	ENetPacket* chatMessage( const char* message, int reliable = ENET_PACKET_FLAG_RELIABLE );
+private:
+	struct ack {
+		int id;
+		int a;
+	};
+
+	struct mouse {
+		int id;
+		double x;
+		double y;
+	};
+
+	struct keyboard {
+		int id;
+		char press;
+	};	
+	struct chat {
+		int id;
+		const char* message;
+	};
+};
+
+class PacketDecoder
+{
+public:
+	PacketDecoder();
+	bool elaborate( ENetEvent* event );
+private:
+	struct ack {
+		int id;
+		int a;
+	};
+
+	struct mouse {
+		int id;
+		double x;
+		double y;
+	};
+
+	struct keyboard {
+		int id;
+		char press;
+	};
+	struct chat {
+		int id;
+		const char* message;
+	};
+	
+	void acknowledgement( ENetPacket* event );
+	void mousem( ENetPacket* event );
+	void keystrike( ENetPacket* event );
+	void chatMessage( ENetPacket* event );
+	
+	//print functions
+	void printAck( ack* data );
+	void printMouse( mouse* data );
+	void printKey( keyboard* data );
+	void printChat( chat* data );
+	void printPeer( ENetPeer* peer );
+};
+}
+
+#endif /*PACKETMANAGER_H_*/
