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

Last change on this file since 362 was 351, checked in by alloc, 6 years ago

Fixed game version compatibility of GamePrefs
Code style cleanup (mostly argument names)

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