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

Last change on this file since 424 was 369, checked in by alloc, 3 years ago

Preparations for A20 release
Changes usage of "SteamID" to "UserID" in console commands
Also changes a bunch of the WebAPI stuff to show / use UserIDs

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