Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
r198 committed - Modified gogo to fully use cockpit. I think the conversion is complete...
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  1 message - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
gunzemula...@googlecode.com  
View profile  
 More options Jun 8 2010, 10:56 pm
From: gunzemula...@googlecode.com
Date: Wed, 09 Jun 2010 02:56:27 +0000
Local: Tues, Jun 8 2010 10:56 pm
Subject: [gunzemulator] r198 committed - Modified gogo to fully use cockpit. I think the conversion is complete...
Revision: 198
Author: cg.wowus.cg
Date: Tue Jun  8 19:30:28 2010
Log: Modified gogo to fully use cockpit. I think the conversion is complete!
http://code.google.com/p/gunzemulator/source/detail?r=198

Added:
  /trunk/gogo/src/GoGoClient.cpp
  /trunk/gogo/src/GoGoClient.h
  /trunk/gogo/src/GoGoFactory.cpp
  /trunk/gogo/src/GoGoFactory.h
Deleted:
  /trunk/gogo/src/Client.cpp
  /trunk/gogo/src/Client.h
  /trunk/gogo/src/Server.cpp
  /trunk/gogo/src/Server.h
Modified:
  /trunk/cockpit/src/CMakeLists.txt
  /trunk/cockpit/src/Client.cpp
  /trunk/gogo/src/CMakeLists.txt
  /trunk/gogo/src/main.cpp

=======================================
--- /dev/null
+++ /trunk/gogo/src/GoGoClient.cpp      Tue Jun  8 19:30:28 2010
@@ -0,0 +1,32 @@
+#include "GoGoClient.h"
+
+#include <cockpit/Transmitter.h>
+#include <cockpit/packet/Registry.h>
+
+#include <cassert>
+
+using namespace boost;
+using namespace cockpit;
+
+GoGoClient::GoGoClient(Logger* _logger)
+{
+       assert(_logger);
+       logger = _logger;
+}
+
+void GoGoClient::initialize(Transmitter* _transmitter, packet::Registry*  
_registry)
+{
+       transmitter = _transmitter;
+       registry = _registry;
+
+       // TODO: Register all necessary handlers.
+}
+
+array<uint8_t, 26> GoGoClient::handshake(const asio::ip::tcp::socket& s)  
const
+{
+       // TODO: A synchronous handshake. <- Don't say that out loud, it's  
misleading =P
+}
+
+GoGoClient::~GoGoClient()
+{
+}
=======================================
--- /dev/null
+++ /trunk/gogo/src/GoGoClient.h        Tue Jun  8 19:30:28 2010
@@ -0,0 +1,23 @@
+#pragma once
+
+#include <cockpit/ClientHandler.h>
+#include <cockpit/Logger.h>
+
+class GoGoClient : public cockpit::ClientHandler
+{
+private:
+       cockpit::Logger* logger;
+       cockpit::Transmitter* transmitter;
+       cockpit::packet::Registry* registry;
+
+public:
+       GoGoClient(cockpit::Logger* logger);
+
+       void initialize(cockpit::Transmitter* transmitter,  
cockpit::packet::Registry* registry);
+
+       boost::array<boost::uint8_t, 26>
+       handshake(const boost::asio::ip::tcp::socket& s) const;
+
+       ~GoGoClient();
+};
+
=======================================
--- /dev/null
+++ /trunk/gogo/src/GoGoFactory.cpp     Tue Jun  8 19:30:28 2010
@@ -0,0 +1,16 @@
+#include "GoGoFactory.h"
+
+#include "GoGoClient.h"
+
+#include <cassert>
+
+GoGoFactory::GoGoFactory(cockpit::Logger* _logger)
+{
+       assert(_logger);
+       logger = _logger;
+}
+
+cockpit::ClientHandler* GoGoFactory::create_client_handler()
+{
+       return new GoGoClient(logger);
+}
=======================================
--- /dev/null
+++ /trunk/gogo/src/GoGoFactory.h       Tue Jun  8 19:30:28 2010
@@ -0,0 +1,15 @@
+#pragma once
+
+#include <cockpit/ClientHandlerFactory.h>
+#include <cockpit/Logger.h>
+
+class GoGoFactory : public cockpit::ClientHandlerFactory
+{
+private:
+       cockpit::Logger* logger;
+
+public:
+       GoGoFactory(cockpit::Logger* logger);
+
+       cockpit::ClientHandler* create_client_handler();
+};
=======================================
--- /trunk/gogo/src/Client.cpp  Tue Jun  8 19:27:58 2010
+++ /dev/null
@@ -1,184 +0,0 @@
-#include "Client.h"
-#include <boost/format.hpp>
-#include <util/memory.h>
-#include <util/buffer.h>
-
-using namespace boost;
-using namespace cockpit;
-
-namespace
-{
-       struct Handshake
-       {
-               boost::uint16_t Header;
-               boost::uint32_t Size;
-               MUID ServerId;
-               MUID PlayerId;
-               boost::uint32_t Timestamp; // Not ever used; MAIET is retarded. We just  
set this to 0x0DEADCA7 to be cool.
-
-               Handshake();
-               Handshake(MUID server, MUID player);
-       };
-}
-
-Handshake::Handshake()
-{
-       Header = 10;
-       Size = 26;
-       ServerId = 0;
-       PlayerId = 0;
-       Timestamp = 0x0DEADCA7;
-}
-
-Handshake::Handshake(MUID server, MUID player)
-{
-       Header = 10;
-       Size = 26;
-       ServerId = server;
-       PlayerId = player;
-       Timestamp = 0x0DEADCA7;
-}
-
-Client::Client(Logger* _logger, asio::io_service &service, MUIDSanta*  
_santa)
-       : socket(service), logger(_logger), santa(_santa)
-{
-       memory::set(cryptkey, 0x00, sizeof(cryptkey));
-       clientid = santa->get();
-}
-
-void Client::start()
-{
-       logger->info(
-               format("Incoming connection from [%1%], MUID = %2%.")
-                       % socket.remote_endpoint().address().to_string()
-                       % clientid
-       );
-
-
-       send_handshake();
-}
-
-void Client::OnRecv()
-{
-}
-
-boost::array<boost::uint8_t, 26>
-Client::make_handshake()
-{
-       uint32_t tempValues[3] = { 0 };
-       uint8_t* cryptkeyPtr = cryptkey;
-       Handshake handshake(1, clientid);
-
-       boost::array<boost::uint8_t, 26> packet = { {
-               0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-               0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-               0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-               0x00, 0x00
-       } };
-
-       uint8_t* packetPtr = &(packet[0]);
-
-       //Static client keys.
-       uint8_t IV[2][16] = {
-               {
-                       0x37, 0x04, 0x5D, 0x2E, 0x43, 0x3A, 0x49, 0x53,
-                       0x50, 0x05, 0x13, 0xC9, 0x28, 0xA4, 0x4D, 0x05
-               },
-               {
-                       0x57, 0x02, 0x5B, 0x04, 0x34, 0x06, 0x01, 0x08,
-                       0x37, 0x0A, 0x12, 0x69, 0x41, 0x38, 0x0F, 0x78
-               }
-       };
-
-       //Crypt key creation.
-       cryptkeyPtr = memory::pcopy(cryptkeyPtr, &handshake.Timestamp, 4);
-
-       //TODO: Fix the order of this...
-       cryptkeyPtr = memory::pcopy(cryptkeyPtr, &handshake.ServerId,  
sizeof(boost::uint32_t));
-       cryptkeyPtr = memory::pcopy(cryptkeyPtr, &clientid, sizeof(clientid));
-       cryptkeyPtr = memory::pcopy(cryptkeyPtr, IV, sizeof(IV[0]));
-
-       for (int i = 0; i < 4; ++i)
-       {
-               memory::copy(tempValues, IV[1]+(i*4), sizeof(uint32_t));
-               memory::copy(tempValues + 1, cryptkey+(i*sizeof(uint32_t)),  
sizeof(uint32_t));
-               tempValues[2] = tempValues[0] ^ tempValues[1];
-               memory::copy(cryptkey+(i*4), tempValues + 2 ,sizeof(uint32_t));
-       }
-
-       //Create the packet.
-       packetPtr = memory::pcopy(packetPtr, &handshake.Header,  
sizeof(boost::uint16_t));
-       packetPtr = memory::pcopy(packetPtr, &handshake.Size,  
sizeof(boost::uint32_t));
-       packetPtr = memory::pcopy(packetPtr, &handshake.ServerId, sizeof(MUID));
-       packetPtr = memory::pcopy(packetPtr, &handshake.PlayerId, sizeof(MUID));
-       packetPtr = memory::pcopy(packetPtr, &handshake.Timestamp,  
sizeof(boost::uint32_t));
-
-       return packet;
-}
-
-boost::array<boost::uint8_t, 26>
-Client::test_handshake(boost::uint64_t clientid)
-{
-       uint8_t cryptkey[32];
-       uint32_t tempValues[3] = { 0 };
-       uint8_t* cryptkeyPtr = cryptkey;
-       Handshake handshake(1, clientid);
-
-       boost::array<boost::uint8_t, 26> packet = { {
-               0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-               0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-               0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-               0x00, 0x00
-       } };
-
-       uint8_t* packetPtr = &(packet[0]);
-
-       //Static client keys.
-       uint8_t IV[2][16] = {
-               {
-                       0x37, 0x04, 0x5D, 0x2E, 0x43, 0x3A, 0x49, 0x53,
-                       0x50, 0x05, 0x13, 0xC9, 0x28, 0xA4, 0x4D, 0x05
-               },
-               {
-                       0x57, 0x02, 0x5B, 0x04, 0x34, 0x06, 0x01, 0x08,
-                       0x37, 0x0A, 0x12, 0x69, 0x41, 0x38, 0x0F, 0x78
-               }
-       };
-
-       //Crypt key creation.
-       cryptkeyPtr = memory::pcopy(cryptkeyPtr, &handshake.Timestamp, 4);
-
-       //TODO: Fix the order of this...
-       cryptkeyPtr = memory::pcopy(cryptkeyPtr, &handshake.ServerId,  
sizeof(boost::uint32_t));
-       cryptkeyPtr = memory::pcopy(cryptkeyPtr, &clientid, sizeof(clientid));
-       cryptkeyPtr = memory::pcopy(cryptkeyPtr, IV, sizeof(IV[0]));
-
-       for (int i = 0; i < 4; ++i)
-       {
-               memory::copy(tempValues, IV[1]+(i*4), sizeof(uint32_t));
-               memory::copy(tempValues + 1, cryptkey+(i*sizeof(uint32_t)),  
sizeof(uint32_t));
-               tempValues[2] = tempValues[0] ^ tempValues[1];
-               memory::copy(cryptkey+(i*4), tempValues + 2 ,sizeof(uint32_t));
-       }
-
-       //Create the packet.
-       packetPtr = memory::pcopy(packetPtr, &handshake.Header,  
sizeof(boost::uint16_t));
-       packetPtr = memory::pcopy(packetPtr, &handshake.Size,  
sizeof(boost::uint32_t));
-       packetPtr = memory::pcopy(packetPtr, &handshake.ServerId, sizeof(MUID));
-       packetPtr = memory::pcopy(packetPtr, &handshake.PlayerId, sizeof(MUID));
-       packetPtr = memory::pcopy(packetPtr, &handshake.Timestamp,  
sizeof(boost::uint32_t));
-
-       return packet;
-}
-
-void Client::send_handshake()
-{
-       boost::array<boost::uint8_t, 26> packet = make_handshake();
-
-       socket.send(boost::asio::buffer(packet, 26));
-}
-
-Client::~Client()
-{
-       santa->give_back(clientid);
-}
=======================================
--- /trunk/gogo/src/Client.h    Tue Jun  8 19:27:58 2010
+++ /dev/null
@@ -1,38 +0,0 @@
-#pragma once
-#include <boost/array.hpp>
-#include <boost/shared_array.hpp>
-#include <boost/enable_shared_from_this.hpp>
-#include <boost/asio.hpp>
-#include <boost/asio/buffer.hpp>
-#include <boost/cstdint.hpp>
-#include <cockpit/Logger.h>
-
-#include "Structures.h"
-#include "MUIDSanta.h"
-
-class Client
-{
-public:
-       boost::asio::ip::tcp::socket socket;
-
-private:
-       boost::shared_array<unsigned char> recvbuffer;
-       boost::uint8_t cryptkey[32];
-       cockpit::Logger* logger;
-       MUID clientid;
-       MUIDSanta* santa;
-
-public:
-       Client(cockpit::Logger* logger, boost::asio::io_service& service,  
MUIDSanta* santa);
-       void start();
-
-       boost::array<boost::uint8_t, 26>
-       make_handshake();
-       static boost::array<boost::uint8_t, 26> test_handshake(boost::uint64_t);
-
-       ~Client();
-
-private:
-       void send_handshake();
-       void OnRecv();
-};
=======================================
--- /trunk/gogo/src/Server.cpp  Tue Jun  8 19:27:58 2010
+++ /dev/null
@@ -1,41 +0,0 @@
-#include "Server.h"
-#include <boost/asio.hpp>
-#include <boost/bind.hpp>
-
-using namespace boost;
-using namespace cockpit;
-
-Server::Server(
-       Logger* _logger,
-       asio::io_service& service,
-       const asio::ip::tcp::endpoint& endpoint
-)
-       : logger(_logger), acceptor(service, endpoint)
-{
-       start_accept();
-
-       logger->info(format("GoGo has initialized and is running on port %1%!") %  
endpoint.port());
-}
-
-void Server::start_accept()
-{
-       shared_ptr<Client> client(new Client(logger, acceptor.io_service(),  
&santa));
-
-       acceptor.async_accept(
-               client->socket,
-               bind(&Server::handle_accept, this, client, asio::placeholders::error)
-       );
-}
-
-void Server::handle_accept(shared_ptr<Client> client, const  
boost::system::error_code& error)
-{
-       if(!error)
-       {
-               client->start();
-               start_accept();
-       }
-       else
-       {
-               logger->warning("New connection could not be made.");
-       }
-}
=======================================
--- /trunk/gogo/src/Server.h    Tue Jun  8 19:27:58 2010
+++ /dev/null
@@ -1,32 +0,0 @@
-#pragma once
-#include <boost/shared_ptr.hpp>
-#include <boost/cstdint.hpp>
-#include <boost/asio.hpp>
-
-#include <cockpit/Logger.h>
-
-#include "Client.h"
-#include "MUIDSanta.h"
-
-class Server
-{
-private:
-       cockpit::Logger* logger;
-       boost::asio::ip::tcp::acceptor acceptor;
-       MUIDSanta santa;
-
-private:
-       void handle_accept(
-               boost::shared_ptr<Client> client,
-               const boost::system::error_code& error
-       );
-
-       void start_accept();
-
-public:
-       Server(
-               cockpit::Logger* logger,
-               boost::asio::io_service& serivce,
-               const boost::asio::ip::tcp::endpoint& endpoint
-       );
-};
=======================================
--- /trunk/cockpit/src/CMakeLists.txt   Sun Jun  6 09:15:01 2010
+++ /trunk/cockpit/src/CMakeLists.txt   Tue Jun  8 19:30:28 2010
@@ -3,6 +3,7 @@
        packet/crypto.cpp
        packet/Parameters.cpp
        packet/Registry.cpp
+       packet/security.cpp

        Client.cpp
        MatchServer.cpp
=======================================
--- /trunk/cockpit/src/Client.cpp       Tue Jun  8 19:30:12 2010
+++ /trunk/cockpit/src/Client.cpp       Tue Jun  8 19:30:28 2010
@@ -170,9 +170,6 @@
                disconnect();
                return;
        }
-
-       // If this gets triggered, boost is fucking up and we need to read the  
docs some more.
-       assert(bytesTransferred == payloadSize);

        if(payloadSize < sizeof(Payload))
        {
@@ -183,6 +180,9 @@
                disconnect();
                return;
        }
+
+       // If this gets triggered, boost is fucking up and we need to read the  
docs some more.
+       assert(bytesTransferred == payloadSize);

        Payload payload = extract_payload(p, encrypted);
        uint16_t paramLength = payloadSize - sizeof(Payload);   // LOL.
=======================================
--- /trunk/gogo/src/CMakeLists.txt      Tue Jun  8 19:29:59 2010
+++ /trunk/gogo/src/CMakeLists.txt      Tue Jun  8 19:30:28 2010
@@ -1,14 +1,14 @@
  set(GOGO_SRC
-       main.cpp
-       Structures.h
-       Client.h
-       Client.cpp
        ConsoleLogger.h
        ConsoleLogger.cpp
-       Server.h
-       Server.cpp
+       GoGoClient.cpp
+       GoGoClient.h
+       GoGoFactory.cpp
+       GoGoFactory.h
+       main.cpp
        MUIDSanta.h
        MUIDSanta.cpp
+       Structures.h
        # Feel free to add more source files when they're added.
  )

=======================================
--- /trunk/gogo/src/main.cpp    Tue Jun  8 19:30:12 2010
+++ /trunk/gogo/src/main.cpp    Tue Jun  8 19:30:28 2010
@@ -1,6 +1,11 @@
  #include "ConsoleLogger.h"
+#include "GoGoFactory.h"
+
+#include <cockpit/MatchServer.h>
+
  #include <exception>
  #include <boost/asio/io_service.hpp>
+#include <boost/thread.hpp>

  using namespace boost;

@@ -8,10 +13,19 @@
  {
        ConsoleLogger loggerImpl;
        cockpit::Logger* logger = &loggerImpl;
-       asio::io_service ioService;
+
+       // By default, run 2 times as many threads as the CPU has cores.
+       asio::io_service ioService(thread::hardware_concurrency() * 2);
+
+       GoGoFactory factory(logger);

        try {
-               // IMPLEMENTATION HERE.
+               // TODO: Configuration loading for the port number.
+               cockpit::MatchServer server(logger, &factory, &ioService, 6000);
+
+               server.run();
+
+               ioService.run();

        } catch(const std::exception& ex) {
                logger->error(format("Fatal error: %1%") % ex.what());


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »