Added config file to server
This commit is contained in:
@@ -35,6 +35,10 @@
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.Xna.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" />
|
||||
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
@@ -50,9 +54,14 @@
|
||||
<Compile Include="Entity.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="ServerSettings.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
<None Include="packages.config" />
|
||||
<None Include="server.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\FluckyGame.Library\FluckyGame.Library.csproj">
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Threading;
|
||||
using Newtonsoft.Json;
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace FluckyGame.Server
|
||||
@@ -17,10 +19,14 @@ namespace FluckyGame.Server
|
||||
internal static Random random;
|
||||
internal static List<Entity> entities;
|
||||
|
||||
internal static ServerSettings settings;
|
||||
|
||||
private static void Main(string[] args)
|
||||
{
|
||||
Console.WriteLine("Initializing FluckyGame Server 1.0...");
|
||||
|
||||
settings = JsonConvert.DeserializeObject<ServerSettings>(File.ReadAllText("server.json"));
|
||||
|
||||
clients = new List<Client>();
|
||||
|
||||
acceptThread = new Thread(AcceptConnections);
|
||||
@@ -76,7 +82,7 @@ namespace FluckyGame.Server
|
||||
|
||||
private static void AcceptConnections()
|
||||
{
|
||||
var listener = new TcpListener(IPAddress.Any, 8001);
|
||||
var listener = new TcpListener(IPAddress.Any, settings.listeningPort);
|
||||
listener.Start();
|
||||
while (true)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
using System;
|
||||
|
||||
namespace FluckyGame.Server
|
||||
{
|
||||
internal class ServerSettings
|
||||
{
|
||||
public int listeningPort;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net461" />
|
||||
</packages>
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"listeningPort": 8001
|
||||
}
|
||||
Reference in New Issue
Block a user