/// <summary> /// Sets up a socket and the necessary handlers. /// </summary> public void Init() { socket = new ClientSocket(); // create a socket socket.ConnectSuccess += new EventHandler(SocketConnectedHandler); socket.Closed += new EventHandler(SocketClosedHandler); socket.ConnectionException += new ClientSocket.ExceptionEventHandler(SocketErrorHandler); socket.SendException += new ClientSocket.ExceptionEventHandler(SocketErrorHandler); socket.GeneralException += new ClientSocket.ExceptionEventHandler(SocketErrorHandler); socket.DataArrival += new EventHandler(DataArrivalHandler); }
/// <summary> /// Triggered when a socket exception is raised. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SocketErrorHandler(object sender, ClientSocket.ExceptionEventArgs e) { Debug.WriteLine(e.CatchedException.Message, "SocketError."); if (ConnectionSocketError != null) ConnectionSocketError(sender, e); else throw (e.CatchedException); Init(); }
private void ConnectionError(object sender, ClientSocket.ExceptionEventArgs e) { Log(e.CatchedException.Message, Color.Red); }