init commit over here
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
The servers default port is 25566
|
||||
|
||||
|
||||
TCPServer.cs
|
||||
Void TCPServer() Initilizes the server object on the default game port of 25566
|
||||
Void SendAll(string Data) Send data to all the clients
|
||||
Event onReceived Fires when data is received from a client
|
||||
|
||||
TCPClient.cs
|
||||
Void TCPClient(String ServerIP) Initilizes the client object
|
||||
Void Send(String Data) Sends data to the server
|
||||
Event onReceived Fires when data is received from the server
|
||||
|
||||
UDPClient.cs
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 6.3 MiB |
@@ -0,0 +1,33 @@
|
||||
using MistoxServer;
|
||||
using System;
|
||||
|
||||
namespace MistoxHolePunch {
|
||||
class HelpDocumentation {
|
||||
|
||||
public static string HelpText = @"
|
||||
-------------- Help Page for Mistox Game Server --------------
|
||||
|
||||
Usage: MistServer ServerIP [Command] [Options]
|
||||
|
||||
Command Linux Style Command Meaning
|
||||
/c -c Start The Client
|
||||
/s -s Start The Server
|
||||
|
||||
ServerOptions
|
||||
/s -s [options]
|
||||
/p -p The port that will be used for the server [Includes {port} + 1]
|
||||
/a -a Uses the Athoratative model for the server
|
||||
|
||||
ClientOptions
|
||||
/c -c [options]
|
||||
/h -h The Hostname or IP of the server
|
||||
/p -p The port of the server
|
||||
|
||||
Examples:
|
||||
MistServer.exe /c 127.0.0.1 /p 25550 /u Mistox Start the client connecting to server 127.0.0.1 using port 25550
|
||||
MistServer.exe /c 127.0.0.1 Start the client connecting to server 127.0.0.1 using port 25567
|
||||
MistServer.exe /s Start the server
|
||||
"
|
||||
;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<StartupObject>MistoxHolePunch.Program</StartupObject>
|
||||
<PackageId>Mistox Game Server</PackageId>
|
||||
<Authors>Mistox</Authors>
|
||||
<Company>Mistox.net</Company>
|
||||
<Product>Mistox Game Server</Product>
|
||||
<Description>Game Server for Mistox Games and partners</Description>
|
||||
<SignAssembly>false</SignAssembly>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||
<ErrorReport>none</ErrorReport>
|
||||
<DebugType>none</DebugType>
|
||||
<DebugSymbols>false</DebugSymbols>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\MistoxServer\MistServerModule.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<_LastSelectedProfileId>F:\Users\Derek\Desktop\GameServerStandard\CLI\Properties\PublishProfiles\FolderProfile.pubxml</_LastSelectedProfileId>
|
||||
<ActiveDebugProfile>MistServer</ActiveDebugProfile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<DebuggerFlavor>ProjectDebugger</DebuggerFlavor>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
+114
@@ -0,0 +1,114 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using MistoxServer;
|
||||
|
||||
namespace MistoxHolePunch {
|
||||
class Program {
|
||||
|
||||
static IMistoxServer serverObj;
|
||||
static bool running = true;
|
||||
|
||||
void onConnected( object sender, EventArgs e ) {
|
||||
// sender and e are always null
|
||||
// put connected functions in here
|
||||
}
|
||||
|
||||
void slowReceive( object obj, EventArgs e ) {
|
||||
if ( serverObj is ServerInterface ) {
|
||||
// If ServerMode is passive obj is byte[] and Send takes in byte[]
|
||||
// If Servermode is Athoritiative obj is the Class type sent and Send takes in any Class type except generic object
|
||||
|
||||
// Check to make sure data is correct before relaying
|
||||
// Also perform server specific checks in here
|
||||
// IE player didnt teleport or is shooting from 20 feet from his body
|
||||
serverObj.Send( obj, SendType.SlowUpdate );
|
||||
}
|
||||
Console.Write( "Received TCP : " );
|
||||
Console.WriteLine( obj );
|
||||
}
|
||||
|
||||
void fastReceive( object obj, EventArgs e ) {
|
||||
if( serverObj is ServerInterface ) {
|
||||
// If ServerMode is passive obj is byte[] and Send takes in byte[]
|
||||
// If Servermode is Athoritiative obj is the Class type sent and Send takes in any Class type except generic object
|
||||
|
||||
// Check to make sure data is correct before relaying
|
||||
// Also perform server specific checks in here
|
||||
// IE player didnt teleport or is shooting from 20 feet from his body
|
||||
serverObj.Send( obj, SendType.FastUpdate );
|
||||
}
|
||||
Console.Write( "Received UDP : " );
|
||||
Console.WriteLine( obj );
|
||||
}
|
||||
|
||||
void onDisconnected( object sender, EventArgs e ) {
|
||||
// sender and e are always null
|
||||
// put disconnected functions in here
|
||||
}
|
||||
|
||||
static string host = "example.com";
|
||||
static int port = 7300;
|
||||
static ServerMode mode = ServerMode.Passive;
|
||||
|
||||
async Task RunServer() {
|
||||
serverObj = mServer.newServer( Convert.ToInt32( port ), mode );
|
||||
serverObj.onConnected += onConnected;
|
||||
serverObj.onSlowReceive += slowReceive;
|
||||
serverObj.onFastReceive += fastReceive;
|
||||
serverObj.onDisconnected += onDisconnected;
|
||||
while ( running ) {
|
||||
// Stop this thread for 1 second so the CPU isnt 100%
|
||||
// All the real work is on different threads
|
||||
// While loop needs to exist so our main thread doesnt close
|
||||
await Task.Delay( 1000 );
|
||||
}
|
||||
}
|
||||
|
||||
async Task RunClient() {
|
||||
serverObj = mServer.newClient( host, Convert.ToInt32( port ) );
|
||||
serverObj.onConnected += onConnected;
|
||||
serverObj.onSlowReceive += slowReceive;
|
||||
serverObj.onFastReceive += fastReceive;
|
||||
serverObj.onDisconnected += onDisconnected;
|
||||
while( running ) {
|
||||
// Stop this thread for 1 second so the CPU isnt 100%
|
||||
// All the real work is on different threads
|
||||
// While loop needs to exist so our main thread doesnt close
|
||||
await Task.Delay( 1000 );
|
||||
}
|
||||
}
|
||||
|
||||
static async Task Main(string[] args) {
|
||||
string Task = args.Length > 0 ? args[0].ToLower() : null;
|
||||
|
||||
for( int i = 0; i < args.Length; i++ ) {
|
||||
string cur = args[i].ToLower();
|
||||
if( cur == "/h" || cur == "-h" ) {
|
||||
host = args [i + 1];
|
||||
} else if( cur == "/p" || cur == "-p" ) {
|
||||
port = Convert.ToInt32( args [i + 1] );
|
||||
} else if( cur == "/a" || cur == "-a" ) {
|
||||
mode = ServerMode.Authoritative;
|
||||
}
|
||||
}
|
||||
|
||||
if (Task == "/?" || Task == "--help") {
|
||||
Console.WriteLine(HelpDocumentation.HelpText);
|
||||
} else if (Task == "/s" || Task == "-s") {
|
||||
Program prog = new Program();
|
||||
await prog.RunServer();
|
||||
} else if (Task == "/c" || Task == "-c") {
|
||||
Program prog = new Program();
|
||||
await prog.RunClient();
|
||||
} else {
|
||||
host = "example.com";
|
||||
port = 1500;
|
||||
Program prog = new Program();
|
||||
//prog.RunClient();
|
||||
await prog.RunServer();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
https://go.microsoft.com/fwlink/?LinkID=208121.
|
||||
-->
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Any CPU</Platform>
|
||||
<PublishDir>F:\Users\Derek\Desktop</PublishDir>
|
||||
<PublishProtocol>FileSystem</PublishProtocol>
|
||||
<_TargetId>Folder</_TargetId>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<RuntimeIdentifier>linux-x64</RuntimeIdentifier>
|
||||
<SelfContained>true</SelfContained>
|
||||
<PublishSingleFile>true</PublishSingleFile>
|
||||
<PublishTrimmed>true</PublishTrimmed>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
https://go.microsoft.com/fwlink/?LinkID=208121.
|
||||
-->
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<History>True|2023-12-26T22:53:03.7982931Z;True|2023-12-25T20:43:03.3448404-08:00;True|2023-12-25T20:38:14.9173619-08:00;True|2023-12-25T15:49:11.8551513-08:00;True|2023-12-25T15:43:58.6114277-08:00;True|2023-12-25T13:38:16.4384268-08:00;True|2023-12-25T13:05:11.8207105-08:00;True|2023-12-25T12:52:06.9027395-08:00;True|2023-12-25T12:49:31.5840138-08:00;True|2023-12-25T12:44:52.1638218-08:00;True|2023-12-25T12:44:04.8184020-08:00;True|2023-12-25T12:23:48.6142003-08:00;True|2023-12-25T12:19:14.4957590-08:00;True|2023-12-25T12:15:47.1143818-08:00;True|2023-12-25T12:01:00.8637339-08:00;</History>
|
||||
<LastFailureDetails />
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user