mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-18 11:19:10 +00:00
Remove unused dead weight CSR and SimpleNet code
This commit is contained in:
@ -4,8 +4,6 @@ add_subdirectory(inc)
|
||||
add_subdirectory(pnAddrInfo)
|
||||
add_subdirectory(pnAsyncCore)
|
||||
add_subdirectory(pnAsyncCoreExe)
|
||||
#add_subdirectory(pnCsrCli) # Not being used in any current sln
|
||||
add_subdirectory(pnCsrNet)
|
||||
add_subdirectory(pnDispatch)
|
||||
add_subdirectory(pnEncryption)
|
||||
add_subdirectory(pnFactory)
|
||||
@ -20,7 +18,6 @@ add_subdirectory(pnNetCommon)
|
||||
add_subdirectory(pnNetProtocol)
|
||||
add_subdirectory(pnProduct)
|
||||
add_subdirectory(pnSceneObject)
|
||||
add_subdirectory(pnSimpleNet)
|
||||
add_subdirectory(pnTimer)
|
||||
add_subdirectory(pnUtils)
|
||||
add_subdirectory(pnUtilsExe)
|
||||
|
@ -162,8 +162,8 @@ enum EConnType {
|
||||
kConnTypeSrvToState = 17,
|
||||
kConnTypeSrvToLog = 18,
|
||||
kConnTypeSrvToScore = 19,
|
||||
kConnTypeCliToCsr = 20,
|
||||
kConnTypeSimpleNet = 21,
|
||||
kConnTypeCliToCsr = 20, // DEAD
|
||||
kConnTypeSimpleNet = 21, // DEAD
|
||||
kConnTypeCliToGateKeeper = 22,
|
||||
|
||||
// Text connections
|
||||
|
@ -1,16 +0,0 @@
|
||||
include_directories(../../CoreLib)
|
||||
include_directories(../../NucleusLib)
|
||||
|
||||
set(pnCsrCli_SOURCES
|
||||
pnCsrCli.cpp
|
||||
)
|
||||
|
||||
set(pnCsrCli_HEADERS
|
||||
Pch.h
|
||||
pnCsrCli.h
|
||||
)
|
||||
|
||||
add_library(pnCsrCli STATIC ${pnCsrCli_SOURCES} ${pnCsrCli_HEADERS})
|
||||
|
||||
source_group("Source Files" FILES ${pnCsrCli_SOURCES})
|
||||
source_group("Header Files" FILES ${pnCsrCli_HEADERS})
|
@ -1,56 +0,0 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Additional permissions under GNU GPL version 3 section 7
|
||||
|
||||
If you modify this Program, or any covered work, by linking or
|
||||
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
|
||||
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
|
||||
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
|
||||
(or a modified version of those libraries),
|
||||
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
|
||||
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
|
||||
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
|
||||
licensors of this Program grant you additional
|
||||
permission to convey the resulting work. Corresponding Source for a
|
||||
non-source form of such a combination shall include the source code for
|
||||
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
|
||||
work.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
/*****************************************************************************
|
||||
*
|
||||
* $/Plasma20/Sources/Plasma/NucleusLib/pnCsrCli/Pch.h
|
||||
*
|
||||
***/
|
||||
|
||||
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNCSRCLI_PCH_H
|
||||
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnCsrCli/Pch.h included more than once"
|
||||
#endif
|
||||
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNCSRCLI_PCH_H
|
||||
|
||||
|
||||
#include "pnCsrCli.h"
|
||||
|
||||
#include <malloc.h>
|
@ -1,269 +0,0 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Additional permissions under GNU GPL version 3 section 7
|
||||
|
||||
If you modify this Program, or any covered work, by linking or
|
||||
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
|
||||
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
|
||||
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
|
||||
(or a modified version of those libraries),
|
||||
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
|
||||
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
|
||||
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
|
||||
licensors of this Program grant you additional
|
||||
permission to convey the resulting work. Corresponding Source for a
|
||||
non-source form of such a combination shall include the source code for
|
||||
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
|
||||
work.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
/*****************************************************************************
|
||||
*
|
||||
* $/Plasma20/Sources/Plasma/NucleusLib/pnCsrCli/pnCsrCli.cpp
|
||||
*
|
||||
***/
|
||||
|
||||
#include "Pch.h"
|
||||
#pragma hdrstop
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* Local types
|
||||
*
|
||||
***/
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* Local data
|
||||
*
|
||||
***/
|
||||
|
||||
static bool s_running;
|
||||
static CCritSect s_critsect;
|
||||
static SimpleNetConn * s_conn;
|
||||
static FCsrCliOnError s_onError;
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* Local functions
|
||||
*
|
||||
***/
|
||||
|
||||
//============================================================================
|
||||
static SimpleNetConn * GetConnIncRef () {
|
||||
|
||||
SimpleNetConn * conn;
|
||||
s_critsect.Enter();
|
||||
{
|
||||
if (nil != (conn = s_conn))
|
||||
SimpleNetConnIncRef(conn);
|
||||
}
|
||||
s_critsect.Leave();
|
||||
return conn;
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
static bool SimpleNetOnMsg (
|
||||
SimpleNetConn * ,
|
||||
SimpleNet_MsgHeader *
|
||||
) {
|
||||
LogMsg(kLogPerf, L"pnCsrCli: Rcvd unexpected message from peer");
|
||||
return false;
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
static void SimpleNetOnError (
|
||||
SimpleNetConn * ,
|
||||
ENetError error
|
||||
) {
|
||||
if (!s_running)
|
||||
return;
|
||||
|
||||
LogMsg(kLogPerf, L"pnCsrCli: NetError: %s", NetErrorToString(error));
|
||||
|
||||
if (error == kNetErrDisconnected)
|
||||
CsrCliDisconnect();
|
||||
|
||||
s_onError(error);
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
static void SimpleNetOnConnect (
|
||||
void * param,
|
||||
SimpleNetConn * conn,
|
||||
ENetError result
|
||||
) {
|
||||
FCsrCliOnConnect onConnect = (FCsrCliOnConnect)param;
|
||||
|
||||
LogMsg(kLogPerf, L"pnCsrCli: OnConnect: %s", NetErrorToString(result));
|
||||
|
||||
if (s_conn)
|
||||
CsrCliDisconnect();
|
||||
|
||||
if (IS_NET_SUCCESS(result)) {
|
||||
s_critsect.Enter();
|
||||
{
|
||||
s_conn = conn;
|
||||
}
|
||||
s_critsect.Leave();
|
||||
}
|
||||
|
||||
if (onConnect)
|
||||
onConnect(result);
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
static void Send_ExecConsoleCmd (const char cmd[]) {
|
||||
|
||||
SimpleNetConn * conn = GetConnIncRef();
|
||||
if (!conn)
|
||||
return;
|
||||
|
||||
unsigned cmdBytes = StrBytes(cmd);
|
||||
|
||||
CsrNet_ExecConsoleCmd * msg;
|
||||
|
||||
unsigned msgBytes
|
||||
= sizeof(*msg)
|
||||
- sizeof(msg->cmd)
|
||||
+ cmdBytes
|
||||
+ sizeof(cmd[0])
|
||||
;
|
||||
|
||||
msg = new(_alloca(msgBytes)) CsrNet_ExecConsoleCmd();
|
||||
msg->messageBytes = msgBytes;
|
||||
|
||||
StrCopy(msg->cmd, cmd, cmdBytes / sizeof(cmd[0]));
|
||||
msg->cmd[cmdBytes] = 0;
|
||||
|
||||
SimpleNetSend(conn, msg);
|
||||
SimpleNetConnDecRef(conn);
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* Exports
|
||||
*
|
||||
***/
|
||||
|
||||
//============================================================================
|
||||
void CsrCliInitialize (FCsrCliOnError onError) {
|
||||
|
||||
ASSERT(!s_running);
|
||||
ASSERT(onError);
|
||||
|
||||
s_running = true;
|
||||
s_onError = onError;
|
||||
|
||||
SimpleNetInitialize();
|
||||
SimpleNetCreateChannel(kSimpleNetChannelCsr, SimpleNetOnMsg, SimpleNetOnError);
|
||||
};
|
||||
|
||||
//============================================================================
|
||||
void CsrCliShutdown () {
|
||||
|
||||
s_running = false;
|
||||
s_onError = nil;
|
||||
|
||||
CsrCliDisconnect();
|
||||
SimpleNetDestroyChannel(kSimpleNetChannelCsr);
|
||||
SimpleNetShutdown();
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
void CsrCliStartConnecting (
|
||||
const wchar_t addr[],
|
||||
FCsrCliOnConnect onConnect
|
||||
) {
|
||||
ASSERT(s_running);
|
||||
|
||||
CsrCliDisconnect();
|
||||
SimpleNetStartConnecting(kSimpleNetChannelCsr, addr, SimpleNetOnConnect, onConnect);
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
void CsrCliDisconnect () {
|
||||
|
||||
SimpleNetConn * conn = nil;
|
||||
s_critsect.Enter();
|
||||
{
|
||||
SWAP(conn, s_conn);
|
||||
}
|
||||
s_critsect.Leave();
|
||||
if (conn)
|
||||
SimpleNetDisconnect(conn);
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
void CsrCliToggleAvatarPhysical () {
|
||||
|
||||
ASSERT(s_running);
|
||||
|
||||
Send_ExecConsoleCmd("Avatar.Physics.TogglePhysical");
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
void CsrCliWarpPlayerHere (unsigned playerId) {
|
||||
|
||||
ASSERT(s_running);
|
||||
|
||||
char cmd[1024];
|
||||
StrPrintf(cmd, arrsize(cmd), "CCR.WarpPlayerHere %u", playerId);
|
||||
Send_ExecConsoleCmd(cmd);
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
void CsrCliWarpToPlayer (unsigned playerId) {
|
||||
|
||||
ASSERT(s_running);
|
||||
|
||||
char cmd[1024];
|
||||
StrPrintf(cmd, arrsize(cmd), "CCR.WarpToPlayer %u", playerId);
|
||||
Send_ExecConsoleCmd(cmd);
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
void CsrCliLinkPlayerHere (unsigned playerId) {
|
||||
|
||||
ASSERT(s_running);
|
||||
|
||||
char cmd[1024];
|
||||
StrPrintf(cmd, arrsize(cmd), "CCR.LinkPlayerHere %u", playerId);
|
||||
Send_ExecConsoleCmd(cmd);
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
void CsrCliLinkToPlayer (unsigned playerId) {
|
||||
|
||||
ASSERT(s_running);
|
||||
|
||||
char cmd[1024];
|
||||
StrPrintf(cmd, arrsize(cmd), "CCR.LinkToPlayer %u", playerId);
|
||||
Send_ExecConsoleCmd(cmd);
|
||||
}
|
@ -1,83 +0,0 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Additional permissions under GNU GPL version 3 section 7
|
||||
|
||||
If you modify this Program, or any covered work, by linking or
|
||||
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
|
||||
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
|
||||
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
|
||||
(or a modified version of those libraries),
|
||||
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
|
||||
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
|
||||
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
|
||||
licensors of this Program grant you additional
|
||||
permission to convey the resulting work. Corresponding Source for a
|
||||
non-source form of such a combination shall include the source code for
|
||||
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
|
||||
work.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
/*****************************************************************************
|
||||
*
|
||||
* $/Plasma20/Sources/Plasma/NucleusLib/pnCsrCli/pnCsrCli.h
|
||||
*
|
||||
***/
|
||||
|
||||
#ifndef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNCSRCLI_PNCSRCLI_H
|
||||
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNCSRCLI_PNCSRCLI_H
|
||||
|
||||
|
||||
#include "pnCsrNet/pnCsrNet.h"
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* pnCsrCli
|
||||
* - Connects to pfCsrSrv in remote CSR client.
|
||||
* - Sends commands to pfCsrSrv for remote execution.
|
||||
*
|
||||
***/
|
||||
|
||||
typedef void (*FCsrCliOnError) (ENetError error);
|
||||
|
||||
void CsrCliInitialize (FCsrCliOnError onError);
|
||||
void CsrCliShutdown ();
|
||||
|
||||
typedef void (*FCsrCliOnConnect) (ENetError result);
|
||||
|
||||
void CsrCliStartConnecting (
|
||||
const wchar_t addr[],
|
||||
FCsrCliOnConnect onConnect
|
||||
);
|
||||
void CsrCliDisconnect ();
|
||||
|
||||
void CsrCliToggleAvatarPhysical ();
|
||||
void CsrCliWarpPlayerHere (unsigned playerId);
|
||||
void CsrCliWarpToPlayer (unsigned playerId);
|
||||
void CsrCliLinkPlayerHere (unsigned playerId);
|
||||
void CsrCliLinkToPlayer (unsigned playerId);
|
||||
|
||||
|
||||
#endif // PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNCSRCLI_PNCSRCLI_H
|
@ -1,16 +0,0 @@
|
||||
include_directories(../../CoreLib)
|
||||
include_directories(../../NucleusLib)
|
||||
|
||||
set(pnCsrNet_SOURCES
|
||||
pnCsrNet.cpp
|
||||
)
|
||||
|
||||
set(pnCsrNet_HEADERS
|
||||
Pch.h
|
||||
pnCsrNet.h
|
||||
)
|
||||
|
||||
add_library(pnCsrNet STATIC ${pnCsrNet_SOURCES} ${pnCsrNet_HEADERS})
|
||||
|
||||
source_group("Source Files" FILES ${pnCsrNet_SOURCES})
|
||||
source_group("Header Files" FILES ${pnCsrNet_HEADERS})
|
@ -1,54 +0,0 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Additional permissions under GNU GPL version 3 section 7
|
||||
|
||||
If you modify this Program, or any covered work, by linking or
|
||||
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
|
||||
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
|
||||
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
|
||||
(or a modified version of those libraries),
|
||||
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
|
||||
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
|
||||
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
|
||||
licensors of this Program grant you additional
|
||||
permission to convey the resulting work. Corresponding Source for a
|
||||
non-source form of such a combination shall include the source code for
|
||||
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
|
||||
work.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
/*****************************************************************************
|
||||
*
|
||||
* $/Plasma20/Sources/Plasma/NucleusLib/pnCsrNet/Pch.h
|
||||
*
|
||||
***/
|
||||
|
||||
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNCSRNET_PCH_H
|
||||
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnCsrNet/Pch.h included more than once"
|
||||
#endif
|
||||
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNCSRNET_PCH_H
|
||||
|
||||
|
||||
#include "pnCsrNet.h"
|
@ -1,49 +0,0 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Additional permissions under GNU GPL version 3 section 7
|
||||
|
||||
If you modify this Program, or any covered work, by linking or
|
||||
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
|
||||
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
|
||||
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
|
||||
(or a modified version of those libraries),
|
||||
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
|
||||
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
|
||||
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
|
||||
licensors of this Program grant you additional
|
||||
permission to convey the resulting work. Corresponding Source for a
|
||||
non-source form of such a combination shall include the source code for
|
||||
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
|
||||
work.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
/*****************************************************************************
|
||||
*
|
||||
* $/Plasma20/Sources/Plasma/NucleusLib/pnCsrNet/pnCsrNet.cpp
|
||||
*
|
||||
***/
|
||||
|
||||
#include "Pch.h"
|
||||
#pragma hdrstop
|
@ -1,88 +0,0 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Additional permissions under GNU GPL version 3 section 7
|
||||
|
||||
If you modify this Program, or any covered work, by linking or
|
||||
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
|
||||
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
|
||||
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
|
||||
(or a modified version of those libraries),
|
||||
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
|
||||
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
|
||||
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
|
||||
licensors of this Program grant you additional
|
||||
permission to convey the resulting work. Corresponding Source for a
|
||||
non-source form of such a combination shall include the source code for
|
||||
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
|
||||
work.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
/*****************************************************************************
|
||||
*
|
||||
* $/Plasma20/Sources/Plasma/NucleusLib/pnCsrNet/pnCsrNet.h
|
||||
*
|
||||
***/
|
||||
|
||||
#ifndef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNCSRNET_PNCSRNET_H
|
||||
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNCSRNET_PNCSRNET_H
|
||||
|
||||
|
||||
#include "pnSimpleNet/pnSimpleNet.h"
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* CSR Client Automation - Types and Constants
|
||||
*
|
||||
***/
|
||||
|
||||
// Newer CSR game clients must remain compatible with older CSR tools,
|
||||
// therefore these values may not change. Only append to this enum.
|
||||
enum {
|
||||
kCsrNet_ExecConsoleCmd,
|
||||
};
|
||||
|
||||
//============================================================================
|
||||
// BEGIN PACKED DATA STRUCTURES
|
||||
//============================================================================
|
||||
#pragma pack(push,1)
|
||||
|
||||
#define CSRNET_MSG(a) \
|
||||
CsrNet_##a () : SimpleNet_MsgHeader(kSimpleNetChannelCsr, kCsrNet_##a) { }
|
||||
|
||||
struct CsrNet_ExecConsoleCmd : SimpleNet_MsgHeader {
|
||||
CSRNET_MSG (ExecConsoleCmd);
|
||||
|
||||
char cmd[1]; // null-terminated string
|
||||
};
|
||||
|
||||
#undef CSRNET_MSG
|
||||
//============================================================================
|
||||
// END PACKED DATA STRUCTURES
|
||||
//============================================================================
|
||||
#pragma pack(pop)
|
||||
|
||||
|
||||
#endif // PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNCSRNET_PNCSRNET_H
|
@ -121,20 +121,6 @@ const AccountRoleInfo kAccountRoles[] = {
|
||||
{ kAccountRolesAllUserFlags, "End" }
|
||||
};
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* Csr
|
||||
*
|
||||
***/
|
||||
|
||||
enum ECsrFlags {
|
||||
kCsrFlagAdmin = 1 << 0,
|
||||
kCsrFlagDisabled = 1 << 1,
|
||||
kCsrFlagServer = 1 << 2,
|
||||
};
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* Game Score Types
|
||||
|
@ -46,10 +46,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
uint8_t kAuthDhNData[kNetDiffieHellmanKeyBits / 8] = {0};
|
||||
uint8_t kAuthDhXData[kNetDiffieHellmanKeyBits / 8] = {0};
|
||||
|
||||
// CSR Server
|
||||
uint8_t kCsrDhNData[kNetDiffieHellmanKeyBits / 8] = {0};
|
||||
uint8_t kCsrDhXData[kNetDiffieHellmanKeyBits / 8] = {0};
|
||||
|
||||
// Game Server
|
||||
uint8_t kGameDhNData[kNetDiffieHellmanKeyBits / 8] = {0};
|
||||
uint8_t kGameDhXData[kNetDiffieHellmanKeyBits / 8] = {0};
|
||||
|
@ -51,11 +51,6 @@ static const unsigned kAuthDhGValue = 41;
|
||||
extern uint8_t kAuthDhNData[kNetDiffieHellmanKeyBits / 8];
|
||||
extern uint8_t kAuthDhXData[kNetDiffieHellmanKeyBits / 8];
|
||||
|
||||
// CSR Server
|
||||
static const unsigned kCsrDhGValue = 97;
|
||||
extern uint8_t kCsrDhNData[kNetDiffieHellmanKeyBits / 8];
|
||||
extern uint8_t kCsrDhXData[kNetDiffieHellmanKeyBits / 8];
|
||||
|
||||
// Game Server
|
||||
static const unsigned kGameDhGValue = 73;
|
||||
extern uint8_t kGameDhNData[kNetDiffieHellmanKeyBits / 8];
|
||||
|
@ -59,12 +59,12 @@ const wchar_t * NetProtocolToString (ENetProtocol protocol) {
|
||||
{ kNetProtocolDebug, L"kNetProtocolDebug" },
|
||||
|
||||
// Client connections
|
||||
{ kNetProtocolCli2Csr, L"GateKeeper Server" },
|
||||
{ kNetProtocolCli2Csr, L"Csr Server" },
|
||||
{ kNetProtocolCli2Auth, L"Auth Server" },
|
||||
{ kNetProtocolCli2Game, L"Game Server" },
|
||||
{ kNetProtocolCli2File, L"File Server" },
|
||||
{ kNetProtocolCli2Unused_01, L"kNetProtocolCli2Unused_01" },
|
||||
{ kNetProtocolCli2GateKeeper, L"GateKeeper Server" },
|
||||
{ kNetProtocolCli2Unused_02, L"kNetProtocolCli2Unused_02" },
|
||||
{ kNetProtocolCli2Auth, L"Auth Server" },
|
||||
{ kNetProtocolCli2Game, L"Game Server" },
|
||||
{ kNetProtocolCli2File, L"File Server" },
|
||||
{ kNetProtocolCli2Unused_01, L"kNetProtocolCli2Unused_01" },
|
||||
|
||||
// Server connections
|
||||
{ kNetProtocolSrvConn, L"kNetProtocolSrvConn" },
|
||||
|
@ -64,7 +64,7 @@ enum ENetProtocol {
|
||||
|
||||
// Client connections
|
||||
kNetProtocolCli2GateKeeper = 2,
|
||||
kNetProtocolCli2Csr = 3,
|
||||
kNetProtocolCli2Unused_02 = 3,
|
||||
kNetProtocolCli2Auth = 4,
|
||||
kNetProtocolCli2Game = 5,
|
||||
kNetProtocolCli2File = 6,
|
||||
|
@ -65,12 +65,6 @@ static const char* s_fileAddrs[] = {
|
||||
};
|
||||
|
||||
|
||||
static char s_csrAddrConsole[64] = {0};
|
||||
static const char* s_csrAddrs[] = {
|
||||
s_csrAddrConsole
|
||||
};
|
||||
|
||||
|
||||
static char s_gateKeeperAddrConsole[64] = {0};
|
||||
static const char* s_gateKeeperAddrs[] = {
|
||||
s_gateKeeperAddrConsole
|
||||
@ -113,22 +107,6 @@ void SetFileSrvHostname (const char addr[]) {
|
||||
strncpy(s_fileAddrConsole, addr, arrsize(s_fileAddrConsole));
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
// Csr
|
||||
//============================================================================
|
||||
unsigned GetCsrSrvHostnames (const char*** addrs) {
|
||||
|
||||
*addrs = s_csrAddrs;
|
||||
return arrsize(s_csrAddrs);
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
void SetCsrSrvHostname (const char addr[]) {
|
||||
|
||||
strncpy(s_csrAddrConsole, addr, arrsize(s_csrAddrConsole));
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
// GateKeeper
|
||||
//============================================================================
|
||||
|
@ -68,7 +68,7 @@ enum ESrvType {
|
||||
kSrvTypeLog = 9,
|
||||
kSrvTypeDll = 10,
|
||||
kSrvTypeScore = 11,
|
||||
kSrvTypeCsr = 12,
|
||||
kSrvTypeCsr = 12, // DEAD
|
||||
kSrvTypeGateKeeper = 13,
|
||||
|
||||
kNumSrvTypes,
|
||||
@ -90,9 +90,6 @@ void SetAuthSrvHostname (const char addr[]);
|
||||
unsigned GetFileSrvHostnames (const char*** addrs); // returns addrCount
|
||||
void SetFileSrvHostname (const char addr[]);
|
||||
|
||||
unsigned GetCsrSrvHostnames (const char*** addrs); // returns addrCount
|
||||
void SetCsrSrvHostname (const char addr[]);
|
||||
|
||||
unsigned GetGateKeeperSrvHostnames (const char*** addrs); // returns addrCount
|
||||
void SetGateKeeperSrvHostname (const char addr[]);
|
||||
|
||||
|
@ -22,11 +22,6 @@ set(pnNetProtocol_PROTO_CLI2AUTH
|
||||
Private/Protocols/Cli2Auth/pnNpCli2Auth.cpp
|
||||
)
|
||||
|
||||
set(pnNetProtocol_PROTO_CLI2CSR
|
||||
Private/Protocols/Cli2Csr/pnNpCli2Csr.h
|
||||
Private/Protocols/Cli2Csr/pnNpCli2Csr.cpp
|
||||
)
|
||||
|
||||
set(pnNetProtocol_PROTO_CLI2FILE
|
||||
Private/Protocols/Cli2File/pnNpCli2File.h
|
||||
Private/Protocols/Cli2File/pnNpCli2File.cpp
|
||||
@ -73,18 +68,16 @@ set(pnNetProtocol_PROTO_SRV2VAULT
|
||||
)
|
||||
|
||||
add_library(pnNetProtocol STATIC ${pnNetProtocol_HEADERS} ${pnNetProtocol_PRIVATE}
|
||||
${pnNetProtocol_PROTO_CLI2AUTH} ${pnNetProtocol_PROTO_CLI2CSR}
|
||||
${pnNetProtocol_PROTO_CLI2FILE} ${pnNetProtocol_PROTO_CLI2GAME}
|
||||
${pnNetProtocol_PROTO_CLI2GK} ${pnNetProtocol_PROTO_SRV2DB}
|
||||
${pnNetProtocol_PROTO_SRV2LOG} ${pnNetProtocol_PROTO_SRV2MCP}
|
||||
${pnNetProtocol_PROTO_SRV2SCORE} ${pnNetProtocol_PROTO_SRV2STATE}
|
||||
${pnNetProtocol_PROTO_SRV2VAULT}
|
||||
${pnNetProtocol_PROTO_CLI2AUTH} ${pnNetProtocol_PROTO_CLI2FILE}
|
||||
${pnNetProtocol_PROTO_CLI2GAME} ${pnNetProtocol_PROTO_CLI2GK}
|
||||
${pnNetProtocol_PROTO_SRV2DB} ${pnNetProtocol_PROTO_SRV2LOG}
|
||||
${pnNetProtocol_PROTO_SRV2MCP} ${pnNetProtocol_PROTO_SRV2SCORE}
|
||||
${pnNetProtocol_PROTO_SRV2STATE} ${pnNetProtocol_PROTO_SRV2VAULT}
|
||||
)
|
||||
|
||||
source_group("Header Files" FILES ${pnNetProtocol_HEADERS})
|
||||
source_group("Private" FILES ${pnNetProtocol_PRIVATE})
|
||||
source_group("Private\\Cli2Auth" FILES ${pnNetProtocol_PROTO_CLI2AUTH})
|
||||
source_group("Private\\Cli2Csr" FILES ${pnNetProtocol_PROTO_CLI2CSR})
|
||||
source_group("Private\\Cli2File" FILES ${pnNetProtocol_PROTO_CLI2FILE})
|
||||
source_group("Private\\Cli2Game" FILES ${pnNetProtocol_PROTO_CLI2GAME})
|
||||
source_group("Private\\Cli2GateKeeper" FILES ${pnNetProtocol_PROTO_CLI2GK})
|
||||
|
@ -1,122 +0,0 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Additional permissions under GNU GPL version 3 section 7
|
||||
|
||||
If you modify this Program, or any covered work, by linking or
|
||||
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
|
||||
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
|
||||
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
|
||||
(or a modified version of those libraries),
|
||||
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
|
||||
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
|
||||
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
|
||||
licensors of this Program grant you additional
|
||||
permission to convey the resulting work. Corresponding Source for a
|
||||
non-source form of such a combination shall include the source code for
|
||||
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
|
||||
work.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
/*****************************************************************************
|
||||
*
|
||||
* $/Plasma20/Sources/Plasma/NucleusLib/pnNetProtocol/Private/Protocols/Cli2Csr/pnNpCli2Csr.cpp
|
||||
*
|
||||
***/
|
||||
|
||||
#define USES_PROTOCOL_CLI2CSR
|
||||
#include "../../../Pch.h"
|
||||
#pragma hdrstop
|
||||
|
||||
|
||||
namespace Cli2Csr {
|
||||
/*****************************************************************************
|
||||
*
|
||||
* Cli2Csr message field definitions
|
||||
*
|
||||
***/
|
||||
|
||||
static const NetMsgField kPingRequestFields[] = {
|
||||
kNetMsgFieldTransId, // transId
|
||||
kNetMsgFieldTimeMs, // pingTimeMs
|
||||
NET_MSG_FIELD_VAR_COUNT(1, 64 * 1024), // payloadBytes
|
||||
NET_MSG_FIELD_VAR_PTR(), // payload
|
||||
};
|
||||
|
||||
static const NetMsgField kRegisterRequestFields[] = {
|
||||
kNetMsgFieldTransId, // transId
|
||||
};
|
||||
|
||||
static const NetMsgField kLoginRequestFields[] = {
|
||||
kNetMsgFieldTransId, // transId
|
||||
NET_MSG_FIELD_DWORD(), // clientChallenge
|
||||
kNetMsgFieldAccountName, // csrName
|
||||
kNetMsgFieldShaDigest, // challenge
|
||||
};
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* Csr2Cli message field definitions
|
||||
*
|
||||
***/
|
||||
|
||||
static const NetMsgField kPingReplyFields[] = {
|
||||
kNetMsgFieldTransId, // transId
|
||||
kNetMsgFieldTimeMs, // pingTimeMs
|
||||
NET_MSG_FIELD_VAR_COUNT(1, 64 * 1024), // payloadBytes
|
||||
NET_MSG_FIELD_VAR_PTR(), // payload
|
||||
};
|
||||
|
||||
static const NetMsgField kRegisterReplyFields[] = {
|
||||
kNetMsgFieldTransId, // transId
|
||||
NET_MSG_FIELD_DWORD(), // serverChallenge
|
||||
NET_MSG_FIELD_DWORD(), // latestBuildId
|
||||
};
|
||||
|
||||
static const NetMsgField kLoginReplyFields[] = {
|
||||
kNetMsgFieldTransId, // transId
|
||||
kNetMsgFieldENetError, // result
|
||||
kNetMsgFieldUuid, // csrId
|
||||
NET_MSG_FIELD_DWORD(), // csrFlags
|
||||
};
|
||||
|
||||
|
||||
} using namespace Cli2Csr;
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* Exports
|
||||
*
|
||||
***/
|
||||
|
||||
const NetMsg kNetMsg_Cli2Csr_PingRequest = NET_MSG(kCli2Csr_PingRequest, kPingRequestFields);
|
||||
const NetMsg kNetMsg_Cli2Csr_RegisterRequest = NET_MSG(kCli2Csr_RegisterRequest, kRegisterRequestFields);
|
||||
const NetMsg kNetMsg_Cli2Csr_LoginRequest = NET_MSG(kCli2Csr_LoginRequest, kLoginRequestFields);
|
||||
|
||||
const NetMsg kNetMsg_Csr2Cli_PingReply = NET_MSG(kCsr2Cli_PingReply, kPingReplyFields);
|
||||
const NetMsg kNetMsg_Csr2Cli_RegisterReply = NET_MSG(kCsr2Cli_RegisterReply, kRegisterReplyFields);
|
||||
const NetMsg kNetMsg_Csr2Cli_LoginReply = NET_MSG(kCsr2Cli_LoginReply, kLoginReplyFields);
|
||||
|
@ -1,178 +0,0 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Additional permissions under GNU GPL version 3 section 7
|
||||
|
||||
If you modify this Program, or any covered work, by linking or
|
||||
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
|
||||
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
|
||||
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
|
||||
(or a modified version of those libraries),
|
||||
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
|
||||
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
|
||||
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
|
||||
licensors of this Program grant you additional
|
||||
permission to convey the resulting work. Corresponding Source for a
|
||||
non-source form of such a combination shall include the source code for
|
||||
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
|
||||
work.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
/*****************************************************************************
|
||||
*
|
||||
* $/Plasma20/Sources/Plasma/NucleusLib/pnNetProtocol/Private/Protocols/Cli2Csr/pnNpCli2Csr.h
|
||||
*
|
||||
***/
|
||||
|
||||
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNNETPROTOCOL_PRIVATE_PROTOCOLS_CLI2CSR_PNNPCLI2CSR_H
|
||||
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnNetProtocol/Private/Protocols/Cli2Csr/pnNpCli2Csr.h included more than once"
|
||||
#endif
|
||||
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNNETPROTOCOL_PRIVATE_PROTOCOLS_CLI2CSR_PNNPCLI2CSR_H
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* kNetProtocolCli2Csr message ids
|
||||
*
|
||||
***/
|
||||
|
||||
// Because SrvCsr must remain backward compatible with all client builds,
|
||||
// the following enum values may never change under any circumstances.
|
||||
|
||||
//============================================================================
|
||||
// Cli2Csr
|
||||
|
||||
enum {
|
||||
// Misc
|
||||
kCli2Csr_PingRequest = 0,
|
||||
// Encrypt
|
||||
kCli2Csr_RegisterRequest = 1,
|
||||
// Login
|
||||
kCli2Csr_LoginRequest = 2,
|
||||
// Patch
|
||||
kCli2Csr_PatchRequest = 3,
|
||||
|
||||
kNumCli2CsrMessages
|
||||
};
|
||||
COMPILER_ASSERT_HEADER(Cli2Scr, kNumCli2CsrMessages <= (uint16_t)-1);
|
||||
|
||||
|
||||
//============================================================================
|
||||
// Csr2Cli
|
||||
|
||||
enum {
|
||||
// Misc
|
||||
kCsr2Cli_PingReply = 0,
|
||||
// Encrypt
|
||||
kCsr2Cli_RegisterReply = 1,
|
||||
// Login
|
||||
kCsr2Cli_LoginReply = 2,
|
||||
// Patch
|
||||
kCli2Csr_PatchReply = 3,
|
||||
|
||||
kNumCsr2CliMessages
|
||||
};
|
||||
COMPILER_ASSERT_HEADER(Cli2Scr, kNumCsr2CliMessages <= (uint16_t)-1);
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* Networked structures
|
||||
*
|
||||
***/
|
||||
#pragma pack(push,1)
|
||||
|
||||
//============================================================================
|
||||
// Connect packet
|
||||
|
||||
struct Cli2Csr_ConnData {
|
||||
uint32_t dataBytes;
|
||||
};
|
||||
struct Cli2Csr_Connect {
|
||||
AsyncSocketConnectPacket hdr;
|
||||
Cli2Csr_ConnData data;
|
||||
};
|
||||
|
||||
//============================================================================
|
||||
// Message header
|
||||
|
||||
struct Cli2Csr_MsgHeader {
|
||||
uint32_t messageId;
|
||||
uint32_t transId;
|
||||
};
|
||||
|
||||
//============================================================================
|
||||
// Cli --> Csr message structures
|
||||
|
||||
// PingRequest
|
||||
extern const NetMsg kNetMsg_Cli2Csr_PingRequest;
|
||||
struct Cli2Csr_PingRequest : Cli2Csr_MsgHeader {
|
||||
uint32_t pingTimeMs;
|
||||
uint32_t payloadBytes;
|
||||
uint8_t payload[1]; // [payloadBytes]
|
||||
};
|
||||
|
||||
// RegisterRequest
|
||||
extern const NetMsg kNetMsg_Cli2Csr_RegisterRequest;
|
||||
struct Cli2Csr_RegisterRequest : Cli2Csr_MsgHeader {
|
||||
};
|
||||
|
||||
// LoginRequest
|
||||
extern const NetMsg kNetMsg_Cli2Csr_LoginRequest;
|
||||
struct Cli2Csr_LoginRequest : Cli2Csr_MsgHeader {
|
||||
uint32_t clientChallenge;
|
||||
wchar_t csrName[kMaxAccountNameLength];
|
||||
ShaDigest challengeHash;
|
||||
};
|
||||
|
||||
|
||||
//============================================================================
|
||||
// Csr --> Cli message structures
|
||||
|
||||
// PingReply
|
||||
extern const NetMsg kNetMsg_Csr2Cli_PingReply;
|
||||
struct Csr2Cli_PingReply : Cli2Csr_MsgHeader {
|
||||
uint32_t pingTimeMs;
|
||||
uint32_t payloadBytes;
|
||||
uint8_t payload[1]; // [payloadBytes]
|
||||
};
|
||||
|
||||
// RegisterReply
|
||||
extern const NetMsg kNetMsg_Csr2Cli_RegisterReply;
|
||||
struct Csr2Cli_RegisterReply : Cli2Csr_MsgHeader {
|
||||
uint32_t serverChallenge;
|
||||
uint32_t csrBuildId; // buildId of the latest csr client
|
||||
};
|
||||
|
||||
// LoginReply
|
||||
extern const NetMsg kNetMsg_Csr2Cli_LoginReply;
|
||||
struct Csr2Cli_LoginReply : Cli2Csr_MsgHeader {
|
||||
ENetError result;
|
||||
Uuid csrId;
|
||||
uint32_t csrFlags;
|
||||
};
|
||||
|
||||
|
||||
#pragma pack(pop)
|
||||
|
@ -76,10 +76,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
# include "Protocols/Cli2Game/pnNpCli2Game.h"
|
||||
# endif
|
||||
|
||||
# ifdef USES_PROTOCOL_CLI2CSR
|
||||
# include "Protocols/Cli2Csr/pnNpCli2Csr.h"
|
||||
# endif
|
||||
|
||||
# ifdef USES_PROTOCOL_CLI2GATEKEEPER
|
||||
# include "Protocols/Cli2GateKeeper/pnNpCli2GateKeeper.h"
|
||||
# endif
|
||||
|
@ -1,15 +0,0 @@
|
||||
include_directories("../../CoreLib")
|
||||
include_directories("../../NucleusLib")
|
||||
|
||||
set(pnSimpleNet_HEADERS
|
||||
pnSimpleNet.h
|
||||
)
|
||||
|
||||
set(pnSimpleNet_SOURCES
|
||||
pnSimpleNet.cpp
|
||||
)
|
||||
|
||||
add_library(pnSimpleNet STATIC ${pnSimpleNet_HEADERS} ${pnSimpleNet_SOURCES})
|
||||
|
||||
source_group("Header Files" FILES ${pnSimpleNet_HEADERS})
|
||||
source_group("Source Files" FILES ${pnSimpleNet_SOURCES})
|
@ -1,658 +0,0 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Additional permissions under GNU GPL version 3 section 7
|
||||
|
||||
If you modify this Program, or any covered work, by linking or
|
||||
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
|
||||
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
|
||||
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
|
||||
(or a modified version of those libraries),
|
||||
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
|
||||
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
|
||||
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
|
||||
licensors of this Program grant you additional
|
||||
permission to convey the resulting work. Corresponding Source for a
|
||||
non-source form of such a combination shall include the source code for
|
||||
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
|
||||
work.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
/*****************************************************************************
|
||||
*
|
||||
* $/Plasma20/Sources/Plasma/NucleusLib/pnSimpleNet/pnSimpleNet.cpp
|
||||
*
|
||||
***/
|
||||
|
||||
#include "pnSimpleNet.h"
|
||||
#include "hsThread.h"
|
||||
|
||||
#include <list>
|
||||
#include <map>
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* Local types
|
||||
*
|
||||
***/
|
||||
|
||||
struct SimpleNetConn : AtomicRef {
|
||||
AsyncSocket sock;
|
||||
AsyncCancelId cancelId;
|
||||
uint32_t channelId;
|
||||
bool abandoned;
|
||||
struct ConnectParam * connectParam;
|
||||
|
||||
SimpleNet_MsgHeader * oversizeMsg;
|
||||
ARRAY(uint8_t) oversizeBuffer;
|
||||
};
|
||||
|
||||
struct SimpleNetChannel : AtomicRef {
|
||||
FSimpleNetOnMsg onMsg;
|
||||
FSimpleNetOnError onError;
|
||||
uint32_t channelId;
|
||||
std::list<SimpleNetConn*> conns;
|
||||
|
||||
SimpleNetChannel (uint32_t channel) : channelId(channel) { }
|
||||
~SimpleNetChannel () {
|
||||
ASSERT(!conns.size());
|
||||
}
|
||||
};
|
||||
|
||||
struct ConnectParam {
|
||||
SimpleNetChannel * channel;
|
||||
FSimpleNetOnConnect callback;
|
||||
void * param;
|
||||
|
||||
~ConnectParam () {
|
||||
if (channel)
|
||||
channel->DecRef();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* Local data
|
||||
*
|
||||
***/
|
||||
|
||||
static bool s_running;
|
||||
static hsMutex s_critsect;
|
||||
static FSimpleNetQueryAccept s_queryAccept;
|
||||
static void * s_queryAcceptParam;
|
||||
static std::map<uint32_t, SimpleNetChannel*> s_channels;
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* Local functions
|
||||
*
|
||||
***/
|
||||
|
||||
//============================================================================
|
||||
static void NotifyConnSocketConnect (SimpleNetConn * conn) {
|
||||
|
||||
conn->TransferRef("Connecting", "Connected");
|
||||
|
||||
conn->connectParam->callback(
|
||||
conn->connectParam->param,
|
||||
conn,
|
||||
kNetSuccess
|
||||
);
|
||||
|
||||
delete conn->connectParam;
|
||||
conn->connectParam = nil;
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
static void NotifyConnSocketConnectFailed (SimpleNetConn * conn) {
|
||||
|
||||
s_critsect.Lock();
|
||||
{
|
||||
std::map<uint32_t, SimpleNetChannel*>::iterator it;
|
||||
if ((it = s_channels.find(conn->channelId)) != s_channels.end()) {
|
||||
it->second->conns.remove(conn);
|
||||
}
|
||||
}
|
||||
s_critsect.Unlock();
|
||||
|
||||
conn->connectParam->callback(
|
||||
conn->connectParam->param,
|
||||
nil,
|
||||
kNetErrConnectFailed
|
||||
);
|
||||
|
||||
delete conn->connectParam;
|
||||
conn->connectParam = nil;
|
||||
|
||||
conn->DecRef("Connecting");
|
||||
conn->DecRef("Lifetime");
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
static void NotifyConnSocketDisconnect (SimpleNetConn * conn) {
|
||||
|
||||
bool abandoned;
|
||||
SimpleNetChannel* channel = nil;
|
||||
s_critsect.Lock();
|
||||
{
|
||||
abandoned = conn->abandoned;
|
||||
std::map<uint32_t, SimpleNetChannel*>::iterator it;
|
||||
if ((it = s_channels.find(conn->channelId)) != s_channels.end()) {
|
||||
channel = it->second;
|
||||
channel->IncRef();
|
||||
channel->conns.remove(conn);
|
||||
}
|
||||
}
|
||||
s_critsect.Unlock();
|
||||
|
||||
if (channel && !abandoned) {
|
||||
channel->onError(conn, kNetErrDisconnected);
|
||||
channel->DecRef();
|
||||
}
|
||||
|
||||
conn->DecRef("Connected");
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
static bool NotifyConnSocketRead (SimpleNetConn * conn, AsyncNotifySocketRead * read) {
|
||||
|
||||
SimpleNetChannel* channel = nil;
|
||||
s_critsect.Lock();
|
||||
{
|
||||
std::map<uint32_t, SimpleNetChannel*>::iterator it;
|
||||
if ((it = s_channels.find(conn->channelId)) != s_channels.end()) {
|
||||
channel = it->second;
|
||||
channel->IncRef();
|
||||
}
|
||||
}
|
||||
s_critsect.Unlock();
|
||||
|
||||
if (!channel)
|
||||
return false;
|
||||
|
||||
bool result = true;
|
||||
|
||||
const uint8_t * curr = read->buffer;
|
||||
const uint8_t * term = curr + read->bytes;
|
||||
|
||||
while (curr < term) {
|
||||
// Reading oversize msg?
|
||||
if (conn->oversizeBuffer.Count()) {
|
||||
unsigned spaceLeft = conn->oversizeMsg->messageBytes - conn->oversizeBuffer.Count();
|
||||
unsigned copyBytes = min(spaceLeft, term - curr);
|
||||
conn->oversizeBuffer.Add(curr, copyBytes);
|
||||
|
||||
curr += copyBytes;
|
||||
|
||||
// Wait until we have received the entire message
|
||||
if (copyBytes != spaceLeft)
|
||||
break;
|
||||
|
||||
// Dispatch oversize msg
|
||||
if (!channel->onMsg(conn, conn->oversizeMsg)) {
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
|
||||
conn->oversizeBuffer.SetCount(0);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Wait until we receive the entire message header
|
||||
if (term - curr < sizeof(SimpleNet_MsgHeader))
|
||||
break;
|
||||
|
||||
SimpleNet_MsgHeader * msg = (SimpleNet_MsgHeader *) read->buffer;
|
||||
|
||||
// Sanity check message size
|
||||
if (msg->messageBytes < sizeof(*msg)) {
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
|
||||
// Handle oversized messages
|
||||
if (msg->messageBytes > kAsyncSocketBufferSize) {
|
||||
|
||||
conn->oversizeBuffer.SetCount(msg->messageBytes);
|
||||
conn->oversizeMsg = (SimpleNet_MsgHeader *) conn->oversizeBuffer.Ptr();
|
||||
*conn->oversizeMsg = *msg;
|
||||
|
||||
curr += sizeof(*msg);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Wait until we have received the entire message
|
||||
const uint8_t * msgTerm = (const uint8_t *) curr + msg->messageBytes;
|
||||
if (msgTerm > term)
|
||||
break;
|
||||
curr = msgTerm;
|
||||
|
||||
// Dispatch msg
|
||||
if (!channel->onMsg(conn, msg)) {
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Return count of bytes we processed
|
||||
read->bytesProcessed = curr - read->buffer;
|
||||
|
||||
channel->DecRef();
|
||||
return result;
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
static bool AsyncNotifySocketProc (
|
||||
AsyncSocket sock,
|
||||
EAsyncNotifySocket code,
|
||||
AsyncNotifySocket * notify,
|
||||
void ** userState
|
||||
) {
|
||||
bool result = true;
|
||||
SimpleNetConn * conn;
|
||||
|
||||
switch (code) {
|
||||
case kNotifySocketListenSuccess: {
|
||||
|
||||
AsyncNotifySocketListen * listen = (AsyncNotifySocketListen *) notify;
|
||||
|
||||
const SimpleNet_ConnData & connect = *(const SimpleNet_ConnData *) listen->buffer;
|
||||
listen->bytesProcessed += sizeof(connect);
|
||||
|
||||
SimpleNetChannel* channel = nil;
|
||||
s_critsect.Lock();
|
||||
{
|
||||
std::map<uint32_t, SimpleNetChannel*>::iterator it;
|
||||
if ((it = s_channels.find(connect.channelId)) != s_channels.end()) {
|
||||
channel = it->second;
|
||||
channel->IncRef();
|
||||
}
|
||||
}
|
||||
s_critsect.Unlock();
|
||||
|
||||
if (!channel)
|
||||
break;
|
||||
|
||||
conn = NEWZERO(SimpleNetConn);
|
||||
conn->channelId = channel->channelId;
|
||||
conn->IncRef("Lifetime");
|
||||
conn->IncRef("Connected");
|
||||
conn->sock = sock;
|
||||
*userState = conn;
|
||||
|
||||
bool accepted = s_queryAccept(
|
||||
s_queryAcceptParam,
|
||||
channel->channelId,
|
||||
conn,
|
||||
listen->remoteAddr
|
||||
);
|
||||
|
||||
if (!accepted) {
|
||||
SimpleNetDisconnect(conn);
|
||||
}
|
||||
else {
|
||||
s_critsect.Lock();
|
||||
{
|
||||
channel->conns.push_back(conn);
|
||||
}
|
||||
s_critsect.Unlock();
|
||||
}
|
||||
|
||||
channel->DecRef();
|
||||
}
|
||||
break;
|
||||
|
||||
case kNotifySocketConnectSuccess: {
|
||||
conn = (SimpleNetConn *) notify->param;
|
||||
*userState = conn;
|
||||
bool abandoned;
|
||||
|
||||
s_critsect.Lock();
|
||||
{
|
||||
conn->sock = sock;
|
||||
conn->cancelId = 0;
|
||||
abandoned = conn->abandoned;
|
||||
}
|
||||
s_critsect.Unlock();
|
||||
|
||||
if (abandoned)
|
||||
AsyncSocketDisconnect(sock, true);
|
||||
else
|
||||
NotifyConnSocketConnect(conn);
|
||||
}
|
||||
break;
|
||||
|
||||
case kNotifySocketConnectFailed:
|
||||
conn = (SimpleNetConn *) notify->param;
|
||||
NotifyConnSocketConnectFailed(conn);
|
||||
break;
|
||||
|
||||
case kNotifySocketDisconnect:
|
||||
conn = (SimpleNetConn *) *userState;
|
||||
NotifyConnSocketDisconnect(conn);
|
||||
break;
|
||||
|
||||
case kNotifySocketRead:
|
||||
conn = (SimpleNetConn *) *userState;
|
||||
result = NotifyConnSocketRead(conn, (AsyncNotifySocketRead *) notify);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
static void Connect(const plNetAddress& addr, ConnectParam * cp) {
|
||||
|
||||
SimpleNetConn * conn = NEWZERO(SimpleNetConn);
|
||||
conn->channelId = cp->channel->channelId;
|
||||
conn->connectParam = cp;
|
||||
conn->IncRef("Lifetime");
|
||||
conn->IncRef("Connecting");
|
||||
|
||||
s_critsect.Lock();
|
||||
{
|
||||
cp->channel->conns.push_back(conn);
|
||||
|
||||
SimpleNet_Connect connect;
|
||||
connect.hdr.connType = kConnTypeSimpleNet;
|
||||
connect.hdr.hdrBytes = sizeof(connect.hdr);
|
||||
connect.hdr.buildId = BuildId();
|
||||
connect.hdr.buildType = BUILD_TYPE_LIVE;
|
||||
connect.hdr.branchId = BranchId();
|
||||
connect.hdr.productId = ProductId();
|
||||
connect.data.channelId = cp->channel->channelId;
|
||||
|
||||
AsyncSocketConnect(
|
||||
&conn->cancelId,
|
||||
addr,
|
||||
AsyncNotifySocketProc,
|
||||
conn,
|
||||
&connect,
|
||||
sizeof(connect)
|
||||
);
|
||||
|
||||
conn = nil;
|
||||
cp = nil;
|
||||
}
|
||||
s_critsect.Unlock();
|
||||
|
||||
delete conn;
|
||||
delete cp;
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
static void AsyncLookupCallback (
|
||||
void * param,
|
||||
const char name[],
|
||||
unsigned addrCount,
|
||||
const plNetAddress addrs[]
|
||||
) {
|
||||
ConnectParam * cp = (ConnectParam *)param;
|
||||
|
||||
if (!addrCount) {
|
||||
if (cp->callback)
|
||||
cp->callback(cp->param, nil, kNetErrNameLookupFailed);
|
||||
delete cp;
|
||||
return;
|
||||
}
|
||||
|
||||
Connect(addrs[0], (ConnectParam *)param);
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* Exported functions
|
||||
*
|
||||
***/
|
||||
|
||||
//============================================================================
|
||||
void SimpleNetInitialize () {
|
||||
|
||||
s_running = true;
|
||||
|
||||
AsyncSocketRegisterNotifyProc(
|
||||
kConnTypeSimpleNet,
|
||||
AsyncNotifySocketProc
|
||||
);
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
void SimpleNetShutdown () {
|
||||
|
||||
s_running = false;
|
||||
|
||||
ASSERT(!s_channels.size());
|
||||
|
||||
AsyncSocketUnregisterNotifyProc(
|
||||
kConnTypeSimpleNet,
|
||||
AsyncNotifySocketProc
|
||||
);
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
void SimpleNetConnIncRef (SimpleNetConn * conn) {
|
||||
|
||||
ASSERT(s_running);
|
||||
ASSERT(conn);
|
||||
|
||||
conn->IncRef();
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
void SimpleNetConnDecRef (SimpleNetConn * conn) {
|
||||
|
||||
ASSERT(s_running);
|
||||
ASSERT(conn);
|
||||
|
||||
conn->DecRef();
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
bool SimpleNetStartListening (
|
||||
FSimpleNetQueryAccept queryAccept,
|
||||
void * param
|
||||
) {
|
||||
ASSERT(s_running);
|
||||
ASSERT(queryAccept);
|
||||
ASSERT(!s_queryAccept);
|
||||
|
||||
s_queryAccept = queryAccept;
|
||||
s_queryAcceptParam = param;
|
||||
|
||||
plNetAddress addr;
|
||||
addr.SetPort(kNetDefaultSimpleNetPort);
|
||||
addr.SetAnyAddr();
|
||||
return (0 != AsyncSocketStartListening(addr, nil));
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
void SimpleNetStopListening () {
|
||||
|
||||
ASSERT(s_running);
|
||||
|
||||
plNetAddress addr;
|
||||
addr.SetPort(kNetDefaultSimpleNetPort);
|
||||
addr.SetAnyAddr();
|
||||
AsyncSocketStopListening(addr, nil);
|
||||
|
||||
s_queryAccept = nil;
|
||||
s_queryAcceptParam = nil;
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
void SimpleNetCreateChannel (
|
||||
unsigned channelId,
|
||||
FSimpleNetOnMsg onMsg,
|
||||
FSimpleNetOnError onError
|
||||
) {
|
||||
ASSERT(s_running);
|
||||
|
||||
SimpleNetChannel * channel = NEWZERO(SimpleNetChannel)(channelId);
|
||||
channel->IncRef();
|
||||
|
||||
s_critsect.Lock();
|
||||
{
|
||||
#ifdef HS_DEBUGGING
|
||||
{
|
||||
std::map<uint32_t, SimpleNetChannel*>::iterator it = s_channels.find(channelId);
|
||||
ASSERT(it == s_channels.end());
|
||||
}
|
||||
#endif
|
||||
|
||||
channel->onMsg = onMsg;
|
||||
channel->onError = onError;
|
||||
s_channels[channelId] = channel;
|
||||
channel->IncRef();
|
||||
}
|
||||
s_critsect.Unlock();
|
||||
|
||||
channel->DecRef();
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
void SimpleNetDestroyChannel (unsigned channelId) {
|
||||
|
||||
ASSERT(s_running);
|
||||
|
||||
SimpleNetChannel * channel;
|
||||
s_critsect.Lock();
|
||||
{
|
||||
std::map<uint32_t, SimpleNetChannel*>::iterator it;
|
||||
if ((it = s_channels.find(channelId)) != s_channels.end()) {
|
||||
channel = it->second;
|
||||
|
||||
while (channel->conns.size()) {
|
||||
SimpleNetConn* conn = channel->conns.front();
|
||||
SimpleNetDisconnect(conn);
|
||||
|
||||
channel->conns.pop_front();
|
||||
}
|
||||
|
||||
s_channels.erase(it);
|
||||
}
|
||||
}
|
||||
s_critsect.Unlock();
|
||||
|
||||
if (channel)
|
||||
channel->DecRef();
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
void SimpleNetStartConnecting (
|
||||
unsigned channelId,
|
||||
const char addr[],
|
||||
FSimpleNetOnConnect onConnect,
|
||||
void * param
|
||||
) {
|
||||
ASSERT(s_running);
|
||||
ASSERT(onConnect);
|
||||
|
||||
ConnectParam * cp = new ConnectParam;
|
||||
cp->callback = onConnect;
|
||||
cp->param = param;
|
||||
cp->channel = nil;
|
||||
|
||||
s_critsect.Lock();
|
||||
{
|
||||
std::map<uint32_t, SimpleNetChannel*>::iterator it;
|
||||
if ((it = s_channels.find(channelId)) != s_channels.end()) {
|
||||
cp->channel = it->second;
|
||||
cp->channel->IncRef();
|
||||
}
|
||||
}
|
||||
s_critsect.Unlock();
|
||||
|
||||
ASSERT(cp->channel);
|
||||
|
||||
// Do we need to lookup the address?
|
||||
const char* name = addr;
|
||||
while (unsigned ch = *name) {
|
||||
++name;
|
||||
if (!(isdigit(ch) || ch == L'.' || ch == L':')) {
|
||||
|
||||
AsyncCancelId cancelId;
|
||||
AsyncAddressLookupName(
|
||||
&cancelId,
|
||||
AsyncLookupCallback,
|
||||
addr,
|
||||
kNetDefaultSimpleNetPort,
|
||||
cp
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!name[0]) {
|
||||
plNetAddress netAddr(addr, kNetDefaultSimpleNetPort);
|
||||
Connect(netAddr, cp);
|
||||
}
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
void SimpleNetDisconnect (
|
||||
SimpleNetConn * conn
|
||||
) {
|
||||
ASSERT(s_running);
|
||||
ASSERT(conn);
|
||||
|
||||
s_critsect.Lock();
|
||||
{
|
||||
conn->abandoned = true;
|
||||
if (conn->sock) {
|
||||
AsyncSocketDisconnect(conn->sock, true);
|
||||
conn->sock = nil;
|
||||
}
|
||||
else if (conn->cancelId) {
|
||||
AsyncSocketConnectCancel(AsyncNotifySocketProc, conn->cancelId);
|
||||
conn->cancelId = nil;
|
||||
}
|
||||
}
|
||||
s_critsect.Unlock();
|
||||
|
||||
conn->DecRef("Lifetime");
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
void SimpleNetSend (
|
||||
SimpleNetConn * conn,
|
||||
SimpleNet_MsgHeader * msg
|
||||
) {
|
||||
ASSERT(s_running);
|
||||
ASSERT(msg);
|
||||
ASSERT(msg->messageBytes != (uint32_t)-1);
|
||||
ASSERT(conn);
|
||||
|
||||
s_critsect.Lock();
|
||||
{
|
||||
if (conn->sock)
|
||||
AsyncSocketSend(conn->sock, msg, msg->messageBytes);
|
||||
}
|
||||
s_critsect.Unlock();
|
||||
}
|
@ -1,185 +0,0 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Additional permissions under GNU GPL version 3 section 7
|
||||
|
||||
If you modify this Program, or any covered work, by linking or
|
||||
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
|
||||
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
|
||||
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
|
||||
(or a modified version of those libraries),
|
||||
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
|
||||
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
|
||||
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
|
||||
licensors of this Program grant you additional
|
||||
permission to convey the resulting work. Corresponding Source for a
|
||||
non-source form of such a combination shall include the source code for
|
||||
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
|
||||
work.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
/*****************************************************************************
|
||||
*
|
||||
* $/Plasma20/Sources/Plasma/NucleusLib/pnSimpleNet/pnSimpleNet.h
|
||||
*
|
||||
***/
|
||||
|
||||
#ifndef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNSIMPLENET_PNSIMPLENET_H
|
||||
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNSIMPLENET_PNSIMPLENET_H
|
||||
|
||||
|
||||
#include "pnUtils/pnUtils.h"
|
||||
#include "pnProduct/pnProduct.h"
|
||||
#include "pnNetBase/pnNetBase.h"
|
||||
#include "pnAsyncCore/pnAsyncCore.h"
|
||||
#include "pnNetCommon/plNetAddress.h"
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* SimpleNet:
|
||||
* - TCP only, Nagle buffered only.
|
||||
* - Asynchronous callbacks only.
|
||||
* - Not encrypted, not compressed, no transaction support.
|
||||
* - Good for trivial networked applications only. Examples include:
|
||||
* - CSR client automation by CSR tools.
|
||||
* - Bob and I (eap) talked about 3dsmax automating
|
||||
* the client for the purpose of reloading reexported
|
||||
* assets. With SimpleNet, the client could be running
|
||||
* on a separate machine than Max.
|
||||
*
|
||||
***/
|
||||
|
||||
// Because newer clients must remain compatible with older servers,
|
||||
// these values may never change.
|
||||
enum ESimpleNetChannel {
|
||||
kSimpleNetChannelNil = 0,
|
||||
kSimpleNetChannelCsr = 1,
|
||||
kSimpleNetChannelMax = 2,
|
||||
|
||||
kMaxSimpleNetChannels
|
||||
};
|
||||
COMPILER_ASSERT_HEADER(ESimpleNetChannel, kMaxSimpleNetChannels <= 0xff);
|
||||
|
||||
|
||||
//============================================================================
|
||||
// BEGIN PACKED DATA STRUCTURES
|
||||
//============================================================================
|
||||
#pragma pack(push,1)
|
||||
|
||||
//============================================================================
|
||||
// Connect packet
|
||||
|
||||
struct SimpleNet_ConnData {
|
||||
unsigned channelId;
|
||||
};
|
||||
struct SimpleNet_Connect {
|
||||
AsyncSocketConnectPacket hdr;
|
||||
SimpleNet_ConnData data;
|
||||
};
|
||||
|
||||
//============================================================================
|
||||
// Message header
|
||||
|
||||
struct SimpleNet_MsgHeader {
|
||||
private:
|
||||
uint32_t channelId;
|
||||
public:
|
||||
uint32_t messageId;
|
||||
uint32_t messageBytes;
|
||||
|
||||
SimpleNet_MsgHeader (uint32_t channelId, uint32_t messageId)
|
||||
: channelId(channelId)
|
||||
, messageId(messageId)
|
||||
#ifdef HS_DEBUGGING
|
||||
, messageBytes((uint32_t)-1)
|
||||
#endif
|
||||
{ }
|
||||
};
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* Simple Network API
|
||||
*
|
||||
***/
|
||||
|
||||
struct SimpleNetConn;
|
||||
|
||||
void SimpleNetInitialize ();
|
||||
void SimpleNetShutdown ();
|
||||
|
||||
void SimpleNetConnIncRef (SimpleNetConn * conn);
|
||||
void SimpleNetConnDecRef (SimpleNetConn * conn);
|
||||
|
||||
typedef bool (*FSimpleNetOnMsg) ( // return false to disconnect socket
|
||||
SimpleNetConn * conn,
|
||||
SimpleNet_MsgHeader * msg
|
||||
);
|
||||
typedef void (*FSimpleNetOnError) (
|
||||
SimpleNetConn * conn,
|
||||
ENetError error
|
||||
);
|
||||
typedef void (*FSimpleNetOnConnect) (
|
||||
void * param,
|
||||
SimpleNetConn * conn,
|
||||
ENetError result
|
||||
);
|
||||
typedef bool (*FSimpleNetQueryAccept) ( // return true to accept incoming connection
|
||||
void * param,
|
||||
unsigned channel,
|
||||
SimpleNetConn * conn,
|
||||
const plNetAddress& addr
|
||||
);
|
||||
|
||||
void SimpleNetCreateChannel (
|
||||
unsigned channel,
|
||||
FSimpleNetOnMsg onMsg,
|
||||
FSimpleNetOnError onError
|
||||
);
|
||||
void SimpleNetDestroyChannel (
|
||||
unsigned channel
|
||||
);
|
||||
|
||||
bool SimpleNetStartListening (
|
||||
FSimpleNetQueryAccept queryAccept,
|
||||
void * param
|
||||
);
|
||||
void SimpleNetStopListening ();
|
||||
|
||||
void SimpleNetStartConnecting (
|
||||
unsigned channel,
|
||||
const wchar_t addr[],
|
||||
FSimpleNetOnConnect onConnect,
|
||||
void * param
|
||||
);
|
||||
void SimpleNetDisconnect (
|
||||
SimpleNetConn * conn
|
||||
);
|
||||
void SimpleNetSend (
|
||||
SimpleNetConn * conn,
|
||||
SimpleNet_MsgHeader * msg
|
||||
);
|
||||
#pragma pack(pop)
|
||||
|
||||
#endif // PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNSIMPLENET_PNSIMPLENET_H
|
Reference in New Issue
Block a user