sharp-chat/SharpChat.Protocol.IRC/ClientCommands/QuitCommand.cs

27 lines
749 B
C#
Raw Permalink Normal View History

2022-08-30 15:05:29 +00:00
using SharpChat.Sessions;
using System;
namespace SharpChat.Protocol.IRC.ClientCommands {
public class QuitCommand : IClientCommand {
public const string NAME = @"QUIT";
public string CommandName => NAME;
public bool RequireSession => false;
private SessionManager Sessions { get; }
public QuitCommand(SessionManager sessions) {
Sessions = sessions ?? throw new ArgumentNullException(nameof(sessions));
}
public void HandleCommand(ClientCommandContext ctx) {
//string message = ctx.Arguments.ElementAtOrDefault(0);
ctx.Connection.Close();
if(ctx.Session != null)
Sessions.Destroy(ctx.Connection);
}
}
}