From 9747851172922593fc88a0a65879133ff74f5667 Mon Sep 17 00:00:00 2001 From: Lewis Hazell Date: Sun, 23 May 2021 18:16:32 +0200 Subject: [PATCH] Network: Pass log directly into SocketListener constructor. task: #12 --- cmpctircd/SocketListener.cs | 3 ++- cmpctircd/SocketListenerFactory.cs | 9 ++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/cmpctircd/SocketListener.cs b/cmpctircd/SocketListener.cs index 787ecc0..22351b4 100644 --- a/cmpctircd/SocketListener.cs +++ b/cmpctircd/SocketListener.cs @@ -26,7 +26,8 @@ public class SocketListener { public int ServerCount = 0; public int AuthServerCount = 0; - public SocketListener(IRCd ircd, SocketElement info) { + public SocketListener(Log log, IRCd ircd, SocketElement info) { + this.log = log ?? throw new ArgumentNullException(nameof(log)); this._ircd = ircd; this.Info = info; _listener = new TcpListener(info.Host, info.Port); diff --git a/cmpctircd/SocketListenerFactory.cs b/cmpctircd/SocketListenerFactory.cs index a1200a9..bf9575b 100644 --- a/cmpctircd/SocketListenerFactory.cs +++ b/cmpctircd/SocketListenerFactory.cs @@ -1,9 +1,16 @@ using cmpctircd.Configuration; +using System; namespace cmpctircd { public class SocketListenerFactory : ISocketListenerFactory { + private readonly Log log; + + public SocketListenerFactory(Log log) { + this.log = log ?? throw new ArgumentNullException(nameof(log)); + } + public SocketListener CreateSocketListener(IRCd ircd, SocketElement config) { - return new SocketListener(ircd, config); + return new SocketListener(log, ircd, config); } } }