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

Last change on this file since 361 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
RevLine 
[244]1using System;
2using System.Collections.Generic;
[332]3using System.Net;
[244]4
[325]5namespace AllocsFixes.NetConnections.Servers.Web {
[244]6 public class ConnectionHandler {
[325]7 private readonly Dictionary<string, WebConnection> connections = new Dictionary<string, WebConnection> ();
[244]8
[332]9 public WebConnection IsLoggedIn (string _sessionId, IPAddress _ip) {
[244]10 if (!connections.ContainsKey (_sessionId)) {
11 return null;
12 }
13
14 WebConnection con = connections [_sessionId];
[325]15
[244]16// if (con.Age.TotalMinutes > parent.sessionTimeoutMinutes) {
17// connections.Remove (_sessionId);
18// return null;
19// }
20
[332]21 if (!Equals (con.Endpoint, _ip)) {
22 // Fixed: Allow different clients from same NAT network
23// connections.Remove (_sessionId);
[244]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
[332]36 public WebConnection LogIn (ulong _steamId, IPAddress _ip) {
[244]37 string sessionId = Guid.NewGuid ().ToString ();
[332]38 WebConnection con = new WebConnection (sessionId, _ip, _steamId);
[244]39 connections.Add (sessionId, con);
40 return con;
41 }
42
[351]43 public void SendLine (string _line) {
[332]44 foreach (KeyValuePair<string, WebConnection> kvp in connections) {
[351]45 kvp.Value.SendLine (_line);
[244]46 }
47 }
48 }
[325]49}
Note: See TracBrowser for help on using the repository browser.