Init
This commit is contained in:
28
Samples/ChatExample/CMakeLists.txt
Normal file
28
Samples/ChatExample/CMakeLists.txt
Normal file
@ -0,0 +1,28 @@
|
||||
#
|
||||
# This file was taken from RakNet 4.082.
|
||||
# Please see licenses/RakNet license.txt for the underlying license and related copyright.
|
||||
#
|
||||
#
|
||||
# Modified work: Copyright (c) 2017-2019, 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.
|
||||
#
|
||||
|
||||
cmake_minimum_required(VERSION 2.6)
|
||||
project("Chat Example")
|
||||
include_directories(${SLIKENET_HEADER_FILES} ./)
|
||||
add_executable(ChatServer "Server/Chat Example Server.cpp")
|
||||
add_executable(ChatClient "Client/Chat Example Client.cpp")
|
||||
|
||||
target_link_libraries(ChatServer ${SLIKENET_COMMON_LIBS})
|
||||
VSUBFOLDER(ChatServer "Samples")
|
||||
|
||||
target_link_libraries(ChatClient ${SLIKENET_COMMON_LIBS})
|
||||
VSUBFOLDER(ChatClient "Samples")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
367
Samples/ChatExample/Client/Chat Example Client.cpp
Normal file
367
Samples/ChatExample/Client/Chat Example Client.cpp
Normal file
@ -0,0 +1,367 @@
|
||||
/*
|
||||
* 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-2019, 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.
|
||||
*/
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// RakNet version 1.0
|
||||
// Filename ChatExample.cpp
|
||||
// Very basic chat engine example
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
#include "slikenet/MessageIdentifiers.h"
|
||||
|
||||
#include "slikenet/peerinterface.h"
|
||||
#include "slikenet/statistics.h"
|
||||
#include "slikenet/types.h"
|
||||
#include "slikenet/BitStream.h"
|
||||
#include "slikenet/PacketLogger.h"
|
||||
#include <assert.h>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <stdlib.h>
|
||||
#include <limits> // used for std::numeric_limits
|
||||
#include "slikenet/types.h"
|
||||
#include "slikenet/Kbhit.h"
|
||||
#ifdef _WIN32
|
||||
#include "slikenet/WindowsIncludes.h" // Sleep
|
||||
#else
|
||||
#include <unistd.h> // usleep
|
||||
#endif
|
||||
#include "slikenet/Gets.h"
|
||||
#include "slikenet/linux_adapter.h"
|
||||
#include "slikenet/osx_adapter.h"
|
||||
|
||||
#if LIBCAT_SECURITY==1
|
||||
#include "slikenet/SecureHandshake.h" // Include header for secure handshake
|
||||
#endif
|
||||
|
||||
// We copy this from Multiplayer.cpp to keep things all in one file for this example
|
||||
unsigned char GetPacketIdentifier(SLNet::Packet *p);
|
||||
|
||||
int main(void)
|
||||
{
|
||||
SLNet::RakNetStatistics *rss;
|
||||
// Pointers to the interfaces of our server and client.
|
||||
// Note we can easily have both in the same program
|
||||
SLNet::RakPeerInterface *client= SLNet::RakPeerInterface::GetInstance();
|
||||
// client->InitializeSecurity(0,0,0,0);
|
||||
//SLNet::PacketLogger packetLogger;
|
||||
//client->AttachPlugin(&packetLogger);
|
||||
|
||||
|
||||
// Holds packets
|
||||
SLNet::Packet* p;
|
||||
|
||||
// GetPacketIdentifier returns this
|
||||
unsigned char packetIdentifier;
|
||||
|
||||
// Just so we can remember where the packet came from
|
||||
bool isServer;
|
||||
|
||||
// Record the first client that connects to us so we can pass it to the ping function
|
||||
SLNet::SystemAddress clientID= SLNet::UNASSIGNED_SYSTEM_ADDRESS;
|
||||
|
||||
// Crude interface
|
||||
|
||||
// Holds user data
|
||||
char ip[64], serverPort[30], clientPort[30];
|
||||
|
||||
// A client
|
||||
isServer=false;
|
||||
|
||||
printf("This is a sample implementation of a text based chat client.\n");
|
||||
printf("Connect to the project 'Chat Example Server'.\n");
|
||||
printf("Difficulty: Beginner\n\n");
|
||||
|
||||
// Get our input
|
||||
puts("Enter the client port to listen on");
|
||||
Gets(clientPort,sizeof(clientPort));
|
||||
if (clientPort[0]==0)
|
||||
strcpy_s(clientPort, "0");
|
||||
const int intClientPort = atoi(clientPort);
|
||||
if ((intClientPort < 0) || (intClientPort > std::numeric_limits<unsigned short>::max())) {
|
||||
printf("Specified client port %d is outside valid bounds [0, %u]", intClientPort, std::numeric_limits<unsigned short>::max());
|
||||
return 1;
|
||||
}
|
||||
|
||||
puts("Enter IP to connect to");
|
||||
Gets(ip, sizeof(ip));
|
||||
client->AllowConnectionResponseIPMigration(false);
|
||||
if (ip[0]==0)
|
||||
strcpy_s(ip, "127.0.0.1");
|
||||
// strcpy_s(ip, "natpunch.slikesoft.com");
|
||||
|
||||
|
||||
puts("Enter the port to connect to");
|
||||
Gets(serverPort,sizeof(serverPort));
|
||||
if (serverPort[0]==0)
|
||||
strcpy_s(serverPort, "1234");
|
||||
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 2;
|
||||
}
|
||||
|
||||
// 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>(intClientPort),0);
|
||||
socketDescriptor.socketFamily=AF_INET;
|
||||
client->Startup(8,&socketDescriptor, 1);
|
||||
client->SetOccasionalPing(true);
|
||||
|
||||
|
||||
#if LIBCAT_SECURITY==1
|
||||
char public_key[cat::EasyHandshake::PUBLIC_KEY_BYTES];
|
||||
FILE *fp;
|
||||
fopen_s(&fp,"publicKey.dat","rb");
|
||||
fread(public_key,sizeof(public_key),1,fp);
|
||||
fclose(fp);
|
||||
|
||||
SLNet::PublicKey pk;
|
||||
pk.remoteServerPublicKey=public_key;
|
||||
pk.publicKeyMode= SLNet::PKM_USE_KNOWN_PUBLIC_KEY;
|
||||
client->Connect(ip, static_cast<unsigned short>(intServerPort), "Rumpelstiltskin", (int) strlen("Rumpelstiltskin"), &pk);
|
||||
#else
|
||||
SLNet::ConnectionAttemptResult car = client->Connect(ip, static_cast<unsigned short>(intServerPort), "Rumpelstiltskin", (int) strlen("Rumpelstiltskin"));
|
||||
RakAssert(car== SLNet::CONNECTION_ATTEMPT_STARTED);
|
||||
#endif
|
||||
|
||||
printf("\nMy IP addresses:\n");
|
||||
unsigned int i;
|
||||
for (i=0; i < client->GetNumberOfAddresses(); i++)
|
||||
{
|
||||
printf("%i. %s\n", i+1, client->GetLocalIP(i));
|
||||
}
|
||||
|
||||
printf("My GUID is %s\n", client->GetGuidFromSystemAddress(SLNet::UNASSIGNED_SYSTEM_ADDRESS).ToString());
|
||||
puts("'quit' to quit. 'stat' to show stats. 'ping' to ping.\n'disconnect' to disconnect. 'connect' to reconnnect. Type to talk.");
|
||||
|
||||
char message[2048];
|
||||
|
||||
// Loop for input
|
||||
for(;;)
|
||||
{
|
||||
// This sleep keeps RakNet responsive
|
||||
#ifdef _WIN32
|
||||
Sleep(30);
|
||||
#else
|
||||
usleep(30 * 1000);
|
||||
#endif
|
||||
|
||||
|
||||
if (_kbhit())
|
||||
{
|
||||
// Notice what is not here: something to keep our network running. It's
|
||||
// fine to block on Gets or anything we want
|
||||
// Because the network engine was painstakingly written using threads.
|
||||
Gets(message,sizeof(message));
|
||||
|
||||
if (strcmp(message, "quit")==0)
|
||||
{
|
||||
puts("Quitting.");
|
||||
break;
|
||||
}
|
||||
|
||||
if (strcmp(message, "stat")==0)
|
||||
{
|
||||
|
||||
rss=client->GetStatistics(client->GetSystemAddressFromIndex(0));
|
||||
StatisticsToString(rss, message, 2048, 2);
|
||||
printf("%s", message);
|
||||
printf("Ping=%i\n", client->GetAveragePing(client->GetSystemAddressFromIndex(0)));
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strcmp(message, "disconnect")==0)
|
||||
{
|
||||
printf("Enter index to disconnect: ");
|
||||
char str[32];
|
||||
Gets(str, sizeof(str));
|
||||
if (str[0]==0)
|
||||
strcpy_s(str,"0");
|
||||
int index = atoi(str);
|
||||
client->CloseConnection(client->GetSystemAddressFromIndex(index),false);
|
||||
printf("Disconnecting.\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strcmp(message, "shutdown")==0)
|
||||
{
|
||||
client->Shutdown(100);
|
||||
printf("Shutdown.\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strcmp(message, "startup")==0)
|
||||
{
|
||||
bool b = client->Startup(8,&socketDescriptor, 1)== SLNet::RAKNET_STARTED;
|
||||
if (b)
|
||||
printf("Started.\n");
|
||||
else
|
||||
printf("Startup failed.\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (strcmp(message, "connect")==0)
|
||||
{
|
||||
printf("Enter server ip: ");
|
||||
Gets(ip, sizeof(ip));
|
||||
if (ip[0]==0)
|
||||
strcpy_s(ip, "127.0.0.1");
|
||||
|
||||
printf("Enter server port: ");
|
||||
Gets(serverPort,sizeof(serverPort));
|
||||
if (serverPort[0]==0)
|
||||
strcpy_s(serverPort, "1234");
|
||||
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 2;
|
||||
}
|
||||
|
||||
#if LIBCAT_SECURITY==1
|
||||
bool b = client->Connect(ip, static_cast<unsigned short>(intServerPort), "Rumpelstiltskin", (int) strlen("Rumpelstiltskin"), &pk)== SLNet::CONNECTION_ATTEMPT_STARTED;
|
||||
#else
|
||||
bool b = client->Connect(ip, static_cast<unsigned short>(intServerPort), "Rumpelstiltskin", (int) strlen("Rumpelstiltskin"))== SLNet::CONNECTION_ATTEMPT_STARTED;
|
||||
#endif
|
||||
|
||||
if (b)
|
||||
puts("Attempting connection");
|
||||
else
|
||||
{
|
||||
puts("Bad connection attempt. Terminating.");
|
||||
exit(1);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strcmp(message, "ping")==0)
|
||||
{
|
||||
if (client->GetSystemAddressFromIndex(0)!= SLNet::UNASSIGNED_SYSTEM_ADDRESS)
|
||||
client->Ping(client->GetSystemAddressFromIndex(0));
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strcmp(message, "getlastping")==0)
|
||||
{
|
||||
if (client->GetSystemAddressFromIndex(0)!= SLNet::UNASSIGNED_SYSTEM_ADDRESS)
|
||||
printf("Last ping is %i\n", client->GetLastPing(client->GetSystemAddressFromIndex(0)));
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
// message is the data to send
|
||||
// strlen(message)+1 is to send the null-terminator
|
||||
// HIGH_PRIORITY doesn't actually matter here because we don't use any other priority
|
||||
// RELIABLE_ORDERED means make sure the message arrives in the right order
|
||||
client->Send(message, (int) strlen(message)+1, HIGH_PRIORITY, RELIABLE_ORDERED, 0, SLNet::UNASSIGNED_SYSTEM_ADDRESS, true);
|
||||
}
|
||||
|
||||
// Get a packet from either the server or the client
|
||||
|
||||
for (p=client->Receive(); p; client->DeallocatePacket(p), p=client->Receive())
|
||||
{
|
||||
// We got a packet, get the identifier with our handy function
|
||||
packetIdentifier = GetPacketIdentifier(p);
|
||||
|
||||
// Check if this is a network message packet
|
||||
switch (packetIdentifier)
|
||||
{
|
||||
case ID_DISCONNECTION_NOTIFICATION:
|
||||
// Connection lost normally
|
||||
printf("ID_DISCONNECTION_NOTIFICATION\n");
|
||||
break;
|
||||
case ID_ALREADY_CONNECTED:
|
||||
// Connection lost normally
|
||||
printf("ID_ALREADY_CONNECTED with guid %" PRINTF_64_BIT_MODIFIER "u\n", p->guid.g);
|
||||
break;
|
||||
case ID_INCOMPATIBLE_PROTOCOL_VERSION:
|
||||
printf("ID_INCOMPATIBLE_PROTOCOL_VERSION\n");
|
||||
break;
|
||||
case ID_REMOTE_DISCONNECTION_NOTIFICATION: // Server telling the clients of another client disconnecting gracefully. You can manually broadcast this in a peer to peer enviroment if you want.
|
||||
printf("ID_REMOTE_DISCONNECTION_NOTIFICATION\n");
|
||||
break;
|
||||
case ID_REMOTE_CONNECTION_LOST: // Server telling the clients of another client disconnecting forcefully. You can manually broadcast this in a peer to peer enviroment if you want.
|
||||
printf("ID_REMOTE_CONNECTION_LOST\n");
|
||||
break;
|
||||
case ID_REMOTE_NEW_INCOMING_CONNECTION: // Server telling the clients of another client connecting. You can manually broadcast this in a peer to peer enviroment if you want.
|
||||
printf("ID_REMOTE_NEW_INCOMING_CONNECTION\n");
|
||||
break;
|
||||
case ID_CONNECTION_BANNED: // Banned from this server
|
||||
printf("We are banned from this server.\n");
|
||||
break;
|
||||
case ID_CONNECTION_ATTEMPT_FAILED:
|
||||
printf("Connection attempt failed\n");
|
||||
break;
|
||||
case ID_NO_FREE_INCOMING_CONNECTIONS:
|
||||
// Sorry, the server is full. I don't do anything here but
|
||||
// A real app should tell the user
|
||||
printf("ID_NO_FREE_INCOMING_CONNECTIONS\n");
|
||||
break;
|
||||
|
||||
case ID_INVALID_PASSWORD:
|
||||
printf("ID_INVALID_PASSWORD\n");
|
||||
break;
|
||||
|
||||
case ID_CONNECTION_LOST:
|
||||
// Couldn't deliver a reliable packet - i.e. the other system was abnormally
|
||||
// terminated
|
||||
printf("ID_CONNECTION_LOST\n");
|
||||
break;
|
||||
|
||||
case ID_CONNECTION_REQUEST_ACCEPTED:
|
||||
// This tells the client they have connected
|
||||
printf("ID_CONNECTION_REQUEST_ACCEPTED to %s with GUID %s\n", p->systemAddress.ToString(true), p->guid.ToString());
|
||||
printf("My external address is %s\n", client->GetExternalID(p->systemAddress).ToString(true));
|
||||
break;
|
||||
case ID_CONNECTED_PING:
|
||||
case ID_UNCONNECTED_PING:
|
||||
printf("Ping from %s\n", p->systemAddress.ToString(true));
|
||||
break;
|
||||
default:
|
||||
// It's a client, so just show the message
|
||||
printf("%s\n", p->data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Be nice and let the server know we quit.
|
||||
client->Shutdown(300);
|
||||
|
||||
// We're done with the network
|
||||
SLNet::RakPeerInterface::DestroyInstance(client);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Copied from Multiplayer.cpp
|
||||
// If the first byte is ID_TIMESTAMP, then we want the 5th byte
|
||||
// Otherwise we want the 1st byte
|
||||
unsigned char GetPacketIdentifier(SLNet::Packet *p)
|
||||
{
|
||||
if (p==0)
|
||||
return 255;
|
||||
|
||||
if ((unsigned char)p->data[0] == ID_TIMESTAMP)
|
||||
{
|
||||
RakAssert(p->length > sizeof(SLNet::MessageID) + sizeof(SLNet::Time));
|
||||
return (unsigned char) p->data[sizeof(SLNet::MessageID) + sizeof(SLNet::Time)];
|
||||
}
|
||||
else
|
||||
return (unsigned char) p->data[0];
|
||||
}
|
||||
263
Samples/ChatExample/Client/Chat Example Client.vcxproj
Normal file
263
Samples/ChatExample/Client/Chat Example Client.vcxproj
Normal file
@ -0,0 +1,263 @@
|
||||
<?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>Chat Example Client</ProjectName>
|
||||
<ProjectGuid>{6DC7ADD5-3506-4922-83C8-192196B1FA2C}</ProjectGuid>
|
||||
<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;./../../../DependentExtensions;%(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)Chat Example Client.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;./../../../DependentExtensions;%(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)Chat Example Client.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;./../../../DependentExtensions;%(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;./../../../DependentExtensions;%(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;./../../../DependentExtensions;%(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;./../../../DependentExtensions;%(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="Chat Example Client.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\Lib\LibStatic\LibStatic.vcxproj">
|
||||
<Project>{6533bdae-0f0c-45e4-8fe7-add0f37fe063}</Project>
|
||||
<Private>true</Private>
|
||||
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
|
||||
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
|
||||
<LinkLibraryDependencies>true</LinkLibraryDependencies>
|
||||
<UseLibraryDependencyInputs>false</UseLibraryDependencyInputs>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Header">
|
||||
<UniqueIdentifier>{c7063128-07b3-4105-b1bb-95380e53c10e}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source">
|
||||
<UniqueIdentifier>{1a78ec27-f9b2-4b79-9fd5-169c405de542}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Chat Example Client.cpp">
|
||||
<Filter>Source</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
345
Samples/ChatExample/Server/Chat Example Server.cpp
Normal file
345
Samples/ChatExample/Server/Chat Example Server.cpp
Normal file
@ -0,0 +1,345 @@
|
||||
/*
|
||||
* 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-2019, 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.
|
||||
*/
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// RakNet version 1.0
|
||||
// Filename ChatExample.cpp
|
||||
// Very basic chat engine example
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
#include "slikenet/MessageIdentifiers.h"
|
||||
|
||||
#include "slikenet/peerinterface.h"
|
||||
#include "slikenet/statistics.h"
|
||||
#include "slikenet/types.h"
|
||||
#include "slikenet/BitStream.h"
|
||||
#include "slikenet/sleep.h"
|
||||
#include "slikenet/PacketLogger.h"
|
||||
#include <assert.h>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <stdlib.h>
|
||||
#include <limits> // used for std::numeric_limits
|
||||
#include "slikenet/Kbhit.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "slikenet/Gets.h"
|
||||
#include "slikenet/linux_adapter.h"
|
||||
#include "slikenet/osx_adapter.h"
|
||||
|
||||
#if LIBCAT_SECURITY==1
|
||||
#include "slikenet/SecureHandshake.h" // Include header for secure handshake
|
||||
#endif
|
||||
|
||||
#if defined(_CONSOLE_2)
|
||||
#include "Console2SampleIncludes.h"
|
||||
#endif
|
||||
|
||||
// We copy this from Multiplayer.cpp to keep things all in one file for this example
|
||||
unsigned char GetPacketIdentifier(SLNet::Packet *p);
|
||||
|
||||
#ifdef _CONSOLE_2
|
||||
_CONSOLE_2_SetSystemProcessParams
|
||||
#endif
|
||||
|
||||
int main(void)
|
||||
{
|
||||
// Pointers to the interfaces of our server and client.
|
||||
// Note we can easily have both in the same program
|
||||
SLNet::RakPeerInterface *server= SLNet::RakPeerInterface::GetInstance();
|
||||
SLNet::RakNetStatistics *rss;
|
||||
server->SetIncomingPassword("Rumpelstiltskin", (int)strlen("Rumpelstiltskin"));
|
||||
server->SetTimeoutTime(30000, SLNet::UNASSIGNED_SYSTEM_ADDRESS);
|
||||
// SLNet::PacketLogger packetLogger;
|
||||
// server->AttachPlugin(&packetLogger);
|
||||
|
||||
#if LIBCAT_SECURITY==1
|
||||
cat::EasyHandshake handshake;
|
||||
char public_key[cat::EasyHandshake::PUBLIC_KEY_BYTES];
|
||||
char private_key[cat::EasyHandshake::PRIVATE_KEY_BYTES];
|
||||
handshake.GenerateServerKey(public_key, private_key);
|
||||
server->InitializeSecurity(public_key, private_key, false);
|
||||
FILE *fp;
|
||||
fopen_s(&fp,"publicKey.dat","wb");
|
||||
fwrite(public_key,sizeof(public_key),1,fp);
|
||||
fclose(fp);
|
||||
#endif
|
||||
|
||||
// Holds packets
|
||||
SLNet::Packet* p;
|
||||
|
||||
// GetPacketIdentifier returns this
|
||||
unsigned char packetIdentifier;
|
||||
|
||||
// Record the first client that connects to us so we can pass it to the ping function
|
||||
SLNet::SystemAddress clientID= SLNet::UNASSIGNED_SYSTEM_ADDRESS;
|
||||
|
||||
// Holds user data
|
||||
char portstring[30];
|
||||
|
||||
printf("This is a sample implementation of a text based chat server.\n");
|
||||
printf("Connect to the project 'Chat Example Client'.\n");
|
||||
printf("Difficulty: Beginner\n\n");
|
||||
|
||||
// A server
|
||||
puts("Enter the server port to listen on");
|
||||
Gets(portstring,sizeof(portstring));
|
||||
if (portstring[0]==0)
|
||||
strcpy_s(portstring, "1234");
|
||||
const int intServerPort = atoi(portstring);
|
||||
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 1;
|
||||
}
|
||||
|
||||
puts("Starting server.");
|
||||
// Starting the server is very simple. 2 players allowed.
|
||||
// 0 means we don't care about a connectionValidationInteger, and false
|
||||
// for low priority threads
|
||||
// I am creating two socketDesciptors, to create two sockets. One using IPV6 and the other IPV4
|
||||
SLNet::SocketDescriptor socketDescriptors[2];
|
||||
socketDescriptors[0].port=static_cast<unsigned short>(intServerPort);
|
||||
socketDescriptors[0].socketFamily=AF_INET; // Test out IPV4
|
||||
socketDescriptors[1].port=static_cast<unsigned short>(intServerPort);
|
||||
socketDescriptors[1].socketFamily=AF_INET6; // Test out IPV6
|
||||
bool b = server->Startup(4, socketDescriptors, 2 )== SLNet::RAKNET_STARTED;
|
||||
server->SetMaximumIncomingConnections(4);
|
||||
if (!b)
|
||||
{
|
||||
printf("Failed to start dual IPV4 and IPV6 ports. Trying IPV4 only.\n");
|
||||
|
||||
// Try again, but leave out IPV6
|
||||
b = server->Startup(4, socketDescriptors, 1 )== SLNet::RAKNET_STARTED;
|
||||
if (!b)
|
||||
{
|
||||
puts("Server failed to start. Terminating.");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
server->SetOccasionalPing(true);
|
||||
server->SetUnreliableTimeout(1000);
|
||||
|
||||
DataStructures::List< SLNet::RakNetSocket2* > sockets;
|
||||
server->GetSockets(sockets);
|
||||
printf("Socket addresses used by RakNet:\n");
|
||||
for (unsigned int i=0; i < sockets.Size(); i++)
|
||||
{
|
||||
printf("%i. %s\n", i+1, sockets[i]->GetBoundAddress().ToString(true));
|
||||
}
|
||||
|
||||
printf("\nMy IP addresses:\n");
|
||||
for (unsigned int i=0; i < server->GetNumberOfAddresses(); i++)
|
||||
{
|
||||
SLNet::SystemAddress sa = server->GetInternalID(SLNet::UNASSIGNED_SYSTEM_ADDRESS, i);
|
||||
printf("%i. %s (LAN=%i)\n", i+1, sa.ToString(false), sa.IsLANAddress());
|
||||
}
|
||||
|
||||
printf("\nMy GUID is %s\n", server->GetGuidFromSystemAddress(SLNet::UNASSIGNED_SYSTEM_ADDRESS).ToString());
|
||||
puts("'quit' to quit. 'stat' to show stats. 'ping' to ping.\n'pingip' to ping an ip address\n'ban' to ban an IP from connecting.\n'kick to kick the first connected player.\nType to talk.");
|
||||
char message[2048];
|
||||
|
||||
// Loop for input
|
||||
for(;;)
|
||||
{
|
||||
|
||||
// This sleep keeps RakNet responsive
|
||||
RakSleep(30);
|
||||
|
||||
if (_kbhit())
|
||||
{
|
||||
// Notice what is not here: something to keep our network running. It's
|
||||
// fine to block on gets or anything we want
|
||||
// Because the network engine was painstakingly written using threads.
|
||||
Gets(message,sizeof(message));
|
||||
|
||||
if (strcmp(message, "quit")==0)
|
||||
{
|
||||
puts("Quitting.");
|
||||
break;
|
||||
}
|
||||
|
||||
if (strcmp(message, "stat")==0)
|
||||
{
|
||||
rss=server->GetStatistics(server->GetSystemAddressFromIndex(0));
|
||||
StatisticsToString(rss, message, 2048, 2);
|
||||
printf("%s", message);
|
||||
printf("Ping %i\n", server->GetAveragePing(server->GetSystemAddressFromIndex(0)));
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strcmp(message, "ping")==0)
|
||||
{
|
||||
server->Ping(clientID);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strcmp(message, "pingip")==0)
|
||||
{
|
||||
printf("Enter IP: ");
|
||||
Gets(message,sizeof(message));
|
||||
printf("Enter port: ");
|
||||
Gets(portstring,sizeof(portstring));
|
||||
if (portstring[0]==0)
|
||||
strcpy_s(portstring, "1234");
|
||||
const int intPort = atoi(portstring);
|
||||
if ((intPort < 0) || (intPort > std::numeric_limits<unsigned short>::max())) {
|
||||
printf("Specified port %d is outside valid bounds [0, %u]", intPort, std::numeric_limits<unsigned short>::max());
|
||||
continue;
|
||||
}
|
||||
server->Ping(message, static_cast<unsigned short>(intPort), false);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strcmp(message, "kick")==0)
|
||||
{
|
||||
server->CloseConnection(clientID, true, 0);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strcmp(message, "getconnectionlist")==0)
|
||||
{
|
||||
SLNet::SystemAddress systems[10];
|
||||
unsigned short numConnections=10;
|
||||
server->GetConnectionList((SLNet::SystemAddress*) &systems, &numConnections);
|
||||
for (int i=0; i < numConnections; i++)
|
||||
{
|
||||
printf("%i. %s\n", i+1, systems[i].ToString(true));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strcmp(message, "ban")==0)
|
||||
{
|
||||
printf("Enter IP to ban. You can use * as a wildcard\n");
|
||||
Gets(message,sizeof(message));
|
||||
server->AddToBanList(message);
|
||||
printf("IP %s added to ban list.\n", message);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
// Message now holds what we want to broadcast
|
||||
char message2[2048];
|
||||
// Append Server: to the message so clients know that it ORIGINATED from the server
|
||||
// All messages to all clients come from the server either directly or by being
|
||||
// relayed from other clients
|
||||
message2[0]=0;
|
||||
const static char prefix[] = "Server: ";
|
||||
strncpy_s(message2, prefix, sizeof(message2));
|
||||
strncat_s(message2, message, sizeof(message2) - strlen(prefix) - 1);
|
||||
|
||||
// message2 is the data to send
|
||||
// strlen(message2)+1 is to send the null-terminator
|
||||
// HIGH_PRIORITY doesn't actually matter here because we don't use any other priority
|
||||
// RELIABLE_ORDERED means make sure the message arrives in the right order
|
||||
// We arbitrarily pick 0 for the ordering stream
|
||||
// SLNet::UNASSIGNED_SYSTEM_ADDRESS means don't exclude anyone from the broadcast
|
||||
// true means broadcast the message to everyone connected
|
||||
server->Send(message2, (const int) strlen(message2)+1, HIGH_PRIORITY, RELIABLE_ORDERED, 0, SLNet::UNASSIGNED_SYSTEM_ADDRESS, true);
|
||||
}
|
||||
|
||||
// Get a packet from either the server or the client
|
||||
|
||||
for (p=server->Receive(); p; server->DeallocatePacket(p), p=server->Receive())
|
||||
{
|
||||
// We got a packet, get the identifier with our handy function
|
||||
packetIdentifier = GetPacketIdentifier(p);
|
||||
|
||||
// Check if this is a network message packet
|
||||
switch (packetIdentifier)
|
||||
{
|
||||
case ID_DISCONNECTION_NOTIFICATION:
|
||||
// Connection lost normally
|
||||
printf("ID_DISCONNECTION_NOTIFICATION from %s\n", p->systemAddress.ToString(true));;
|
||||
break;
|
||||
|
||||
|
||||
case ID_NEW_INCOMING_CONNECTION:
|
||||
// Somebody connected. We have their IP now
|
||||
printf("ID_NEW_INCOMING_CONNECTION from %s with GUID %s\n", p->systemAddress.ToString(true), p->guid.ToString());
|
||||
clientID=p->systemAddress; // Record the player ID of the client
|
||||
|
||||
printf("Remote internal IDs:\n");
|
||||
for (int index=0; index < MAXIMUM_NUMBER_OF_INTERNAL_IDS; index++)
|
||||
{
|
||||
SLNet::SystemAddress internalId = server->GetInternalID(p->systemAddress, index);
|
||||
if (internalId!= SLNet::UNASSIGNED_SYSTEM_ADDRESS)
|
||||
{
|
||||
printf("%i. %s\n", index+1, internalId.ToString(true));
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case ID_INCOMPATIBLE_PROTOCOL_VERSION:
|
||||
printf("ID_INCOMPATIBLE_PROTOCOL_VERSION\n");
|
||||
break;
|
||||
|
||||
case ID_CONNECTED_PING:
|
||||
case ID_UNCONNECTED_PING:
|
||||
printf("Ping from %s\n", p->systemAddress.ToString(true));
|
||||
break;
|
||||
|
||||
case ID_CONNECTION_LOST:
|
||||
// Couldn't deliver a reliable packet - i.e. the other system was abnormally
|
||||
// terminated
|
||||
printf("ID_CONNECTION_LOST from %s\n", p->systemAddress.ToString(true));;
|
||||
break;
|
||||
|
||||
default:
|
||||
// The server knows the static data of all clients, so we can prefix the message
|
||||
// With the name data
|
||||
printf("%s\n", p->data);
|
||||
|
||||
// Relay the message. We prefix the name for other clients. This demonstrates
|
||||
// That messages can be changed on the server before being broadcast
|
||||
// Sending is the same as before
|
||||
sprintf_s(message, "%s", p->data);
|
||||
server->Send(message, (const int) strlen(message)+1, HIGH_PRIORITY, RELIABLE_ORDERED, 0, p->systemAddress, true);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
server->Shutdown(300);
|
||||
// We're done with the network
|
||||
SLNet::RakPeerInterface::DestroyInstance(server);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Copied from Multiplayer.cpp
|
||||
// If the first byte is ID_TIMESTAMP, then we want the 5th byte
|
||||
// Otherwise we want the 1st byte
|
||||
unsigned char GetPacketIdentifier(SLNet::Packet *p)
|
||||
{
|
||||
if (p==0)
|
||||
return 255;
|
||||
|
||||
if ((unsigned char)p->data[0] == ID_TIMESTAMP)
|
||||
{
|
||||
RakAssert(p->length > sizeof(SLNet::MessageID) + sizeof(SLNet::Time));
|
||||
return (unsigned char) p->data[sizeof(SLNet::MessageID) + sizeof(SLNet::Time)];
|
||||
}
|
||||
else
|
||||
return (unsigned char) p->data[0];
|
||||
}
|
||||
263
Samples/ChatExample/Server/Chat Example Server.vcxproj
Normal file
263
Samples/ChatExample/Server/Chat Example Server.vcxproj
Normal file
@ -0,0 +1,263 @@
|
||||
<?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>Chat Example Server</ProjectName>
|
||||
<ProjectGuid>{B66086C8-4EBC-42F0-8E8D-AA6D5005B94D}</ProjectGuid>
|
||||
<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;./../../../DependentExtensions;%(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)Chat Example Server.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;./../../../DependentExtensions;%(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)Chat Example Server.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;./../../../DependentExtensions;%(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;./../../../DependentExtensions;%(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;./../../../DependentExtensions;%(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;./../../../DependentExtensions;%(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="Chat Example Server.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\Lib\LibStatic\LibStatic.vcxproj">
|
||||
<Project>{6533bdae-0f0c-45e4-8fe7-add0f37fe063}</Project>
|
||||
<Private>true</Private>
|
||||
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
|
||||
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
|
||||
<LinkLibraryDependencies>true</LinkLibraryDependencies>
|
||||
<UseLibraryDependencyInputs>false</UseLibraryDependencyInputs>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Header">
|
||||
<UniqueIdentifier>{345c028f-37eb-40ff-af78-b314cc0745ed}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source">
|
||||
<UniqueIdentifier>{5762d870-a022-4774-b049-94a173e6bbc1}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Chat Example Server.cpp">
|
||||
<Filter>Source</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user