cinvoke-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cinvoke-svn] r142 - trunk/skorpion


From: will
Subject: [cinvoke-svn] r142 - trunk/skorpion
Date: 14 Mar 2007 02:07:50 -0400

Author: vmy
Date: 2007-03-14 02:07:49 -0400 (Wed, 14 Mar 2007)
New Revision: 142

Added:
   trunk/skorpion/IrcConnection.cs
Modified:
   trunk/skorpion/Chat.cs
   trunk/skorpion/Form1.cs
   trunk/skorpion/skorpion.cs
   trunk/skorpion/skorpion.csproj
Log:
add rudimentary IRC support

Modified: trunk/skorpion/Chat.cs
===================================================================
--- trunk/skorpion/Chat.cs      2007-01-22 03:41:02 UTC (rev 141)
+++ trunk/skorpion/Chat.cs      2007-03-14 06:07:49 UTC (rev 142)
@@ -87,8 +87,16 @@
                {
                        string text = _entryLine.ToString().Trim().Remove(0, 1);
                        if(text.Length > 0)
-                               GlobalState.Command.Execute("rcon say " + text);
-       
+                               if(text.IndexOf(".") == 0)
+                               {
+                                       text = text.Substring(1);
+                                       GlobalState.Irc.WriteLine(":" + 
RegConfig.PlayerName + "!~" + RegConfig.PlayerName + 
"@the.world.is.never.enough PRIVMSG " + GlobalState.Irc._channel + " :" + text);
+                                       GlobalState.Chat.Print("> " + text);
+                               }
+                               else
+                               {
+                                       GlobalState.Command.Execute("rcon say " 
+ text);
+                               }
                        _entryLine = new StringBuilder(_prefix);
                }
 

Modified: trunk/skorpion/Form1.cs
===================================================================
--- trunk/skorpion/Form1.cs     2007-01-22 03:41:02 UTC (rev 141)
+++ trunk/skorpion/Form1.cs     2007-03-14 06:07:49 UTC (rev 142)
@@ -98,6 +98,36 @@
                        GlobalState.Controller.takeMouseFocus();                
                }
 
+               void OnReadLine(object sender, ReadLineEventArgs e)
+               {
+                       if (e.Line.StartsWith("PING"))
+                       {
+                               string server = e.Line.Split(' ')[1];
+                               GlobalState.Irc.WriteLine("PONG "+ server, 
Priority.Critical);
+                               System.Console.WriteLine("Responded to ping at 
{0}.",
+                                       DateTime.Now.ToShortTimeString());
+                       }
+                       else
+                       {
+                               // display a prefix plus this message just like 
you would display chat from other players
+                               String line = e.Line;
+                               line = line.Substring(1);
+                               int nextColonIndex = line.IndexOf(":");
+                               if(nextColonIndex > 0)
+                               {
+                                       string nick = e.Line;
+                                       int nextBangIndex = nick.IndexOf("!");
+                                       if(nextBangIndex > 0)
+                                       {
+                                               nick = nick.Substring(1, 
nextBangIndex - 1);
+                                               line = 
line.Substring(nextColonIndex + 1);
+                                               GlobalState.Console.Print("<" + 
nick + "> " + line);
+                                               GlobalState.Chat.Print("<" + 
nick + "> " + line);
+                                       }
+                               }
+                       }
+               }
+               
                [STAThread]
                static void Main() 
                {
@@ -141,6 +171,19 @@
                                Thread t = new Thread(new 
ThreadStart(ServerState.NetServer.Start));
                                t.Start();
                        }
+
+                       if (ClientConfig.IrcStart)
+                       {
+                               // instantiate an IRC object, create its 
thread, kick it off
+                               GlobalState.Irc = new IrcConnection();
+                               GlobalState.Irc.OnReadLine += new 
ReadLineEventHandler(OnReadLine);
+                               GlobalState.Irc.Connect();
+                               
GlobalState.Irc.WriteLine(Rfc2812.Nick(RegConfig.PlayerName), 
Priority.Critical);
+                               
GlobalState.Irc.WriteLine(Rfc2812.User(RegConfig.PlayerName, 0, "one who is 
one"), Priority.Critical);
+                               
GlobalState.Irc.WriteLine(Rfc2812.Join(GlobalState.Irc._channel));
+                               Thread t = new Thread(new 
ThreadStart(GlobalState.Irc.Listen));
+                               t.Start();
+                       }
                        
                        this.Text       = "Sk0rpion";
                        this.ClientSize = new 
System.Drawing.Size(RegConfig.FormWidth, RegConfig.FormHeight);

Added: trunk/skorpion/IrcConnection.cs
===================================================================
--- trunk/skorpion/IrcConnection.cs                             (rev 0)
+++ trunk/skorpion/IrcConnection.cs     2007-03-14 06:07:49 UTC (rev 142)
@@ -0,0 +1,1914 @@
+using System;
+using System.IO;
+using System.Text;
+using System.Collections;
+using System.Threading;
+using System.Reflection;
+using System.Net.Sockets;
+using System.Text.RegularExpressions;
+using System.Runtime.Serialization;
+
+namespace skorpion
+{
+       public enum Priority
+       {
+               Low,
+               BelowMedium,
+               Medium,
+               AboveMedium,
+               High,
+               Critical
+       }
+
+       public delegate void ReadLineEventHandler(object sender, 
ReadLineEventArgs e);
+       public delegate void WriteLineEventHandler(object sender, 
WriteLineEventArgs e);
+
+       /// <summary>
+       ///
+       /// </summary>
+       public class ReadLineEventArgs : EventArgs
+       {
+               private string _Line;
+
+               public string Line
+               {
+                       get 
+                       {
+                               return _Line;
+                       }
+               }
+
+               internal ReadLineEventArgs(string line)
+               {
+                       _Line = line;
+               }
+       }
+
+       /// <summary>
+       ///
+       /// </summary>
+       public class WriteLineEventArgs : EventArgs
+       {
+               private string _Line;
+
+               public string Line
+               {
+                       get 
+                       {
+                               return _Line;
+                       }
+               }
+
+               internal WriteLineEventArgs(string line)
+               {
+                       _Line = line;
+               }
+       }
+    
+       internal class IrcTcpClient: TcpClient
+    {
+        public Socket Socket
+        {
+            get {
+                return Client;
+            }
+        }
+    }
+
+       public class IrcConnection
+       {
+               private string _serverIP = "69.16.172.2";
+               private int _serverPort = 6667;
+               public string _channel = "#pleep";
+
+               private string          _VersionNumber;
+               private string          _VersionString;
+               private string[]        _AddressList = {"localhost"};
+               private int             _CurrentAddress = 0;
+               private int             _Port = 6667;
+               private StreamReader    _Reader;
+               private StreamWriter    _Writer;
+               private ReadThread      _ReadThread;
+               private WriteThread     _WriteThread;
+               private IrcTcpClient    _TcpClient;
+               private Hashtable       _SendBuffer = 
Hashtable.Synchronized(new Hashtable());
+               private int             _SendDelay = 200;
+               private bool            _IsRegistered = false;
+               private bool            _IsConnected  = false;
+               private bool            _IsConnectionError = false;
+               private int             _ConnectTries  = 0;
+               private bool            _AutoRetry     = false;
+               private int             _AutoRetryDelay = 30;
+               private bool            _AutoReconnect = false;
+               private Encoding        _Encoding = 
Encoding.GetEncoding("ISO-8859-1");
+               //private Encoding        _Encoding = Encoding.ASCII;
+               //private Encoding        _Encoding = 
Encoding.GetEncoding(1252);
+               //private Encoding        _Encoding = Encoding.UTF8;
+               private int             _SocketReceiveTimeout  = 600;
+               private int             _SocketSendTimeout = 600;
+
+               /// <event cref="OnReadLine">
+               /// Raised when a \r\n terminated line is read from the socket
+               /// </event>
+               public event ReadLineEventHandler   OnReadLine;
+               /// <event cref="OnWriteLine">
+               /// Raised when a \r\n terminated line is written to the socket
+               /// </event>
+               public event WriteLineEventHandler  OnWriteLine;
+               /// <event cref="OnConnect">
+               /// Raised before the connect attempt
+               /// </event>
+               public event EventHandler           OnConnecting;
+               /// <event cref="OnConnect">
+               /// Raised on successful connect
+               /// </event>
+               public event EventHandler           OnConnected;
+               /// <event cref="OnConnect">
+               /// Raised before the connection is closed
+               /// </event>
+               public event EventHandler           OnDisconnecting;
+               /// <event cref="OnConnect">
+               /// Raised when the connection is closed
+               /// </event>
+               public event EventHandler           OnDisconnected;
+               /// <event cref="OnConnectionError">
+               /// Raised when the connection got into an error state
+               /// </event>
+               public event EventHandler           OnConnectionError;
+        
+               /// <summary>
+               /// When a connection error is detected this property will 
return true
+               /// </summary>
+               /// <remarks>
+               /// Thread-safe
+               /// </remarks
+               protected bool IsConnectionError
+               {
+                       get 
+                       {
+                               lock (this) 
+                               {
+                                       return _IsConnectionError;
+                               }
+                       }
+                       set 
+                       {
+                               lock (this) 
+                               {
+                                       _IsConnectionError = value;
+                               }
+                       }
+               }
+
+               /// <summary>
+               /// The current address of the connection
+               /// </summary>
+               public string Address
+               {
+                       get 
+                       {
+                               return _AddressList[_CurrentAddress];
+                       }
+               }
+
+               /// <summary>
+               /// The address list of the connection
+               /// </summary>
+               public string[] AddressList
+               {
+                       get 
+                       {
+                               return _AddressList;
+                       }
+               }
+
+               /// <summary>
+               /// Which port is used for the connection
+               /// </summary>
+               public int Port
+               {
+                       get 
+                       {
+                               return _Port;
+                       }
+               }
+
+               /// <summary>
+               /// By default nothing is done when the library looses the 
connection
+               /// to the server.
+               /// Default: false
+               /// </summary>
+               /// <value>
+               /// true, if the library should reconnect on lost connections
+               /// false, if the library should not take care of it
+               /// </value>
+               public bool AutoReconnect
+               {
+                       get 
+                       {
+                               return _AutoReconnect;
+                       }
+                       set 
+                       {
+#if LOG4NET
+                if (value == true) {
+                    Logger.Connection.Info("AutoReconnect enabled");
+                } else {
+                    Logger.Connection.Info("AutoReconnect disabled");
+                }
+#endif
+                               _AutoReconnect = value;
+                       }
+               }
+
+               /// <summary>
+               /// If the library should retry to connect when the connection 
fails.
+               /// Default: false
+               /// </summary>
+               /// <value>
+               /// true, if the library should retry to connect
+               /// false, if the library should not retry
+               /// </value>
+               public bool AutoRetry
+               {
+                       get 
+                       {
+                               return _AutoRetry;
+                       }
+                       set 
+                       {
+#if LOG4NET
+                if (value == true) {
+                    Logger.Connection.Info("AutoRetry enabled");
+                } else {
+                    Logger.Connection.Info("AutoRetry disabled");
+                }
+#endif
+                               _AutoRetry = value;
+                       }
+               }
+
+               /// <summary>
+               /// Delay between retry attempts in Connect() in seconds.
+               /// Default: 30
+               /// </summary>
+               public int AutoRetryDelay
+               {
+                       get 
+                       {
+                               return _AutoRetryDelay;
+                       }
+                       set 
+                       {
+                               _AutoRetryDelay = value;
+                       }
+               }
+
+               /// <summary>
+               /// To prevent flooding the IRC server, it's required to delay 
each
+               /// message, given in milliseconds.
+               /// Default: 200
+               /// </summary>
+               public int SendDelay
+               {
+                       get 
+                       {
+                               return _SendDelay;
+                       }
+                       set 
+                       {
+                               _SendDelay = value;
+                       }
+               }
+
+               /// <summary>
+               /// On successful registration on the IRC network, this is set 
to true.
+               /// </summary>
+               public bool IsRegistered
+               {
+                       get 
+                       {
+                               return _IsRegistered;
+                       }
+               }
+
+               /// <summary>
+               /// On successful connect to the IRC server, this is set to 
true.
+               /// </summary>
+               public bool IsConnected
+               {
+                       get 
+                       {
+                               return _IsConnected;
+                       }
+               }
+
+               /// <summary>
+               /// The SmartIrc4net version number
+               /// </summary>
+               public string VersionNumber
+               {
+                       get 
+                       {
+                               return _VersionNumber;
+                       }
+               }
+
+               /// <summary>
+               /// The full SmartIrc4net version
+               /// </summary>
+               public string VersionString
+               {
+                       get 
+                       {
+                               return _VersionString;
+                       }
+               }
+
+               /// <summary>
+               /// Encoding which is used for reading and writing to the socket
+               /// Default: ISO-8859-1
+               /// </summary>
+               public Encoding Encoding
+               {
+                       get 
+                       {
+                               return _Encoding;
+                       }
+                       set 
+                       {
+                               _Encoding = value;
+                       }
+               }
+
+               /// <summary>
+               /// Timeout in seconds for receiving data from the socket
+               /// Default: 600
+               /// </summary>
+               public int SocketReceiveTimeout
+               {
+                       get 
+                       {
+                               return _SocketReceiveTimeout;
+                       }
+                       set 
+                       {
+                               _SocketReceiveTimeout = value;
+                       }
+               }
+        
+               /// <summary>
+               /// Timeout in seconds for sending data to the socket
+               /// Default: 600
+               /// </summary>
+               public int SocketSendTimeout
+               {
+                       get 
+                       {
+                               return _SocketSendTimeout;
+                       }
+                       set 
+                       {
+                               _SocketSendTimeout = value;
+                       }
+               }
+        
+               /// <summary>
+               /// Initializes the message queues, read and write thread
+               /// </summary>
+               public IrcConnection()
+               {
+#if LOG4NET        
+            Logger.Init();
+            Logger.Main.Debug("IrcConnection created");
+#endif
+                       _SendBuffer[Priority.High]        = 
Queue.Synchronized(new Queue());
+                       _SendBuffer[Priority.AboveMedium] = 
Queue.Synchronized(new Queue());
+                       _SendBuffer[Priority.Medium]      = 
Queue.Synchronized(new Queue());
+                       _SendBuffer[Priority.BelowMedium] = 
Queue.Synchronized(new Queue());
+                       _SendBuffer[Priority.Low]         = 
Queue.Synchronized(new Queue());
+
+                       // setup own callbacks
+                       OnReadLine        += new 
ReadLineEventHandler(_SimpleParser);
+                       OnConnectionError += new 
EventHandler(_OnConnectionError);
+
+                       _ReadThread  = new ReadThread(this);
+                       _WriteThread = new WriteThread(this);
+
+                       Assembly assm = Assembly.GetAssembly(this.GetType());
+                       AssemblyName assm_name = assm.GetName(false);
+
+                       AssemblyProductAttribute pr = 
(AssemblyProductAttribute)assm.GetCustomAttributes(typeof(AssemblyProductAttribute),
 false)[0];
+
+                       _VersionNumber = assm_name.Version.ToString();
+                       _VersionString = pr.Product+" "+_VersionNumber;
+               }
+        
+#if LOG4NET
+        ~IrcConnection()
+        {
+            Logger.Main.Debug("IrcConnection destroyed");
+            log4net.LogManager.Shutdown();
+        }
+#endif
+        
+               /// <overloads>this method has 2 overloads</overloads>
+               /// <summary>
+               /// Connects to the specified server and port, when the 
connection fails
+               /// the next server in the list will be used.
+               /// </summary>
+               /// <param name="addresslist">List of servers to connect 
to</pararm>
+               /// <param name="port">Portnumber to connect to</pararm>
+               /// <exception cref="CouldNotConnectException">The connection 
failed</exceptio>
+               /// <exception cref="AlreadyConnectedException">If there is 
already an active connection</exceptio>
+               public void Connect(string[] addresslist, int port)
+               {
+                       if (_IsConnected) 
+                       {
+                               throw new AlreadyConnectedException("Already 
connected to: "+Address+":"+Port);
+                       }
+
+#if LOG4NET
+            Logger.Connection.Info("connecting...");
+#endif
+                       _ConnectTries++;
+                       _AddressList = (string[])addresslist.Clone();
+                       _Port = port;
+
+                       if (OnConnecting != null) 
+                       {
+                               OnConnecting(this, EventArgs.Empty);
+                       }
+                       try 
+                       {
+                               System.Net.IPAddress ip = 
System.Net.Dns.Resolve(Address).AddressList[0];
+                               _TcpClient = new IrcTcpClient();
+                               _TcpClient.NoDelay = true;
+                               
_TcpClient.Socket.SetSocketOption(SocketOptionLevel.Socket, 
SocketOptionName.KeepAlive, 1);
+                               // set timeout, after this the connection will 
be aborted
+                               _TcpClient.ReceiveTimeout = 
_SocketReceiveTimeout*1000;
+                               _TcpClient.SendTimeout = 
_SocketSendTimeout*1000;
+                               _TcpClient.Connect(ip, port);
+                
+                               _Reader = new 
StreamReader(_TcpClient.GetStream(), Encoding);
+                               _Writer = new 
StreamWriter(_TcpClient.GetStream(), Encoding);
+
+                               // Connection was succeful, reseting the 
connect counter
+                               _ConnectTries = 0;
+
+                               // updating the connection error state, so 
connecting is possible again
+                               IsConnectionError = false;
+                               _IsConnected = true;
+
+                               // lets power up our threads
+                               _ReadThread.Start();
+                               _WriteThread.Start();
+                
+#if LOG4NET
+                Logger.Connection.Info("connected");
+#endif
+                               if (OnConnected != null) 
+                               {
+                                       OnConnected(this, EventArgs.Empty);
+                               }
+                       } 
+                       catch (Exception e) 
+                       {
+                               if (_Reader != null) 
+                               {
+                                       _Reader.Close();
+                               }
+                               if (_Writer != null) 
+                               {
+                                       _Writer.Close();
+                               }
+                               if (_TcpClient != null) 
+                               {
+                                       _TcpClient.Close();
+                               }
+                               _IsConnected = false;
+                               IsConnectionError = true;
+#if LOG4NET
+                Logger.Connection.Info("connection failed: "+e.Message);
+#endif
+                               if (_AutoRetry &&
+                                       (_ConnectTries <= 3)) 
+                               {
+#if LOG4NET
+                    Logger.Connection.Debug("delaying new connect attempt for 
"+_AutoRetryDelay+" sec");
+#endif
+                                       Thread.Sleep(_AutoRetryDelay*1000);
+                                       _NextAddress();
+                                       Connect(_AddressList, _Port);
+                               } 
+                               else 
+                               {
+                                       throw new 
CouldNotConnectException("Could not connect to: "+Address+":"+Port+" 
"+e.Message, e);
+                               }
+                       }
+               }
+
+               /// <summary>
+               /// Connects to the specified server and port.
+               /// </summary>
+               /// <param name="address">Server address to connect to</pararm>
+               /// <param name="port">Port number to connect to</pararm>
+               public void Connect(string address, int port)
+               {
+                       Connect(new string[] {address}, port);
+               }
+
+               public void Connect()
+               {
+                       Connect(_serverIP, _serverPort);
+               }
+
+               /// <summary>
+               /// Reconnects to the server
+               /// </summary>
+               /// <exception cref="NotConnectedException">
+               /// If there was no active connection
+               /// </exception>
+               /// <exception cref="CouldNotConnectException">
+               /// The connection failed
+               /// </exception>
+               /// <exception cref="AlreadyConnectedException">
+               /// If there is already an active connection
+               /// </exception>
+               public void Reconnect()
+               {
+#if LOG4NET
+            Logger.Connection.Info("reconnecting...");
+#endif
+                       Disconnect();
+                       Connect(_AddressList, _Port);
+               }
+        
+               /// <summary>
+               /// Disconnects from the server
+               /// </summary>
+               /// <exception cref="NotConnectedException">
+               /// If there was no active connection
+               /// </exception>
+               public void Disconnect()
+               {
+                       if (!IsConnected) 
+                       {
+                               throw new NotConnectedException("The connection 
could not be disconnected because there is no active connection");
+                       }
+            
+#if LOG4NET
+            Logger.Connection.Info("disconnecting...");
+#endif
+                       if (OnDisconnecting != null) 
+                       {
+                               OnDisconnecting(this, EventArgs.Empty);
+                       }
+
+                       _ReadThread.Stop();
+                       _WriteThread.Stop();
+                       _TcpClient.Close();
+                       _IsConnected = false;
+                       _IsRegistered = false;
+            
+                       if (OnDisconnected != null) 
+                       {
+                               OnDisconnected(this, EventArgs.Empty);
+                       }
+
+#if LOG4NET
+            Logger.Connection.Info("disconnected");
+#endif
+               }
+        
+               public void Listen(bool blocking)
+               {
+                       if (blocking) 
+                       {
+                               while (IsConnected) 
+                               {
+                                       ReadLine(true);
+                               }
+                       } 
+                       else 
+                       {
+                               while (ReadLine(false).Length > 0) 
+                               {
+                                       // loop as long as we receive messages
+                               }
+                       }
+               }
+
+               public void Listen()
+               {
+                       Listen(true);
+               }
+        
+               public void ListenOnce(bool blocking)
+               {
+                       ReadLine(blocking);
+               }
+
+               public void ListenOnce()
+               {
+                       ListenOnce(true);
+               }
+        
+               public string ReadLine(bool blocking)
+               {
+                       string data = "";
+                       if (blocking) 
+                       {
+                               // block till the queue has data, but bail out 
on connection error
+                               while (IsConnected &&
+                                       !IsConnectionError &&
+                                       (_ReadThread.Queue.Count == 0)) 
+                               {
+                                       Thread.Sleep(10);
+                               }
+                       }
+
+                       if (IsConnected &&
+                               (_ReadThread.Queue.Count > 0)) 
+                       {
+                               data = (string)(_ReadThread.Queue.Dequeue());
+                       }
+
+                       if (data != null && data.Length > 0) 
+                       {
+#if LOG4NET
+                Logger.Queue.Debug("read: \""+data+"\"");
+#endif
+                               if (OnReadLine != null) 
+                               {
+                                       OnReadLine(this, new 
ReadLineEventArgs(data));
+                               }
+                       }
+
+                       if (IsConnectionError &&
+                               (OnConnectionError != null)) 
+                       {
+                               OnConnectionError(this, EventArgs.Empty);
+                       }
+            
+                       return data;
+               }
+
+               public void WriteLine(string data, Priority priority)
+               {
+                       if (priority == Priority.Critical) 
+                       {
+                               if (!IsConnected) 
+                               {
+                                       throw new NotConnectedException();
+                               }
+                
+                               _WriteLine(data);
+                       } 
+                       else 
+                       {
+                               ((Queue)_SendBuffer[priority]).Enqueue(data);
+                       }
+               }
+
+               public void WriteLine(string data)
+               {
+                       WriteLine(data, Priority.Medium);
+               }
+
+               private bool _WriteLine(string data)
+               {
+                       if (IsConnected == true) 
+                       {
+                               try 
+                               {
+                                       _Writer.Write(data+"\r\n");
+                                       _Writer.Flush();
+                               } 
+                               catch (IOException) 
+                               {
+#if LOG4NET
+                    Logger.Socket.Warn("sending data failed, connection lost");
+#endif
+                                       IsConnectionError = true;
+                                       return false;
+                               }
+
+#if LOG4NET
+                Logger.Socket.Debug("sent: \""+data+"\"");
+#endif
+                               if (OnWriteLine != null) 
+                               {
+                                       OnWriteLine(this, new 
WriteLineEventArgs(data));
+                               }
+                               return true;
+                       }
+
+                       return false;
+               }
+
+               private void _NextAddress()
+               {
+                       _CurrentAddress++;
+                       if (_CurrentAddress < _AddressList.Length) 
+                       {
+                               // nothing
+                       } 
+                       else 
+                       {
+                               _CurrentAddress = 0;
+                       }
+#if LOG4NET
+            Logger.Connection.Info("set server to: "+Address);
+#endif
+               }
+
+               private void _SimpleParser(object sender, ReadLineEventArgs 
args)
+               {
+                       string   rawline = args.Line; 
+                       string[] rawlineex = rawline.Split(new char[] {' '});
+                       string   messagecode = "";
+
+                       if (rawline[0] == ':') 
+                       {
+                               messagecode = rawlineex[1];
+                               try 
+                               {
+                                       ReplyCode replycode = 
(ReplyCode)int.Parse(messagecode);
+                                       switch(replycode) 
+                                       {
+                                               case ReplyCode.Welcome:
+                                                       _IsRegistered = true;
+#if LOG4NET
+                            Logger.Connection.Info("logged in");
+#endif
+                                                       break;
+                                       }
+                               } 
+                               catch (FormatException) 
+                               {
+                                       // nothing
+                               }
+                       } 
+                       else 
+                       {
+                               messagecode = rawlineex[0];
+                               switch(messagecode) 
+                               {
+                                       case "ERROR":
+                                               IsConnectionError = true;
+                                               break;
+                               }
+                       }
+               }
+
+               private void _OnConnectionError(object sender, EventArgs e)
+               {
+                       try 
+                       {
+                               if (AutoReconnect) 
+                               {
+                                       // lets try to recover the connection
+                                       Reconnect();
+                               } 
+                               else 
+                               {
+                                       // make sure we clean up
+                                       Disconnect();
+                               }
+                       } 
+                       catch (ConnectionException) 
+                       {
+                       }
+               }
+        
+               private class ReadThread
+               {
+                       private IrcConnection  _Connection;
+                       private Thread         _Thread;
+                       private Queue          _Queue = Queue.Synchronized(new 
Queue());
+
+                       public Queue Queue
+                       {
+                               get 
+                               {
+                                       return _Queue;
+                               }
+                       }
+
+                       public ReadThread(IrcConnection connection)
+                       {
+                               _Connection = connection;
+                       }
+
+                       public void Start()
+                       {
+                               _Thread = new Thread(new ThreadStart(_Worker));
+                               _Thread.Name = "ReadThread 
("+_Connection.Address+":"+_Connection.Port+")";
+                               _Thread.IsBackground = true;
+                               _Thread.Start();
+                       }
+
+                       public void Stop()
+                       {
+                               _Thread.Abort();
+                               _Connection._Reader.Close();
+                       }
+
+                       private void _Worker()
+                       {
+#if LOG4NET
+                Logger.Socket.Debug("ReadThread started");
+#endif
+                               try 
+                               {
+                                       string data = "";
+                                       try 
+                                       {
+                                               while ((_Connection.IsConnected 
== true) &&
+                                                       ((data = 
_Connection._Reader.ReadLine()) != null)) 
+                                               {
+                                                       _Queue.Enqueue(data);
+#if LOG4NET
+                            Logger.Socket.Debug("received: \""+data+"\"");
+#endif
+                                               }
+                                       } 
+                                       catch (IOException e) 
+                                       {
+#if LOG4NET
+                        Logger.Socket.Warn("IOException: "+e.Message);
+#endif
+                                       } 
+                                       finally 
+                                       {
+#if LOG4NET
+                        Logger.Socket.Warn("connection lost");
+#endif
+                                               _Connection.IsConnectionError = 
true;
+                                       }
+                               } 
+                               catch (ThreadAbortException) 
+                               {
+                                       Thread.ResetAbort();
+#if LOG4NET
+                    Logger.Socket.Debug("ReadThread aborted");
+#endif
+                               }
+                       }
+               }
+
+               private class WriteThread
+               {
+                       private IrcConnection  _Connection;
+                       private Thread         _Thread;
+                       private int            _HighCount        = 0;
+                       private int            _AboveMediumCount = 0;
+                       private int            _MediumCount      = 0;
+                       private int            _BelowMediumCount = 0;
+                       private int            _LowCount         = 0;
+                       private int            _AboveMediumSentCount = 0;
+                       private int            _MediumSentCount      = 0;
+                       private int            _BelowMediumSentCount = 0;
+                       private int            _AboveMediumThresholdCount = 4;
+                       private int            _MediumThresholdCount      = 2;
+                       private int            _BelowMediumThresholdCount = 1;
+                       private int            _BurstCount = 0;
+
+                       public WriteThread(IrcConnection connection)
+                       {
+                               _Connection = connection;
+                       }
+
+                       public void Start()
+                       {
+                               _Thread = new Thread(new ThreadStart(_Worker));
+                               _Thread.Name = "WriteThread 
("+_Connection.Address+":"+_Connection.Port+")";
+                               _Thread.IsBackground = true;
+                               _Thread.Start();
+                       }
+
+                       public void Stop()
+                       {
+                               _Thread.Abort();
+                               _Connection._Writer.Close();
+                       }
+
+                       private void _Worker()
+                       {
+#if LOG4NET
+                Logger.Socket.Debug("WriteThread started");
+#endif
+                               try 
+                               {
+                                       try 
+                                       {
+                                               while (_Connection.IsConnected 
== true) 
+                                               {
+                                                       _CheckBuffer();
+                                                       
Thread.Sleep(_Connection._SendDelay);
+                                               }
+                                       } 
+                                       catch (IOException e) 
+                                       {
+#if LOG4NET
+                        Logger.Socket.Warn("IOException: "+e.Message);
+#endif
+                                       } 
+                                       finally 
+                                       {
+#if LOG4NET
+                        Logger.Socket.Warn("connection lost");
+#endif
+                                               _Connection.IsConnectionError = 
true;
+                                       }
+                               } 
+                               catch (ThreadAbortException) 
+                               {
+                                       Thread.ResetAbort();
+#if LOG4NET
+                    Logger.Socket.Debug("WriteThread aborted");
+#endif
+                               }
+                       }
+
+                       // WARNING: complex scheduler, don't even think about 
changing it!
+                       private void _CheckBuffer()
+                       {
+                               // only send data if we are succefully 
registered on the IRC network
+                               if (!_Connection._IsRegistered) 
+                               {
+                                       return;
+                               }
+
+                               _HighCount        = 
((Queue)_Connection._SendBuffer[Priority.High]).Count;
+                               _AboveMediumCount = 
((Queue)_Connection._SendBuffer[Priority.AboveMedium]).Count;
+                               _MediumCount      = 
((Queue)_Connection._SendBuffer[Priority.Medium]).Count;
+                               _BelowMediumCount = 
((Queue)_Connection._SendBuffer[Priority.BelowMedium]).Count;
+                               _LowCount         = 
((Queue)_Connection._SendBuffer[Priority.Low]).Count;
+
+                               if ((_CheckHighBuffer() == true) &&
+                                       (_CheckAboveMediumBuffer() == true) &&
+                                       (_CheckMediumBuffer() == true) &&
+                                       (_CheckBelowMediumBuffer() == true) &&
+                                       (_CheckLowBuffer() == true)) 
+                               {
+                                       // everything is sent, resetting all 
counters
+                                       _AboveMediumSentCount = 0;
+                                       _MediumSentCount      = 0;
+                                       _BelowMediumSentCount = 0;
+                                       _BurstCount = 0;
+                               }
+
+                               if (_BurstCount < 3) 
+                               {
+                                       _BurstCount++;
+                                       //_CheckBuffer();
+                               }
+                       }
+
+                       private bool _CheckHighBuffer()
+                       {
+                               if (_HighCount > 0) 
+                               {
+                                       string data = 
(string)((Queue)_Connection._SendBuffer[Priority.High]).Dequeue();
+                                       if (_Connection._WriteLine(data) == 
false) 
+                                       {
+#if LOG4NET
+                        Logger.Queue.Warn("Sending data was not sucessful, 
data is requeued!");
+#endif
+                                               
((Queue)_Connection._SendBuffer[Priority.High]).Enqueue(data);
+                                       }
+
+                                       if (_HighCount > 1) 
+                                       {
+                                               // there is more data to send
+                                               return false;
+                                       }
+                               }
+
+                               return true;
+                       }
+
+                       private bool _CheckAboveMediumBuffer()
+                       {
+                               if ((_AboveMediumCount > 0) &&
+                                       (_AboveMediumSentCount < 
_AboveMediumThresholdCount)) 
+                               {
+                                       string data = 
(string)((Queue)_Connection._SendBuffer[Priority.AboveMedium]).Dequeue();
+                                       if (_Connection._WriteLine(data) == 
false) 
+                                       {
+#if LOG4NET
+                        Logger.Queue.Warn("Sending data was not sucessful, 
data is requeued!");
+#endif
+                                               
((Queue)_Connection._SendBuffer[Priority.AboveMedium]).Enqueue(data);
+                                       }
+                                       _AboveMediumSentCount++;
+
+                                       if (_AboveMediumSentCount < 
_AboveMediumThresholdCount) 
+                                       {
+                                               return false;
+                                       }
+                               }
+
+                               return true;
+                       }
+
+                       private bool _CheckMediumBuffer()
+                       {
+                               if ((_MediumCount > 0) &&
+                                       (_MediumSentCount < 
_MediumThresholdCount)) 
+                               {
+                                       string data = 
(string)((Queue)_Connection._SendBuffer[Priority.Medium]).Dequeue();
+                                       if (_Connection._WriteLine(data) == 
false) 
+                                       {
+#if LOG4NET
+                        Logger.Queue.Warn("Sending data was not sucessful, 
data is requeued!");
+#endif
+                                               
((Queue)_Connection._SendBuffer[Priority.Medium]).Enqueue(data);
+                                       }
+                                       _MediumSentCount++;
+
+                                       if (_MediumSentCount < 
_MediumThresholdCount) 
+                                       {
+                                               return false;
+                                       }
+                               }
+
+                               return true;
+                       }
+
+                       private bool _CheckBelowMediumBuffer()
+                       {
+                               if ((_BelowMediumCount > 0) &&
+                                       (_BelowMediumSentCount < 
_BelowMediumThresholdCount)) 
+                               {
+                                       string data = 
(string)((Queue)_Connection._SendBuffer[Priority.BelowMedium]).Dequeue();
+                                       if (_Connection._WriteLine(data) == 
false) 
+                                       {
+#if LOG4NET
+                        Logger.Queue.Warn("Sending data was not sucessful, 
data is requeued!");
+#endif
+                                               
((Queue)_Connection._SendBuffer[Priority.BelowMedium]).Enqueue(data);
+                                       }
+                                       _BelowMediumSentCount++;
+
+                                       if (_BelowMediumSentCount < 
_BelowMediumThresholdCount) 
+                                       {
+                                               return false;
+                                       }
+                               }
+
+                               return true;
+                       }
+
+                       private bool _CheckLowBuffer()
+                       {
+                               if (_LowCount > 0) 
+                               {
+                                       if ((_HighCount > 0) ||
+                                               (_AboveMediumCount > 0) ||
+                                               (_MediumCount > 0) ||
+                                               (_BelowMediumCount > 0)) 
+                                       {
+                                               return true;
+                                       }
+
+                                       string data = 
(string)((Queue)_Connection._SendBuffer[Priority.Low]).Dequeue();
+                                       if (_Connection._WriteLine(data) == 
false) 
+                                       {
+#if LOG4NET
+                        Logger.Queue.Warn("Sending data was not sucessful, 
data is requeued!");
+#endif
+                                               
((Queue)_Connection._SendBuffer[Priority.Low]).Enqueue(data);
+                                       }
+
+                                       if (_LowCount > 1) 
+                                       {
+                                               return false;
+                                       }
+                               }
+
+                               return true;
+                       }
+                       // END OF WARNING, below this you can read/change again 
;)
+               }
+       }
+
+       public sealed class Rfc2812
+       {
+               // nickname   =  ( letter / special ) *8( letter / digit / 
special / "-" )
+               // letter     =  %x41-5A / %x61-7A       ; A-Z / a-z
+               // digit      =  %x30-39                 ; 0-9
+               // special    =  %x5B-60 / %x7B-7D
+               //                  ; "[", "]", "\", "`", "_", "^", "{", "|", 
"}"
+               private static Regex _NicknameRegex = new 
Regex(@"^[A-Za-z\[\]\\`_^{|}][A-Za-z0-9\[\]\\`_\-^{|}]+$", 
RegexOptions.Compiled);
+        
+               private Rfc2812()
+               {
+               }
+        
+               /// <summary>
+               /// Checks if the passed nickname is valid according to the RFC
+               ///
+               /// Use with caution, many IRC servers are not conform with 
this!
+               /// </summary>
+               public static bool IsValidNickname(string nickname)
+               {
+                       if ((nickname != null) &&
+                               (nickname.Length > 0) &&
+                               (_NicknameRegex.Match(nickname).Success)) 
+                       {
+                               return true;
+                       }
+            
+                       return false;
+               }
+        
+               public static string Pass(string password)
+               {
+                       return "PASS "+password;
+               }
+        
+               public static string Nick(string nickname)
+               {
+                       return "NICK "+nickname;
+               }
+        
+               public static string User(string username, int usermode, string 
realname)
+               {
+                       return "USER "+username+" "+usermode.ToString()+" * 
:"+realname;
+               }
+
+               public static string Oper(string name, string password)
+               {
+                       return "OPER "+name+" "+password;
+               }
+        
+               public static string Privmsg(string destination, string message)
+               {
+                       return "PRIVMSG "+destination+" :"+message;
+               }
+
+               public static string Notice(string destination, string message)
+               {
+                       return "NOTICE "+destination+" :"+message;
+               }
+
+               public static string Join(string channel)
+               {
+                       return "JOIN "+channel;
+               }
+        
+               public static string Join(string[] channels)
+               {
+                       string channellist = String.Join(",", channels);
+                       return "JOIN "+channellist;
+               }
+        
+               public static string Join(string channel, string key)
+               {
+                       return "JOIN "+channel+" "+key;
+               }
+
+               public static string Join(string[] channels, string[] keys)
+               {
+                       string channellist = String.Join(",", channels);
+                       string keylist = String.Join(",", keys);
+                       return "JOIN "+channellist+" "+keylist;
+               }
+        
+               public static string Part(string channel)
+               {
+                       return "PART "+channel;
+               }
+
+               public static string Part(string[] channels)
+               {
+                       string channellist = String.Join(",", channels);
+                       return "PART "+channellist;
+               }
+        
+               public static string Part(string channel, string partmessage)
+               {
+                       return "PART "+channel+" :"+partmessage;
+               }
+
+               public static string Part(string[] channels, string partmessage)
+               {
+                       string channellist = String.Join(",", channels);
+                       return "PART "+channellist+" :"+partmessage;
+               }
+
+               public static string Kick(string channel, string nickname)
+               {
+                       return "KICK "+channel+" "+nickname;
+               }
+
+               public static string Kick(string channel, string nickname, 
string comment)
+               {
+                       return "KICK "+channel+" "+nickname+" :"+comment;
+               }
+        
+               public static string Kick(string[] channels, string nickname)
+               {
+                       string channellist = String.Join(",", channels);
+                       return "KICK "+channellist+" "+nickname;
+               }
+
+               public static string Kick(string[] channels, string nickname, 
string comment)
+               {
+                       string channellist = String.Join(",", channels);
+                       return "KICK "+channellist+" "+nickname+" :"+comment;
+               }
+
+               public static string Kick(string channel, string[] nicknames)
+               {
+                       string nicknamelist = String.Join(",", nicknames);
+                       return "KICK "+channel+" "+nicknamelist;
+               }
+
+               public static string Kick(string channel, string[] nicknames, 
string comment)
+               {
+                       string nicknamelist = String.Join(",", nicknames);
+                       return "KICK "+channel+" "+nicknamelist+" :"+comment;
+               }
+
+               public static string Kick(string[] channels, string[] nicknames)
+               {
+                       string channellist = String.Join(",", channels);
+                       string nicknamelist = String.Join(",", nicknames);
+                       return "KICK "+channellist+" "+nicknamelist;
+               }
+
+               public static string Kick(string[] channels, string[] 
nicknames, string comment)
+               {
+                       string channellist = String.Join(",", channels);
+                       string nicknamelist = String.Join(",", nicknames);
+                       return "KICK "+channellist+" "+nicknamelist+" 
:"+comment;
+               }
+        
+               public static string Motd()
+               {
+                       return "MOTD";
+               }
+
+               public static string Motd(string target)
+               {
+                       return "MOTD "+target;
+               }
+
+               public static string Luser()
+               {
+                       return "LUSER";
+               }
+
+               public static string Luser(string mask)
+               {
+                       return "LUSER "+mask;
+               }
+
+               public static string Luser(string mask, string target)
+               {
+                       return "LUSER "+mask+" "+target;
+               }
+        
+               public static string Version()
+               {
+                       return "VERSION";
+               }
+
+               public static string Version(string target)
+               {
+                       return "VERSION "+target;
+               }
+
+               public static string Stats()
+               {
+                       return "STATS";
+               }
+
+               public static string Stats(string query)
+               {
+                       return "STATS "+query;
+               }
+
+               public static string Stats(string query, string target)
+               {
+                       return "STATS "+query+" "+target;
+               }
+
+               public static string Links()
+               {
+                       return "LINKS";
+               }
+        
+               public static string Links(string servermask)
+               {
+                       return "LINKS "+servermask;
+               }
+        
+               public static string Links(string remoteserver, string 
servermask)
+               {
+                       return "LINKS "+remoteserver+" "+servermask;
+               }
+        
+               public static string Time()
+               {
+                       return "TIME";
+               }
+        
+               public static string Time(string target)
+               {
+                       return "TIME "+target;
+               }
+        
+               public static string Connect(string targetserver, string port)
+               {
+                       return "CONNECT "+targetserver+" "+port;
+               }
+        
+               public static string Connect(string targetserver, string port, 
string remoteserver)
+               {
+                       return "CONNECT "+targetserver+" "+port+" 
"+remoteserver;
+               }
+        
+               public static string Trace()
+               {
+                       return "TRACE";
+               }
+        
+               public static string Trace(string target)
+               {
+                       return "TRACE "+target;
+               }
+        
+               public static string Admin()
+               {
+                       return "ADMIN";
+               }
+        
+               public static string Admin(string target)
+               {
+                       return "ADMIN "+target;
+               }
+        
+               public static string Info()
+               {
+                       return "INFO";
+               }
+        
+               public static string Info(string target)
+               {
+                       return "INFO "+target;
+               }
+        
+               public static string Servlist()
+               {
+                       return "SERVLIST";
+               }
+        
+               public static string Servlist(string mask)
+               {
+                       return "SERVLIST "+mask;
+               }
+        
+               public static string Servlist(string mask, string type)
+               {
+                       return "SERVLIST "+mask+" "+type;
+               }
+        
+               public static string Squery(string servicename, string 
servicetext)
+               {
+                       return "SQUERY "+servicename+" :"+servicetext;
+               }
+        
+               public static string List()
+               {
+                       return "LIST";
+               }
+
+               public static string List(string channel)
+               {
+                       return "LIST "+channel;
+               }
+
+               public static string List(string[] channels)
+               {
+                       string channellist = String.Join(",", channels);
+                       return "LIST "+channellist;
+               }
+        
+               public static string List(string channel, string target)
+               {
+                       return "LIST "+channel+" "+target;
+               }
+
+               public static string List(string[] channels, string target)
+               {
+                       string channellist = String.Join(",", channels);
+                       return "LIST "+channellist+" "+target;
+               }
+        
+               public static string Names()
+               {
+                       return "NAMES";
+               }
+
+               public static string Names(string channel)
+               {
+                       return "NAMES "+channel;
+               }
+
+               public static string Names(string[] channels)
+               {
+                       string channellist = String.Join(",", channels);
+                       return "NAMES "+channellist;
+               }
+        
+               public static string Names(string channel, string target)
+               {
+                       return "NAMES "+channel+" "+target;
+               }
+        
+               public static string Names(string[] channels, string target)
+               {
+                       string channellist = String.Join(",", channels);
+                       return "NAMES "+channellist+" "+target;
+               }
+        
+               public static string Topic(string channel)
+               {
+                       return "TOPIC "+channel;
+               }
+
+               public static string Topic(string channel, string newtopic)
+               {
+                       return "TOPIC "+channel+" :"+newtopic;
+               }
+
+               public static string Mode(string target)
+               {
+                       return "MODE "+target;
+               }
+
+               public static string Mode(string target, string newmode)
+               {
+                       return "MODE "+target+" "+newmode;
+               }
+
+               public static string Service(string nickname, string 
distribution, string info)
+               {
+                       return "SERVICE "+nickname+" * "+distribution+" * * 
:"+info;
+               }
+        
+               public static string Invite(string nickname, string channel)
+               {
+                       return "INVITE "+nickname+" "+channel;
+               }
+
+               public static string Who()
+               {
+                       return "WHO";
+               }
+        
+               public static string Who(string mask)
+               {
+                       return "WHO "+mask;
+               }
+        
+               public static string Who(string mask, bool ircop)
+               {
+                       if (ircop) 
+                       {
+                               return "WHO "+mask+" o";
+                       } 
+                       else 
+                       {
+                               return "WHO "+mask;
+                       }
+               }
+        
+               public static string Whois(string mask)
+               {
+                       return "WHOIS "+mask;
+               }
+        
+               public static string Whois(string[] masks)
+               {
+                       string masklist = String.Join(",", masks);
+                       return "WHOIS "+masklist;
+               }
+        
+               public static string Whois(string target, string mask)
+               {
+                       return "WHOIS "+target+" "+mask;
+               }
+        
+               public static string Whois(string target, string[] masks)
+               {
+                       string masklist = String.Join(",", masks);
+                       return "WHOIS "+target+" "+masklist;
+               }
+        
+               public static string Whowas(string nickname)
+               {
+                       return "WHOWAS "+nickname;
+               }
+        
+               public static string Whowas(string[] nicknames)
+               {
+                       string nicknamelist = String.Join(",", nicknames);
+                       return "WHOWAS "+nicknamelist;
+               }
+
+               public static string Whowas(string nickname, string count)
+               {
+                       return "WHOWAS "+nickname+" "+count+" ";
+               }
+        
+               public static string Whowas(string[] nicknames, string count)
+               {
+                       string nicknamelist = String.Join(",", nicknames);
+                       return "WHOWAS "+nicknamelist+" "+count+" ";
+               }
+        
+               public static string Whowas(string nickname, string count, 
string target)
+               {
+                       return "WHOWAS "+nickname+" "+count+" "+target;
+               }
+        
+               public static string Whowas(string[] nicknames, string count, 
string target)
+               {
+                       string nicknamelist = String.Join(",", nicknames);
+                       return "WHOWAS "+nicknamelist+" "+count+" "+target;
+               }
+        
+               public static string Kill(string nickname, string comment)
+               {
+                       return "KILL "+nickname+" :"+comment;
+               }
+        
+               public static string Ping(string server)
+               {
+                       return "PING "+server;
+               }
+        
+               public static string Ping(string server, string server2)
+               {
+                       return "PING "+server+" "+server2;
+               }
+        
+               public static string Pong(string server)
+               {
+                       return "PONG "+server;
+               }
+        
+               public static string Pong(string server, string server2)
+               {
+                       return "PONG "+server+" "+server2;
+               }
+
+               public static string Error(string errormessage)
+               {
+                       return "ERROR :"+errormessage;
+               }
+        
+               public static string Away()
+               {
+                       return "AWAY";
+               }
+        
+               public static string Away(string awaytext)
+               {
+                       return "AWAY :"+awaytext;
+               }
+        
+               public static string Rehash()
+               {
+                       return "REHASH";
+               }
+        
+               public static string Die()
+               {
+                       return "DIE";
+               }
+        
+               public static string Restart()
+               {
+                       return "RESTART";
+               }
+        
+               public static string Summon(string user)
+               {
+                       return "SUMMON "+user;
+               }
+        
+               public static string Summon(string user, string target)
+               {
+                       return "SUMMON "+user+" "+target;
+               }
+        
+               public static string Summon(string user, string target, string 
channel)
+               {
+                       return "SUMMON "+user+" "+target+" "+channel;
+               }
+        
+               public static string Users()
+               {
+                       return "USERS";
+               }
+        
+               public static string Users(string target)
+               {
+                       return "USERS "+target;
+               }
+        
+               public static string Wallops(string wallopstext)
+               {
+                       return "WALLOPS :"+wallopstext;
+               }
+        
+               public static string Userhost(string nickname)
+               {
+                       return "USERHOST "+nickname;
+               }
+        
+               public static string Userhost(string[] nicknames)
+               {
+                       string nicknamelist = String.Join(" ", nicknames);
+                       return "USERHOST "+nicknamelist;
+               }
+        
+               public static string Ison(string nickname)
+               {
+                       return "ISON "+nickname;
+               }
+        
+               public static string Ison(string[] nicknames)
+               {
+                       string nicknamelist = String.Join(" ", nicknames);
+                       return "ISON "+nicknamelist;
+               }
+        
+               public static string Quit()
+               {
+                       return "QUIT";
+               }
+        
+               public static string Quit(string quitmessage)
+               {
+                       return "QUIT :"+quitmessage;
+               }
+        
+               public static string Squit(string server, string comment)
+               {
+                       return "SQUIT "+server+" :"+comment;
+               }
+       }
+
+       [Serializable()]
+       public class SmartIrc4netException : ApplicationException
+       {
+               public SmartIrc4netException() : base()
+               {
+               }
+
+               public SmartIrc4netException(string message) : base(message)
+               {
+               }
+
+               public SmartIrc4netException(string message, Exception e) : 
base(message, e)
+               {
+               }
+
+               protected SmartIrc4netException(SerializationInfo info, 
StreamingContext context) : base(info, context)
+               {
+               }
+       }
+
+       [Serializable()]
+       public class ConnectionException : SmartIrc4netException
+       {
+               public ConnectionException() : base()
+               {
+               }
+
+               public ConnectionException(string message) : base(message)
+               {
+               }
+
+               public ConnectionException(string message, Exception e) : 
base(message, e)
+               {
+               }
+
+               protected ConnectionException(SerializationInfo info, 
StreamingContext context) : base(info, context)
+               {
+               }
+       }
+
+       [Serializable()]
+       public class CouldNotConnectException : ConnectionException
+       {
+               public CouldNotConnectException() : base()
+               {
+               }
+
+               public CouldNotConnectException(string message) : base(message)
+               {
+               }
+
+               public CouldNotConnectException(string message, Exception e) : 
base(message, e)
+               {
+               }
+
+               protected CouldNotConnectException(SerializationInfo info, 
StreamingContext context) : base(info, context)
+               {
+               }
+       }
+
+       [Serializable()]
+       public class NotConnectedException : ConnectionException
+       {
+               public NotConnectedException() : base()
+               {
+               }
+
+               public NotConnectedException(string message) : base(message)
+               {
+               }
+
+               public NotConnectedException(string message, Exception e) : 
base(message, e)
+               {
+               }
+
+               protected NotConnectedException(SerializationInfo info, 
StreamingContext context) : base(info, context)
+               {
+               }
+       }
+
+       [Serializable()]
+       public class AlreadyConnectedException : ConnectionException
+       {
+               public AlreadyConnectedException() : base()
+               {
+               }
+
+               public AlreadyConnectedException(string message) : base(message)
+               {
+               }
+
+               public AlreadyConnectedException(string message, Exception e) : 
base(message, e)
+               {
+               }
+
+               protected AlreadyConnectedException(SerializationInfo info, 
StreamingContext context) : base(info, context)
+               {
+               }
+       }
+
+       /// <summary>
+       ///
+       /// </summary>
+       public enum ReplyCode: int
+       {
+               Null =                           000,
+               Welcome =                        001,
+               YourHost =                       002,
+               Created =                        003,
+               MyInfo =                         004,
+               Bounce =                         005,
+               TraceLink =                      200,
+               TraceConnecting =                201,
+               TraceHandshake =                 202,
+               TraceUnknown =                   203,
+               TraceOperator =                  204,
+               TraceUser =                      205,
+               TraceServer =                    206,
+               TraceService =                   207,
+               TraceNewType =                   208,
+               TraceClass =                     209,
+               TraceReconnect =                 210,
+               StatsLinkInfo =                  211,
+               StatsCommands =                  212,
+               EndOfStats =                     219,
+               UserModeIs =                     221,
+               ServiceList =                    234,
+               ServiceListEnd =                 235,
+               StatsUptime =                    242,
+               StatsOLine =                     243,
+               LuserClient =                    251,
+               LuserOp =                        252,
+               LuserUnknown =                   253,
+               LuserChannels =                  254,
+               LuserMe =                        255,
+               AdminMe =                        256,
+               AdminLocation1 =                 257,
+               AdminLocation2 =                 258,
+               AdminEmail =                     259,
+               TraceLog =                       261,
+               TraceEnd =                       262,
+               TryAgain =                       263,
+               Away =                           301,
+               UserHost =                       302,
+               IsOn =                           303,
+               UnAway =                         305,
+               NowAway =                        306,
+               WhoIsUser =                      311,
+               WhoIsServer =                    312,
+               WhoIsOperator =                  313,
+               WhoWasUser =                     314,
+               EndOfWho =                       315,
+               WhoIsIdle =                      317,
+               EndOfWhoIs =                     318,
+               WhoIsChannels =                  319,
+               ListStart =                      321,
+               List =                           322,
+               ListEnd =                        323,
+               ChannelModeIs =                  324,
+               UniqueOpIs =                     325,
+               NoTopic =                        331,
+               Topic =                          332,
+               Inviting =                       341,
+               Summoning =                      342,
+               InviteList =                     346,
+               EndOfInviteList =                347,
+               ExceptionList =                  348,
+               EndOfExceptionList =             349,
+               Version =                        351,
+               WhoReply =                       352,
+               NamesReply =                     353,
+               Links =                          364,
+               EndOfLinks =                     365,
+               EndOfNames =                     366,
+               BanList =                        367,
+               EndOfBanList =                   368,
+               EndOfWhoWas =                    369,
+               Info =                           371,
+               Motd =                           372,
+               EndOfInfo =                      374,
+               MotdStart =                      375,
+               EndOfMotd =                      376,
+               YouAreOper =                     381,
+               Rehashing =                      382,
+               YouAreService =                  383,
+               Time =                           391,
+               UsersStart =                     392,
+               Users =                          393,
+               EndOfUsers =                     394,
+               NoUsers =                        395,
+               ErrorNoSuchNickname =            401,
+               ErrorNoSuchServer =              402,
+               ErrorNoSuchChannel =             403,
+               ErrorCannotSendToChannel =       404,
+               ErrorTooManyChannels =           405,
+               ErrorWasNoSuchNickname =         406,
+               ErrorTooManyTargets =            407,
+               ErrorNoSuchService =             408,
+               ErrorNoOrigin =                  409,
+               ErrorNoRecipient =               411,
+               ErrorNoTextToSend =              412,
+               ErrorNoTopLevel =                413,
+               ErrorWildTopLevel =              414,
+               ErrorBadMask =                   415,
+               ErrorUnknownCommand =            421,
+               ErrorNoMotd =                    422,
+               ErrorNoAdminInfo =               423,
+               ErrorFileError =                 424,
+               ErrorNoNicknameGiven =           431,
+               ErrorErroneusNickname =          432,
+               ErrorNicknameInUse =             433,
+               ErrorNicknameCollision =         436,
+               ErrorUnavailableResource =       437,
+               ErrorUserNotInChannel =          441,
+               ErrorNotOnChannel =              442,
+               ErrorUserOnChannel =             443,
+               ErrorNoLogin =                   444,
+               ErrorSummonDisabled =            445,
+               ErrorUsersDisabled =             446,
+               ErrorNotRegistered =             451,
+               ErrorNeedMoreParams =            461,
+               ErrorAlreadyRegistered =         462,
+               ErrorNoPermissionForHost =       463,
+               ErrorPasswordMismatch =          464,
+               ErrorYouAreBannedCreep =         465,
+               ErrorYouWillBeBanned =           466,
+               ErrorKeySet =                    467,
+               ErrorChannelIsFull =             471,
+               ErrorUnknownMode =               472,
+               ErrorInviteOnlyChannel =         473,
+               ErrorBannedFromChannel =         474,
+               ErrorBadChannelKey =             475,
+               ErrorBadChannelMask =            476,
+               ErrorNoChannelModes =            477,
+               ErrorBanListFull =               478,
+               ErrorNoPrivileges =              481,
+               ErrorChannelOpPrivilegesNeeded = 482,
+               ErrorCannotKillServer =          483,
+               ErrorRestricted =                484,
+               ErrorUniqueOpPrivilegesNeeded =  485,
+               ErrorNoOperHost =                491,
+               ErrorUserModeUnknownFlag =       501,
+               ErrorUsersDoNotMatch =           502
+       }
+}

Modified: trunk/skorpion/skorpion.cs
===================================================================
--- trunk/skorpion/skorpion.cs  2007-01-22 03:41:02 UTC (rev 141)
+++ trunk/skorpion/skorpion.cs  2007-03-14 06:07:49 UTC (rev 142)
@@ -27,7 +27,7 @@
 {
        public class RegConfig
        {
-               public static string        PlayerName          = "du0d";
+               public static string        PlayerName          = "vmy";
                public static int           FormWidth           = 800;
                public static int           FormHeight          = 600;
        }
@@ -50,6 +50,8 @@
                        
                public static bool          ServerStart         = false;
 
+               public static bool                      IrcStart                
        = true;
+
                public static TimeSpan      ConsoleOpen         = new 
TimeSpan(0,0,0,0,500);
                public static TimeSpan      ClientKeyRepeat     = new 
TimeSpan(0,0,0,0,200);
                public static TimeSpan      ClientACKRetry      = new 
TimeSpan(0,0,0,2,0);
@@ -78,6 +80,7 @@
                public static Console             Console             = null;
                public static PlayerList          PlayerList          = null;
                public static Chat                Chat                = null;
+               public static IrcConnection       Irc                 = null;
                public static Command             Command             = null;
                public static Bind                Bind                = null;
        }

Modified: trunk/skorpion/skorpion.csproj
===================================================================
--- trunk/skorpion/skorpion.csproj      2007-01-22 03:41:02 UTC (rev 141)
+++ trunk/skorpion/skorpion.csproj      2007-03-14 06:07:49 UTC (rev 142)
@@ -178,6 +178,11 @@
                     BuildAction = "EmbeddedResource"
                 />
                 <File
+                    RelPath = "IrcConnection.cs"
+                    SubType = "Code"
+                    BuildAction = "Compile"
+                />
+                <File
                     RelPath = "ParticleSystem.cs"
                     SubType = "Code"
                     BuildAction = "Compile"





reply via email to

[Prev in Thread] Current Thread [Next in Thread]