Last change
on this file since 329 was 326, checked in by alloc, 6 years ago |
More cleanup, allocation improvements
|
File size:
1.1 KB
|
Rev | Line | |
---|
[244] | 1 | using System;
|
---|
| 2 | using System.Collections.Generic;
|
---|
| 3 |
|
---|
[325] | 4 | namespace AllocsFixes.NetConnections.Servers.Web {
|
---|
[244] | 5 | public class ConnectionHandler {
|
---|
[325] | 6 | private readonly Dictionary<string, WebConnection> connections = new Dictionary<string, WebConnection> ();
|
---|
[244] | 7 |
|
---|
| 8 | public WebConnection IsLoggedIn (string _sessionId, string _endpoint) {
|
---|
| 9 | if (!connections.ContainsKey (_sessionId)) {
|
---|
| 10 | return null;
|
---|
| 11 | }
|
---|
| 12 |
|
---|
| 13 | WebConnection con = connections [_sessionId];
|
---|
[325] | 14 |
|
---|
[244] | 15 | // if (con.Age.TotalMinutes > parent.sessionTimeoutMinutes) {
|
---|
| 16 | // connections.Remove (_sessionId);
|
---|
| 17 | // return null;
|
---|
| 18 | // }
|
---|
| 19 |
|
---|
| 20 | if (con.Endpoint != _endpoint) {
|
---|
| 21 | connections.Remove (_sessionId);
|
---|
| 22 | return null;
|
---|
| 23 | }
|
---|
| 24 |
|
---|
| 25 | con.UpdateUsage ();
|
---|
| 26 |
|
---|
| 27 | return con;
|
---|
| 28 | }
|
---|
| 29 |
|
---|
| 30 | public void LogOut (string _sessionId) {
|
---|
| 31 | connections.Remove (_sessionId);
|
---|
| 32 | }
|
---|
| 33 |
|
---|
| 34 | public WebConnection LogIn (ulong _steamId, string _endpoint) {
|
---|
| 35 | string sessionId = Guid.NewGuid ().ToString ();
|
---|
| 36 | WebConnection con = new WebConnection (sessionId, _endpoint, _steamId);
|
---|
| 37 | connections.Add (sessionId, con);
|
---|
| 38 | return con;
|
---|
| 39 | }
|
---|
| 40 |
|
---|
| 41 | public void SendLine (string line) {
|
---|
| 42 | foreach (WebConnection wc in connections.Values) {
|
---|
| 43 | wc.SendLine (line);
|
---|
| 44 | }
|
---|
| 45 | }
|
---|
| 46 | }
|
---|
[325] | 47 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.