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

Last change on this file since 260 was 250, checked in by alloc, 9 years ago

Fixes 5_7_9

File size: 1.2 KB
Line 
1using System;
2using System.Collections.Generic;
3
4namespace AllocsFixes.NetConnections.Servers.Web
5{
6 public class ConnectionHandler {
7 private Web parent;
8 private Dictionary<string, WebConnection> connections = new Dictionary<string, WebConnection> ();
9
10 public ConnectionHandler (Web _parent) {
11 parent = _parent;
12 }
13
14 public WebConnection IsLoggedIn (string _sessionId, string _endpoint) {
15 if (!connections.ContainsKey (_sessionId)) {
16 return null;
17 }
18
19 WebConnection con = connections [_sessionId];
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 }
53}
54
Note: See TracBrowser for help on using the repository browser.