polka dot socks
fuck man
This commit is contained in:
parent
c45cf59dac
commit
2393f94339
4 changed files with 29 additions and 13 deletions
|
@ -13,7 +13,7 @@ namespace CircleScape {
|
|||
server.Start();
|
||||
|
||||
while(true) {
|
||||
// physics and game logic processing loop
|
||||
// logic processing loop
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,8 @@ namespace Kneesocks {
|
|||
|
||||
private TcpClient Socket;
|
||||
private NetworkStream Stream;
|
||||
private string RawBuffer = "";
|
||||
private List<Frame> FrameBuffer = new List<Frame>();
|
||||
|
||||
public bool Disconnected { get; private set; } = false;
|
||||
public string DisconnectReason { get; private set; } = null;
|
||||
|
@ -55,6 +57,14 @@ namespace Kneesocks {
|
|||
Headers = conn.Headers;
|
||||
}
|
||||
|
||||
public byte[] Parse() {
|
||||
if(!Handshaked) {
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void Disconnect(string reason = null) {
|
||||
Disconnect(Frame.kClosingReason.Normal, reason);
|
||||
}
|
||||
|
|
|
@ -27,41 +27,49 @@ namespace Kneesocks {
|
|||
public int Tolerance { get; set; } = 0;
|
||||
|
||||
private int _fullThreadCount;
|
||||
private bool updateFullThreadCount = true;
|
||||
private volatile bool updateFullThreadCount = true;
|
||||
|
||||
private List<ThreadContext> Threads
|
||||
= new List<ThreadContext>();
|
||||
|
||||
private UInt64 InternalCounter = 0;
|
||||
private long InternalCounter = 0;
|
||||
private Dictionary<UInt64, Connection> Connections
|
||||
= new Dictionary<UInt64, Connection>();
|
||||
|
||||
public Pool() {
|
||||
for(var i = 0; i < InitialCount; ++i)
|
||||
CreateThread();
|
||||
CreateThread(runWithNoClients: true);
|
||||
}
|
||||
|
||||
private void IndexConnection(UInt64 id, Connection connection) {
|
||||
lock(Connections) {
|
||||
if(id == 0)
|
||||
id = InternalCounter++;
|
||||
id = (ulong)Interlocked.Increment(ref InternalCounter);
|
||||
|
||||
connection.Id = id;
|
||||
Connections.Add(id, connection);
|
||||
}
|
||||
}
|
||||
|
||||
public void InvalidateConnection(UInt64 id) {
|
||||
lock(Connections) {
|
||||
Connections.Remove(id);
|
||||
}
|
||||
}
|
||||
|
||||
public bool AddConnection(Connection connection, UInt64 id = 0) {
|
||||
lock(Threads) {
|
||||
foreach(var thread in Threads) {
|
||||
if(thread.Stack.Count < FullThreadSize) {
|
||||
thread.Stack.AddClient(connection);
|
||||
IndexConnection(id, connection);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if(MaxCount == 0 || Threads.Count < MaxCount) {
|
||||
CreateThread(connection);
|
||||
IndexConnection(id, connection);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -69,12 +77,6 @@ namespace Kneesocks {
|
|||
return false;
|
||||
}
|
||||
|
||||
public void InvalidateConnection(Connection connection) {
|
||||
lock(Connections) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void InvalidateThread(Stack<T> stackRef) {
|
||||
lock(Threads) {
|
||||
var ctx = Threads.FirstOrDefault(x => Object.ReferenceEquals(x.Stack, stackRef));
|
||||
|
|
|
@ -53,7 +53,11 @@ namespace Kneesocks {
|
|||
while(Running && (Count > 0 || RunWithNoClients)) {
|
||||
for(var i = Count - 1; i >= 0 && Running; ++i) {
|
||||
var client = Clients[i];
|
||||
client
|
||||
if(client.Handshaked) {
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue