This commit is contained in:
2025-11-24 14:19:51 +05:30
commit f5c1412b28
6734 changed files with 1527575 additions and 0 deletions

View File

@ -0,0 +1,14 @@
#
# This file was taken from RakNet 4.082 without any modifications.
# Please see licenses/RakNet license.txt for the underlying license and related copyright.
#
cmake_minimum_required(VERSION 2.6)
GETCURRENTFOLDER()
STANDARDSUBPROJECT(${current_folder})

View File

@ -0,0 +1,260 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug - Unicode|Win32">
<Configuration>Debug - Unicode</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release - Unicode|Win32">
<Configuration>Release - Unicode</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Retail - Unicode|Win32">
<Configuration>Retail - Unicode</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Retail|Win32">
<Configuration>Retail</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectName>RelayPluginTest</ProjectName>
<ProjectGuid>{681EA0B1-C533-4C0D-9790-D65E52D1463D}</ProjectGuid>
<RootNamespace>RelayPluginTest</RootNamespace>
<Keyword>Win32Proj</Keyword>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Retail|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release - Unicode|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Retail - Unicode|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug - Unicode|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Retail|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release - Unicode|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Retail - Unicode|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug - Unicode|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</OutDir>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug - Unicode|Win32'">$(Configuration)\</OutDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug - Unicode|Win32'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</OutDir>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Retail|Win32'">$(Configuration)\</OutDir>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release - Unicode|Win32'">$(Configuration)\</OutDir>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Retail - Unicode|Win32'">$(Configuration)\</OutDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Retail|Win32'">false</LinkIncremental>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release - Unicode|Win32'">false</LinkIncremental>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Retail - Unicode|Win32'">false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>./../../Source/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<AdditionalDependencies>./../../Lib/SLikeNet_LibStatic_Debug_Win32.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>$(OutDir)RelayPluginTest.pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<DataExecutionPrevention>
</DataExecutionPrevention>
<TreatLinkerWarningAsErrors>true</TreatLinkerWarningAsErrors>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug - Unicode|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>./../../Source/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<AdditionalDependencies>./../../Lib/SLikeNet_LibStatic_Debug - Unicode_Win32.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>$(OutDir)RelayPluginTest.pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<DataExecutionPrevention>
</DataExecutionPrevention>
<TreatLinkerWarningAsErrors>true</TreatLinkerWarningAsErrors>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<AdditionalIncludeDirectories>./../../Source/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError>
<MinimalRebuild>true</MinimalRebuild>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<AdditionalDependencies>./../../Lib/SLikeNet_LibStatic_Release_Win32.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<DataExecutionPrevention>
</DataExecutionPrevention>
<TreatLinkerWarningAsErrors>true</TreatLinkerWarningAsErrors>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Retail|Win32'">
<ClCompile>
<AdditionalIncludeDirectories>./../../Source/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;WIN32;_RETAIL;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError>
<MinimalRebuild>true</MinimalRebuild>
<BufferSecurityCheck>false</BufferSecurityCheck>
</ClCompile>
<Link>
<AdditionalDependencies>./../../Lib/SLikeNet_LibStatic_Retail_Win32.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<DataExecutionPrevention>
</DataExecutionPrevention>
<TreatLinkerWarningAsErrors>true</TreatLinkerWarningAsErrors>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release - Unicode|Win32'">
<ClCompile>
<AdditionalIncludeDirectories>./../../Source/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError>
<MinimalRebuild>true</MinimalRebuild>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<AdditionalDependencies>./../../Lib/SLikeNet_LibStatic_Release - Unicode_Win32.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<DataExecutionPrevention>
</DataExecutionPrevention>
<TreatLinkerWarningAsErrors>true</TreatLinkerWarningAsErrors>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Retail - Unicode|Win32'">
<ClCompile>
<AdditionalIncludeDirectories>./../../Source/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;WIN32;_RETAIL;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError>
<MinimalRebuild>true</MinimalRebuild>
<BufferSecurityCheck>false</BufferSecurityCheck>
</ClCompile>
<Link>
<AdditionalDependencies>./../../Lib/SLikeNet_LibStatic_Retail - Unicode_Win32.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<DataExecutionPrevention>
</DataExecutionPrevention>
<TreatLinkerWarningAsErrors>true</TreatLinkerWarningAsErrors>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="main.cpp" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Lib\LibStatic\LibStatic.vcxproj">
<Project>{6533bdae-0f0c-45e4-8fe7-add0f37fe063}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@ -0,0 +1,291 @@
/*
* Original work: Copyright (c) 2014, Oculus VR, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* RakNet License.txt file in the licenses directory of this source tree. An additional grant
* of patent rights can be found in the RakNet Patents.txt file in the same directory.
*
*
* Modified work: Copyright (c) 2016-2018, SLikeSoft UG (haftungsbeschränkt)
*
* This source code was modified by SLikeSoft. Modifications are licensed under the MIT-style
* license found in the license.txt file in the root directory of this source tree.
*/
#include "slikenet/peerinterface.h"
#include "slikenet/sleep.h"
#include "slikenet/RelayPlugin.h"
#include "slikenet/Gets.h"
#include "slikenet/Kbhit.h"
#include "slikenet/BitStream.h"
#include "slikenet/MessageIdentifiers.h"
#include "slikenet/linux_adapter.h"
#include "slikenet/osx_adapter.h"
#include <limits> // used for std::numeric_limits
using namespace SLNet;
int main(void)
{
printf("Tests the RelayPlugin as a server.\n");
printf("Difficulty: Beginner\n\n");
char str[64], str2[64];
SLNet::RakPeerInterface *peer= SLNet::RakPeerInterface::GetInstance();
RelayPlugin *relayPlugin = RelayPlugin::GetInstance();
peer->AttachPlugin(relayPlugin);
// Get our input
char ip[64], serverPort[30], listenPort[30];
puts("Enter the port to listen on");
Gets(listenPort,sizeof(listenPort));
if (listenPort[0]==0)
strcpy_s(listenPort, "1234");
const int intListenPort = atoi(listenPort);
if ((intListenPort < 0) || (intListenPort > std::numeric_limits<unsigned short>::max())) {
printf("Specified listen port %d is outside valid bounds [0, %u]", intListenPort, std::numeric_limits<unsigned short>::max());
return 2;
}
relayPlugin->SetAcceptAddParticipantRequests(true);
// Connecting the client is very simple. 0 means we don't care about
// a connectionValidationInteger, and false for low priority threads
SLNet::SocketDescriptor socketDescriptor(static_cast<unsigned short>(intListenPort),0);
socketDescriptor.socketFamily=AF_INET;
peer->Startup(8,&socketDescriptor, 1);
peer->SetMaximumIncomingConnections(8);
peer->SetOccasionalPing(true);
puts("Enter IP to connect to, or enter for none");
Gets(ip, sizeof(ip));
peer->AllowConnectionResponseIPMigration(false);
if (ip[0])
{
puts("Enter the port to connect to");
Gets(serverPort,sizeof(serverPort));
if (serverPort[0]==0)
strcpy_s(serverPort, "1234");
const int intServerPort = atoi(serverPort);
if ((intServerPort < 0) || (intServerPort > std::numeric_limits<unsigned short>::max())) {
printf("Specified server port %d is outside valid bounds [0, %u]", intServerPort, std::numeric_limits<unsigned short>::max());
return 3;
}
SLNET_VERIFY(peer->Connect(ip, static_cast<unsigned short>(intServerPort), 0, 0) == SLNet::CONNECTION_ATTEMPT_STARTED);
}
peer->SetTimeoutTime(30000, UNASSIGNED_SYSTEM_ADDRESS);
peer->GetGuidFromSystemAddress(UNASSIGNED_SYSTEM_ADDRESS).ToString(str, 64);
printf("My GUID is %s\n", str);
printf("(A)ddParticipantRequestFromClient\n");
printf("(R)emoveParticipantRequestFromClient\n");
printf("SendTo(P)articipant\n");
printf("(S)endGroupMessage\n");
printf("(J)oinGroupRequest\n");
printf("(L)eaveGroup\n");
printf("(G)etGroupList\n");
printf("(Q)uit\n");
char name[128];
for(;;)
{
if (_kbhit())
{
int ch = _getch();
if (ch=='a' || ch=='A')
{
printf("Enter name of participant: ");
Gets(name, sizeof(name));
if (name[0])
{
relayPlugin->AddParticipantRequestFromClient(name,peer->GetGUIDFromIndex(0));
printf("Done\n");
}
else
{
printf("Operation aborted\n");
}
}
else if (ch=='r' || ch=='R')
{
relayPlugin->RemoveParticipantRequestFromClient(peer->GetGUIDFromIndex(0));
printf("Done\n");
}
else if (ch=='p' || ch=='P')
{
printf("Enter name of participant: ");
Gets(name, sizeof(name));
if (name[0])
{
printf("Enter message to send: ");
char msg[256];
Gets(msg, sizeof(msg));
RakString msgRs = msg;
BitStream msgBs;
msgBs.WriteCompressed(msgRs);
relayPlugin->SendToParticipant(peer->GetGUIDFromIndex(0), name, &msgBs, HIGH_PRIORITY, RELIABLE_ORDERED, 0 );
printf("Done\n");
}
else
{
printf("Operation aborted\n");
}
}
else if (ch=='s' || ch=='S')
{
printf("Enter message to send: ");
char msg[256];
Gets(msg, sizeof(msg));
RakString msgRs = msg;
BitStream msgBs;
msgBs.Write(msgRs);
relayPlugin->SendGroupMessage(peer->GetGUIDFromIndex(0), &msgBs, HIGH_PRIORITY, RELIABLE_ORDERED, 0 );
printf("Done\n");
}
else if (ch=='j' || ch=='J')
{
printf("Enter group name to join: ");
char msg[256];
Gets(msg, sizeof(msg));
relayPlugin->JoinGroupRequest(peer->GetGUIDFromIndex(0), msg);
printf("Done\n");
}
else if (ch=='l' || ch=='l')
{
relayPlugin->LeaveGroup(peer->GetGUIDFromIndex(0));
printf("Done\n");
}
else if (ch=='g' || ch=='G')
{
relayPlugin->GetGroupList(peer->GetGUIDFromIndex(0));
printf("Done\n");
}
else if (ch=='q')
{
break;
}
}
Packet *packet;
for (packet=peer->Receive(); packet; peer->DeallocatePacket(packet), packet=peer->Receive())
{
packet->guid.ToString(str, 64);
packet->systemAddress.ToString(true,str2,static_cast<size_t>(64));
if (packet->data[0]==ID_NEW_INCOMING_CONNECTION)
{
printf("ID_NEW_INCOMING_CONNECTION from %s on %s\n", str, str2);
}
else if (packet->data[0]==ID_CONNECTION_REQUEST_ACCEPTED)
{
printf("ID_CONNECTION_REQUEST_ACCEPTED from %s on %s\n", str, str2);
}
else if (packet->data[0]==ID_CONNECTION_LOST)
{
printf("ID_CONNECTION_LOST from %s on %s\n", str, str2);
}
else if (packet->data[0]==ID_RELAY_PLUGIN)
{
BitStream msgRs;
RakString senderRs;
BitStream bsIn(packet->data, packet->length, false);
bsIn.IgnoreBytes(sizeof(MessageID));
RelayPluginEnums rpe;
bsIn.ReadCasted<MessageID>(rpe);
switch (rpe)
{
case RPE_MESSAGE_TO_CLIENT_FROM_SERVER:
{
RakString senderName;
bsIn.ReadCompressed(senderName);
bsIn.AlignReadToByteBoundary();
RakString dataInAsStr;
bsIn.ReadCompressed(dataInAsStr);
printf("RPE_MESSAGE_TO_CLIENT_FROM_SERVER from %s, data=%s\n", senderName.C_String(), dataInAsStr.C_String());
}
break;
case RPE_ADD_CLIENT_NOT_ALLOWED:
{
RakString senderName;
bsIn.ReadCompressed(senderName);
printf("RPE_ADD_CLIENT_NOT_ALLOWED for %s\n", senderName.C_String());
}
break;
case RPE_ADD_CLIENT_TARGET_NOT_CONNECTED:
{
RakString senderName;
bsIn.ReadCompressed(senderName);
printf("RPE_ADD_CLIENT_TARGET_NOT_CONNECTED for %s\n", senderName.C_String());
}
break;
case RPE_ADD_CLIENT_NAME_ALREADY_IN_USE:
{
RakString senderName;
bsIn.ReadCompressed(senderName);
printf("RPE_ADD_CLIENT_NAME_ALREADY_IN_USE for %s\n", senderName.C_String());
}
break;
case RPE_ADD_CLIENT_SUCCESS:
{
RakString senderName;
bsIn.ReadCompressed(senderName);
printf("RPE_ADD_CLIENT_SUCCESS for %s\n", senderName.C_String());
}
break;
case RPE_USER_ENTERED_ROOM:
{
RakString whichUser;
bsIn.ReadCompressed(whichUser);
printf("RPE_USER_ENTERED_ROOM user=%s\n", whichUser.C_String());
}
break;
case RPE_USER_LEFT_ROOM:
{
RakString whichUser;
bsIn.ReadCompressed(whichUser);
printf("RPE_USER_LEFT_ROOM user=%s\n", whichUser.C_String());
}
break;
case RPE_GROUP_MSG_FROM_SERVER:
{
RakString senderName;
bsIn.ReadCompressed(senderName);
bsIn.AlignReadToByteBoundary();
RakString dataInAsStr;
bsIn.Read(dataInAsStr);
printf("RPE_GROUP_MSG_FROM_SERVER from %s, data=%s\n", senderName.C_String(), dataInAsStr.C_String());
}
break;
case RPE_GET_GROUP_LIST_REPLY_FROM_SERVER:
{
uint16_t chatRoomsSize, usersInRoomSize;
bsIn.Read(chatRoomsSize);
RakString roomName;
printf("RPE_GET_GROUP_LIST_REPLY_FROM_SERVER %i rooms\n", chatRoomsSize);
for (uint16_t chatRoomsIdx=0; chatRoomsIdx < chatRoomsSize; chatRoomsIdx++)
{
bsIn.ReadCompressed(roomName);
bsIn.Read(usersInRoomSize);
printf("%i. %s %i users\n", chatRoomsIdx+1, roomName.C_String(), usersInRoomSize);
}
}
break;
default:
{
RakAssert(0);
}
}
}
}
RakSleep(30);
}
return 1;
}