Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 33 additions & 41 deletions QuickFIXn/AcceptorSocketDescriptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,58 +3,50 @@
using System.Net;
using QuickFix.Logger;

namespace QuickFix
{
internal class AcceptorSocketDescriptor
{
public ThreadedSocketReactor SocketReactor { get; }
public IPEndPoint Address { get; }
namespace QuickFix;

private readonly Dictionary<SessionID, Session> _acceptedSessions = new ();
internal class AcceptorSocketDescriptor
{
public ThreadedSocketReactor SocketReactor { get; }
public IPEndPoint Address { get; }

internal AcceptorSocketDescriptor(
IPEndPoint socketEndPoint,
SocketSettings socketSettings,
IQuickFixLoggerFactory loggerFactory)
{
Address = socketEndPoint;
SocketReactor = new ThreadedSocketReactor(Address, socketSettings, this, loggerFactory);
}
private readonly Dictionary<SessionID, Session> _acceptedSessions = new ();

internal AcceptorSocketDescriptor(
IPEndPoint socketEndPoint,
SocketSettings socketSettings,
SettingsDictionary sessionDict,
IQuickFixLoggerFactory nonSessionLog) : this(socketEndPoint, socketSettings, nonSessionLog)
{ }
internal AcceptorSocketDescriptor(
IPEndPoint socketEndPoint,
SocketSettings socketSettings,
IQuickFixLoggerFactory loggerFactory)
{
Address = socketEndPoint;
SocketReactor = new ThreadedSocketReactor(Address, socketSettings, this, loggerFactory);
}

internal void AcceptSession(Session session)
internal void AcceptSession(Session session)
{
lock (_acceptedSessions)
{
lock (_acceptedSessions)
{
_acceptedSessions[session.SessionID] = session;
}
_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)
/// <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)
{
lock (_acceptedSessions)
{
return _acceptedSessions.Remove(sessionId);
}
return _acceptedSessions.Remove(sessionId);
}
}

internal Dictionary<SessionID, Session> GetAcceptedSessions()
internal Dictionary<SessionID, Session> GetAcceptedSessions()
{
lock (_acceptedSessions)
{
lock (_acceptedSessions)
{
return new Dictionary<SessionID, Session>(_acceptedSessions);
}
return new Dictionary<SessionID, Session>(_acceptedSessions);
}
}
}
Loading
Loading