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

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