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

Last change on this file since 325 was 325, checked in by alloc, 8 years ago

Code style cleanup (mostly whitespace changes, enforcing braces, using cleanup)

File size: 1.2 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 private Web parent;
8
9 public ConnectionHandler (Web _parent) {
10 parent = _parent;
11 }
12
13 public WebConnection IsLoggedIn (string _sessionId, string _endpoint) {
14 if (!connections.ContainsKey (_sessionId)) {
15 return null;
16 }
17
18 WebConnection con = connections [_sessionId];
19
20// if (con.Age.TotalMinutes > parent.sessionTimeoutMinutes) {
21// connections.Remove (_sessionId);
22// return null;
23// }
24
25 if (con.Endpoint != _endpoint) {
26 connections.Remove (_sessionId);
27 return null;
28 }
29
30 con.UpdateUsage ();
31
32 return con;
33 }
34
35 public void LogOut (string _sessionId) {
36 connections.Remove (_sessionId);
37 }
38
39 public WebConnection LogIn (ulong _steamId, string _endpoint) {
40 string sessionId = Guid.NewGuid ().ToString ();
41 WebConnection con = new WebConnection (sessionId, _endpoint, _steamId);
42 connections.Add (sessionId, con);
43 return con;
44 }
45
46 public void SendLine (string line) {
47 foreach (WebConnection wc in connections.Values) {
48 wc.SendLine (line);
49 }
50 }
51 }
52}
Note: See TracBrowser for help on using the repository browser.