source: binary-improvements/MapRendering/Web/ConnectionHandler.cs@ 328

Last change on this file since 328 was 326, checked in by alloc, 6 years ago

More cleanup, allocation improvements

File size: 1.1 KB
Line 
1using System;
2using System.Collections.Generic;
3
4namespace AllocsFixes.NetConnections.Servers.Web {
5 public class ConnectionHandler {
6 private readonly Dictionary<string, WebConnection> connections = new Dictionary<string, WebConnection> ();
7
8 public WebConnection IsLoggedIn (string _sessionId, string _endpoint) {
9 if (!connections.ContainsKey (_sessionId)) {
10 return null;
11 }
12
13 WebConnection con = connections [_sessionId];
14
15// if (con.Age.TotalMinutes > parent.sessionTimeoutMinutes) {
16// connections.Remove (_sessionId);
17// return null;
18// }
19
20 if (con.Endpoint != _endpoint) {
21 connections.Remove (_sessionId);
22 return null;
23 }
24
25 con.UpdateUsage ();
26
27 return con;
28 }
29
30 public void LogOut (string _sessionId) {
31 connections.Remove (_sessionId);
32 }
33
34 public WebConnection LogIn (ulong _steamId, string _endpoint) {
35 string sessionId = Guid.NewGuid ().ToString ();
36 WebConnection con = new WebConnection (sessionId, _endpoint, _steamId);
37 connections.Add (sessionId, con);
38 return con;
39 }
40
41 public void SendLine (string line) {
42 foreach (WebConnection wc in connections.Values) {
43 wc.SendLine (line);
44 }
45 }
46 }
47}
Note: See TracBrowser for help on using the repository browser.