diff --git a/server/server.csproj b/server/CircleScape.csproj similarity index 95% rename from server/server.csproj rename to server/CircleScape.csproj index 71106c8..8477976 100644 --- a/server/server.csproj +++ b/server/CircleScape.csproj @@ -56,8 +56,12 @@ - + + + + + diff --git a/server/Entrypoint.cs b/server/Entrypoint.cs new file mode 100644 index 0000000..b93c18f --- /dev/null +++ b/server/Entrypoint.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CircleScape { + class Entrypoint { + static void Main(string[] args) { + + } + } +} diff --git a/server/Server.cs b/server/Server.cs deleted file mode 100644 index 933bee5..0000000 --- a/server/Server.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using WebSocketSharp; -using WebSocketSharp.Server; - -namespace CircleScape { - class Connection : WebSocketBehavior { - Connection() { - - } - - protected override void OnOpen() { - if() - } - - protected override void OnMessage(MessageEventArgs e) { - - } - - protected override void OnClose(CloseEventArgs e) { - - } - } - - class Server { - static void Main(string[] args) { - - } - } -} diff --git a/server/Websocket/Connection.cs b/server/Websocket/Connection.cs new file mode 100644 index 0000000..4060324 --- /dev/null +++ b/server/Websocket/Connection.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CircleScape.Websocket { + class Connection { + + } +} diff --git a/server/Websocket/Pool.cs b/server/Websocket/Pool.cs new file mode 100644 index 0000000..4501903 --- /dev/null +++ b/server/Websocket/Pool.cs @@ -0,0 +1,63 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading; + +namespace CircleScape.Websocket { + class Pool { + private const int InitialCount = 3; + private const int InitialSize = 3; + private const int SizeGrowth = 1; + private const int MaxSize = 10; + + private int _fullThreadCount; + private bool updateFullThreadCount = true; + + private List Threads + = new List(); + private Dictionary Connections + = new Dictionary(); + + public Pool() { + for(var i = 0; i < InitialCount; ++i) { + + } + } + + public bool AddConnection(Connection connection) { + foreach(var thread in Threads) { + + } + } + + private ThreadContext CreateThread(Connection initialConnection = null) { + var stack = new Stack(true); + var ctx = new ThreadContext { + Stack = stack, + Thread = new Thread(new ThreadStart(stack.ManageStack)) + }; + + Threads.Add(ctx); + return ctx; + } + + private int FullThreadCount { + get { + if(updateFullThreadCount) { + _fullThreadCount = Math.Min( + MaxSize, + InitialSize + SizeGrowth * (Threads.Count - InitialCount) + ); + } + + return _fullThreadCount; + } + } + + class ThreadContext { + public Thread Thread { get; set; } + public Stack Stack { get; set; } + } + } +} diff --git a/server/Websocket/Server.cs b/server/Websocket/Server.cs new file mode 100644 index 0000000..93560f0 --- /dev/null +++ b/server/Websocket/Server.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CircleScape.Websocket { + class Server { + + } +} diff --git a/server/Websocket/Stack.cs b/server/Websocket/Stack.cs new file mode 100644 index 0000000..968431e --- /dev/null +++ b/server/Websocket/Stack.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net.Sockets; +using System.Text; +using System.Threading; + +namespace CircleScape.Websocket { + class Stack { + private List Clients = new List(); + private Mutex ClientsMutex = new Mutex(); + private bool RunWithNoClients = false; + + public Stack(Connection initialConnection = null) { + if(initialConnection != null) + Clients.Add(initialConnection); + } + + public Stack(bool runWithNoClients, Connection initialConnection = null) + : this(initialConnection) + { + RunWithNoClients = runWithNoClients; + } + + public bool AddClient(Connection client) { + if(!ClientsMutex.WaitOne(5000)) + return false; + + Clients.Add(client); + + ClientsMutex.ReleaseMutex(); + return true; + } + + public int ClientCount { + get { + return Clients.Count; + } + } + + // USED FOR THREADING -- DO NOT CALL + public void ManageStack() { + int clientCount = ClientCount; + + for(var i = 0; i < clientCount; ++i) + } + } +} diff --git a/server/packages.config b/server/packages.config index 972a887..865793e 100644 --- a/server/packages.config +++ b/server/packages.config @@ -5,5 +5,4 @@ - \ No newline at end of file diff --git a/server/server.sln b/server/server.sln index f5fa09e..296d8db 100644 --- a/server/server.sln +++ b/server/server.sln @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 VisualStudioVersion = 14.0.25420.1 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "server", "server.csproj", "{438DBAC1-BA37-40BB-9CCE-0FE1F23C6DC5}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CircleScape", "CircleScape.csproj", "{438DBAC1-BA37-40BB-9CCE-0FE1F23C6DC5}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution