[244] | 1 | using System;
|
---|
| 2 | using System.Collections.Generic;
|
---|
| 3 |
|
---|
| 4 | namespace 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 | public void SendLog (string text, string trace, UnityEngine.LogType type) {
|
---|
| 53 | foreach (WebConnection wc in connections.Values) {
|
---|
| 54 | wc.SendLog (text, trace, type);
|
---|
| 55 | }
|
---|
| 56 | }
|
---|
| 57 |
|
---|
| 58 | }
|
---|
| 59 | }
|
---|
| 60 |
|
---|