- Joined
- May 30, 2009
- Messages
- 190
- Reaction score
- 61
Hello friends, enjoy it. :8:
If you really want to use it, you must have a good knowledge on PT, programming and a knowledge on graphics.
Even though I believe that almost no one can use it, I hope you can use it for study and take some knowledge.
If you really want to understand how everything was made, you can check the commits from code, since I am sharing the source with the git files included.
Thanks for #Cainankenji and #slave (me) for this source.
Also you can thank me reading my last posts and giving a reaction on it.
Handle a Network Message
The first thing you need to do to handle a Network Message, it is define an unique OpCode as identifier for this Network Message. This OpCode will be used to identify the Network Message through Network Socket and know which data struct should be used, which functions will handle it etc.
You must define your OpCode in the NetworkDef.h file, inside of enum class OpCode.
Network Message Data
To define a Network Message Data, you must create a file hpp inside the directory shared/Network/Messages specific for that Message.
Handle Network Message
Remote Procedure Call
Handle a Remote Procedure Call
Calling a Remote Procedure Call
Vcpkg
- Removed all korean comments
- Common bugs fixed
- Source migrated to use x64 instead of x86
- All warnings solved (source using /w3)
- Using safer functions for memory operations
- Using Precompiled Header
- Game and Server in different source files (same project)
- Removed unused code and files
- Source files organized in folders
- Graphics Rendering rewrote and refactored to use Directx 11
- Network rewrote to use SLikeNet library (UDP + Messages Stream etc)
- Removed transformed vertices from rendering
- Some rendering stuffs using DirectxTK (fonts etc)
- All textures converted to DDS
- Source using vcpkg to manage dependencies (lua, slikenet, rmlui, dxtk)
- Source integrated with RmlUI (html rendering library)
- Source integrated with Github actions to validate commits automatically
- Input subsytem using DXTK
- Network messages handler (handle and process your network messages dynamically)
- Cursor rendering using Windows API
- Network remote procedure call system (call a function with custom arguments over network)
- Network properties replication draft (you can check it in `feature/property-replication` branch)
If you really want to use it, you must have a good knowledge on PT, programming and a knowledge on graphics.
Even though I believe that almost no one can use it, I hope you can use it for study and take some knowledge.
If you really want to understand how everything was made, you can check the commits from code, since I am sharing the source with the git files included.
Thanks for #Cainankenji and #slave (me) for this source.
Also you can thank me reading my last posts and giving a reaction on it.
You must be registered to see links
You must be registered to see links
You must be registered to see links
You must be registered to see links
You must be registered to see links
Handle a Network Message
The first thing you need to do to handle a Network Message, it is define an unique OpCode as identifier for this Network Message. This OpCode will be used to identify the Network Message through Network Socket and know which data struct should be used, which functions will handle it etc.
You must define your OpCode in the NetworkDef.h file, inside of enum class OpCode.
Code:
enum class OpCode
{
MyCustomNetworkMessage
};
Network Message Data
To define a Network Message Data, you must create a file hpp inside the directory shared/Network/Messages specific for that Message.
Code:
#pragma once
#include "Network/NetworkDef.h"
#include "Network/NetworkMessage.h"
namespace Network
{
class MyData : public Message
{
public:
bool Loaded = false;
int Other = 0;
void Serialize(MessageStream& Message) override
{
Message.Write(Loaded);
Message.Write(Other);
}
void Deserialize(MessageStream& Message) override
{
Message.Read(Loaded);
Message.Read(Other);
}
bool Validate() override
{
// Ensure message can be handled. If this function wasn't implemented, the network message will always be handled
if (Loaded)
return true;
return false;
}
};
DECLARE_NETWORK_MESSAGE(MyData, OpCode::MyCustomNetworkMessage)
Handle Network Message
Code:
namespace Network
{
class Foo
{
public:
void Handle(Connection* Connection, MyData& Data)
{
}
void HandleWithoutData(Connection* Connection)
{
// Since we don't have a Message Data for that OpCode, we just need the Connection pointer to Handle it
}
};
ServerMessagesHandler::ServerMessagesHandler()
{
Foo foo;
HANDLE_NETWORK_MESSAGE(OpCode::MyCustomNetworkMessage, ValidationType::Authed, ProcessingType::InPlace, &Foo::Handle, foo);
HANDLE_NETWORK_MESSAGE(OpCode::MyCustomNetworkMessageWithoutData, ValidationType::Authed, ProcessingType::InPlace, &Foo::HandleWithoutData, foo);
}
}
Remote Procedure Call
Code:
namespace Network
{
class NetworkContext;
enum class RemoteProcedureCallType : char
{
Request,
Response
};
DECLARE_NETWORK_RPC(TestRPC1, int, char, std::string)
DECLARE_NETWORK_RPC(TestRPC2)
}
Handle a Remote Procedure Call
Code:
class AnyClass
{
public:
HANDLE_NETWORK_RPC(TestRPC1, AnyClass::Test)
int Test(int a, char b, std::string c)
{
return 30;
}
HANDLE_NETWORK_RPC(TestRPC2, AnyClass::Test2)
void Test2()
{
}
};
Calling a Remote Procedure Call
Code:
std::function Response = [](int Value)
{
LOG("Testing return data {0}", Value);
};
Connection->CallWithResponse<Network::TestRPC1>(Response, 30, 'a', std::string("Str"));
Code:
Connection->Call<Network::TestRPC2>();
Vcpkg
Code:
vcpkg install slikenet:x64-windows-static directxtk:x64-windows-static lua:x64-windows-static rmlui:x64-windows-static
Code:
vcpkg integrate install
Last edited: