forked from connamara/quickfixn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AcceptorSocketDescriptor.cs
61 lines (54 loc) · 1.89 KB
/
AcceptorSocketDescriptor.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
using System;
using System.Collections.Generic;
using System.Net;
using QuickFix.Logger;
namespace QuickFix
{
internal class AcceptorSocketDescriptor
{
public ThreadedSocketReactor SocketReactor { get; }
public IPEndPoint Address { get; }
private readonly Dictionary<SessionID, Session> _acceptedSessions = new ();
public AcceptorSocketDescriptor(
IPEndPoint socketEndPoint,
SocketSettings socketSettings,
NonSessionLog nonSessionLog)
{
Address = socketEndPoint;
SocketReactor = new ThreadedSocketReactor(Address, socketSettings, this, nonSessionLog);
}
[Obsolete("Param 'sessionDict' is unused. Use the alt constructor without it.")]
public AcceptorSocketDescriptor(
IPEndPoint socketEndPoint,
SocketSettings socketSettings,
SettingsDictionary sessionDict,
NonSessionLog nonSessionLog) : this(socketEndPoint, socketSettings, nonSessionLog)
{ }
internal void AcceptSession(Session session)
{
lock (_acceptedSessions)
{
_acceptedSessions[session.SessionID] = session;
}
}
/// <summary>
/// Remove a session from those tied to this socket.
/// </summary>
/// <param name="sessionId">ID of session to be removed</param>
/// <returns>true if session removed, false if not found</returns>
internal bool RemoveSession(SessionID sessionId)
{
lock (_acceptedSessions)
{
return _acceptedSessions.Remove(sessionId);
}
}
internal Dictionary<SessionID, Session> GetAcceptedSessions()
{
lock (_acceptedSessions)
{
return new Dictionary<SessionID, Session>(_acceptedSessions);
}
}
}
}