diff --git a/ChatSharp/ChatSharp.csproj b/ChatSharp/ChatSharp.csproj index 53b81b2..8c58958 100644 --- a/ChatSharp/ChatSharp.csproj +++ b/ChatSharp/ChatSharp.csproj @@ -46,6 +46,7 @@ + @@ -56,6 +57,7 @@ + diff --git a/ChatSharp/Events/ErrorReplieEventArgs.cs b/ChatSharp/Events/ErrorReplieEventArgs.cs new file mode 100644 index 0000000..3e1e31d --- /dev/null +++ b/ChatSharp/Events/ErrorReplieEventArgs.cs @@ -0,0 +1,21 @@ +using System; +using System.Net.Sockets; + +namespace ChatSharp.Events +{ + /// + /// Raised when a IRC Error replie occurs. See rfc1459 6.1 for details. + /// + public class ErrorReplieEventArgs : EventArgs + { + /// + /// The IRC error replie that has occured. + /// + public IrcMessage Message { get; set; } + + internal ErrorReplieEventArgs(IrcMessage message) + { + Message = message; + } + } +} diff --git a/ChatSharp/Handlers/ErrorHandlers.cs b/ChatSharp/Handlers/ErrorHandlers.cs new file mode 100644 index 0000000..0fe348a --- /dev/null +++ b/ChatSharp/Handlers/ErrorHandlers.cs @@ -0,0 +1,18 @@ +using ChatSharp.Events; +using System.Linq; + +namespace ChatSharp.Handlers +{ + /// + /// + internal static class ErrorHandlers + { + /// + /// + public static void HandleError(IrcClient client, IrcMessage message) + { +// System.Diagnostics.Trace.WriteLine("HandleNoSuchNick"); + client.OnErrorReplie(new Events.ErrorReplieEventArgs(message)); + } + } +} diff --git a/ChatSharp/Handlers/MessageHandlers.cs b/ChatSharp/Handlers/MessageHandlers.cs index fd05ad3..afa0f5b 100644 --- a/ChatSharp/Handlers/MessageHandlers.cs +++ b/ChatSharp/Handlers/MessageHandlers.cs @@ -58,6 +58,15 @@ namespace ChatSharp.Handlers // Server handlers client.SetHandler("004", ServerHandlers.HandleMyInfo); client.SetHandler("005", ServerHandlers.HandleISupport); + + // Error replies rfc1459 6.1 + client.SetHandler("401", ErrorHandlers.HandleError);//ERR_NOSUCHNICK " :No such nick/channel" + client.SetHandler("402", ErrorHandlers.HandleError);//ERR_NOSUCHSERVER " :No such server" + client.SetHandler("403", ErrorHandlers.HandleError);//ERR_NOSUCHCHANNEL " :No such channel" + client.SetHandler("404", ErrorHandlers.HandleError);//ERR_CANNOTSENDTOCHAN " :Cannot send to channel" + client.SetHandler("405", ErrorHandlers.HandleError);//ERR_TOOMANYCHANNELS " :You have joined too many \ channels" + client.SetHandler("406", ErrorHandlers.HandleError);//ERR_WASNOSUCHNICK " :There was no such nickname" + client.SetHandler("407", ErrorHandlers.HandleError);//ERR_TOOMANYTARGETS " :Duplicate recipients. No message \ } public static void HandleNick(IrcClient client, IrcMessage message) diff --git a/ChatSharp/IrcClient.cs b/ChatSharp/IrcClient.cs index cdbcd35..fbbd06b 100644 --- a/ChatSharp/IrcClient.cs +++ b/ChatSharp/IrcClient.cs @@ -366,6 +366,13 @@ namespace ChatSharp } } + /// + /// + public event EventHandler ErrorReplie; + internal void OnErrorReplie(Events.ErrorReplieEventArgs e) + { + if (ErrorReplie != null) ErrorReplie(this, e); + } /// /// Raised for errors. ///