Added sharedRemoteDebugServer library

This commit is contained in:
Anonymous
2014-01-16 00:05:25 -07:00
parent 99e4eb6b8c
commit 202d7d1de3
12 changed files with 311 additions and 0 deletions
+1
View File
@@ -21,6 +21,7 @@ add_subdirectory(sharedObject)
add_subdirectory(sharedPathfinding)
add_subdirectory(sharedRandom)
add_subdirectory(sharedRegex)
add_subdirectory(sharedRemoteDebugServer)
add_subdirectory(sharedSkillSystem)
add_subdirectory(sharedSynchronization)
add_subdirectory(sharedTerrain)
@@ -0,0 +1,11 @@
cmake_minimum_required(VERSION 2.8)
project(sharedRemoteDebugServer)
if(WIN32)
add_definitions(/D_CRT_SECURE_NO_WARNINGS)
endif()
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include/public)
add_subdirectory(src)
@@ -0,0 +1 @@
#include "../../src/shared/FirstSharedRemoteDebugServer.h"
@@ -0,0 +1 @@
#include "../../src/shared/SharedRemoteDebugServer.h"
@@ -0,0 +1 @@
#include "../../src/shared/SharedRemoteDebugServerConnection.h"
@@ -0,0 +1,26 @@
set(SHARED_SOURCES
shared/FirstSharedRemoteDebugServer.cpp
shared/FirstSharedRemoteDebugServer.h
shared/SharedRemoteDebugServerConnection.cpp
shared/SharedRemoteDebugServerConnection.h
shared/SharedRemoteDebugServer.cpp
shared/SharedRemoteDebugServer.h
)
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/shared
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedDebug/include/public
#${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFile/include/public
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundation/include/public
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundationTypes/include/public
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetwork/include/public
#${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedUtility/include/public
${SWG_EXTERNALS_SOURCE_DIR}/ours/library/archive/include
#${SWG_EXTERNALS_SOURCE_DIR}/ours/library/unicode/include
)
add_library(sharedRemoteDebugServer STATIC
${SHARED_SOURCES}
)
@@ -0,0 +1,8 @@
// ======================================================================
//
// FirstSharedRemoteDebugServer.cpp
// Copyright 2002 Sony Online Entertainment
//
// ======================================================================
#include "sharedRemoteDebugServer/FirstSharedRemoteDebugServer.h"
@@ -0,0 +1,18 @@
// ======================================================================
//
// FirstSharedRemoteDebugServer.h
// Copyright 2002 Sony Online Entertainment
//
// ======================================================================
#ifndef INCLUDED_FirstSharedRemoteDebugServer_H
#define INCLUDED_FirstSharedRemoteDebugServer_H
// ======================================================================
#include "sharedFoundation/FirstSharedFoundation.h"
// ======================================================================
#endif
@@ -0,0 +1,101 @@
// ======================================================================
//
// SharedRemoteDebugServer.cpp
// Copyright 2002 Sony Online Entertainment
//
// ======================================================================
#include "sharedRemoteDebugServer/FirstSharedRemoteDebugServer.h"
#include "Archive/ByteStream.h"
#include "sharedRemoteDebugServer/SharedRemoteDebugServer.h"
#include "sharedRemoteDebugServer/SharedRemoteDebugServerConnection.h"
#include "sharedFoundation/ConfigSharedFoundation.h"
#include "sharedNetwork/Service.h"
#include "sharedNetwork/Connection.h"
#include "sharedNetwork/NetworkSetupData.h"
#include "sharedDebug/RemoteDebug_inner.h"
//-------------------------------------------------------------------
//static definitions
Service * SharedRemoteDebugServer::ms_serviceHandle;
SharedRemoteDebugServerConnection * SharedRemoteDebugServer::ms_connection;
bool SharedRemoteDebugServer::ms_installed;
unsigned int SharedRemoteDebugServer::ms_remoteDebugToolChannelID;
//-------------------------------------------------------------------
void SharedRemoteDebugServer::install()
{
ms_serviceHandle = NULL;
ms_connection = NULL;
if (!ConfigSharedFoundation::getUseRemoteDebug())
return;
DEBUG_FATAL(ms_installed, ("sharedRemoteDebugServer already installed"));
NetworkSetupData setup;
setup.port = static_cast<unsigned short>(ConfigSharedFoundation::getDefaultRemoteDebugPort());
setup.maxConnections = 5;
ms_serviceHandle = new Service(ConnectionAllocator<SharedRemoteDebugServerConnection>(), setup);
//even though this is the game client, this is a remoteDebug *server*, since it sends data to a Qt app for viewing
RemoteDebugServer::install(NULL, open, close, send, NULL);
//this value needs to be true before the call to RemoteDebugServer::open
ms_installed = true;
//try to connect to a localhost instance of the remotedebug app
RemoteDebugServer::open("127.0.0.1", 4444);
}
//-------------------------------------------------------------------
void SharedRemoteDebugServer::remove(void)
{
if(!ms_installed)
return;
close();
NOT_NULL(ms_serviceHandle);
delete ms_serviceHandle;
delete ms_connection;
RemoteDebugServer::remove();
ms_installed = false;
}
//-------------------------------------------------------------------
void SharedRemoteDebugServer::open(const char *server, uint16 port)
{
DEBUG_FATAL(!ms_installed, ("sharedRemoteDebugServer not installed"));
//attempt to auto-connect to a localhost client app (if it's auto-listening)
ms_connection = new SharedRemoteDebugServerConnection(server, port);
}
//-------------------------------------------------------------------
void SharedRemoteDebugServer::close(void)
{
DEBUG_FATAL(!ms_installed, ("sharedRemoteDebugServer not installed"));
delete ms_connection;
ms_connection = NULL;
}
//-------------------------------------------------------------------
void SharedRemoteDebugServer::send(void *buffer, uint32 bufferLen)
{
DEBUG_FATAL(!ms_installed, ("sharedRemoteDebugServer not installed"));
NOT_NULL(ms_connection);
ms_connection->send(Archive::ByteStream(reinterpret_cast<const unsigned char *>(buffer), bufferLen), false);
//always send on VNL channel 0, send the buffer, it's length, and unreliable
}
//-------------------------------------------------------------------
@@ -0,0 +1,40 @@
// ======================================================================
//
// SharedRemoteDebugServer.h
// copyright 2001 Sony Online Entertainment
//
// ======================================================================
#ifndef INCLUDED_SharedRemoteDebugServer_H
#define INCLUDED_SharedRemoteDebugServer_H
class SharedRemoteDebugServerConnectionHandler;
class SharedRemoteDebugServerConnection;
class Service;
class SharedRemoteDebugServer
{
friend class SharedRemoteDebugServerConnectionHandler;
public:
static void install();
static void remove(void);
private:
///The client-specific Service used to transmit data
///true if system has been installed, false otherwise
static bool ms_installed;
static unsigned int ms_remoteDebugToolChannelID;
static Service * ms_serviceHandle;
static SharedRemoteDebugServerConnection * ms_connection;
static void open(const char *server, uint16 port);
static void close(void);
static void send(void *buffer, uint32 bufferLen);
static void receive(void *buffer, uint32 bufferLen);
};
#endif // INCLUDED_SharedRemoteDebugServer_H
@@ -0,0 +1,65 @@
// ======================================================================
//
// SharedRemoteDebugServerConnection.cpp
// Copyright 2002 Sony Online Entertainment
//
// ======================================================================
#include "sharedRemoteDebugServer/FirstSharedRemoteDebugServer.h"
#include "Archive/ByteStream.h"
#include "sharedRemoteDebugServer/SharedRemoteDebugServer.h"
#include "sharedRemoteDebugServer/SharedRemoteDebugServerConnection.h"
#include "sharedDebug/RemoteDebug_inner.h"
#include "sharedNetwork/NetworkSetupData.h"
//-----------------------------------------------------------------------
SharedRemoteDebugServerConnection::SharedRemoteDebugServerConnection(const std::string & a, const unsigned short p) :
Connection(a, p, NetworkSetupData()),
m_remotedebugCommandChannel (NULL)
{
}
//-----------------------------------------------------------------------
SharedRemoteDebugServerConnection::SharedRemoteDebugServerConnection(UdpConnectionMT * u, TcpClient * t) :
Connection(u, t),
m_remotedebugCommandChannel (NULL)
{
}
//-----------------------------------------------------------------------
SharedRemoteDebugServerConnection::~SharedRemoteDebugServerConnection()
{
}
//-----------------------------------------------------------------------
void SharedRemoteDebugServerConnection::onConnectionClosed()
{
RemoteDebugServer::close();
}
//-----------------------------------------------------------------------
void SharedRemoteDebugServerConnection::onConnectionOpened()
{
RemoteDebugServer::isReady();
}
//-----------------------------------------------------------------------
void SharedRemoteDebugServerConnection::onConnectionOverflowing(const unsigned int bytesPending)
{
UNREF(bytesPending);
}
//-----------------------------------------------------------------------
void SharedRemoteDebugServerConnection::onReceive(const Archive::ByteStream & message)
{
RemoteDebugServer::receive(message.getBuffer(), message.getSize());
}
//-----------------------------------------------------------------------
@@ -0,0 +1,38 @@
// ======================================================================
//
// SharedRemoteDebugServerConnection.h
// copyright 2001, Sony Online Entertainment
//
// ======================================================================
#ifndef _SharedRemoteDebugServerConnection_H
#define _SharedRemoteDebugServerConnection_H
//-----------------------------------------------------------------------
#include "sharedNetwork/Connection.h"
class SharedRemoteDebugServerCommandChannel;
//-----------------------------------------------------------------------
class SharedRemoteDebugServerConnection : public Connection
{
public:
SharedRemoteDebugServerConnection(const std::string & remoteAddress, const unsigned short remotePort);
SharedRemoteDebugServerConnection(UdpConnectionMT *, TcpClient *);
virtual ~SharedRemoteDebugServerConnection();
void onConnectionClosed ();
void onConnectionOpened ();
void onConnectionOverflowing (const unsigned int bytesPending);
void onReceive (const Archive::ByteStream & message);
private:
SharedRemoteDebugServerConnection(const SharedRemoteDebugServerConnection &);
SharedRemoteDebugServerConnection & operator = (const SharedRemoteDebugServerConnection &);
SharedRemoteDebugServerCommandChannel *m_remotedebugCommandChannel;
};
//-----------------------------------------------------------------------
#endif // _SharedRemoteDebugServerConnection_H