C# Class IrcShark.Chatting.Irc.IrcClient

Manages a simple irc connection on a low raw level.
With an instance of IrcClient, you can connect to an irc server and receive many events defined by the standard irc protocol. The messages received are automatically parsed to IrcLine objects to be easier accessible. After connection was established, you should call ReceiveLine to get the lines from the server.
Inheritance: IDisposable
Show file Open project: hapm/IrcShark Class Usage Examples

Public Methods

Method Description
Connect ( ) : void

Connects to the irc server addressed by ServerAddress.

Dispose ( ) : void

Disposes the object.

IrcClient ( ) : System

Initializes a new instance of the IrcClient class without any address to connect to.

Join ( string chanName ) : void

Joins a given channel on the irc server.

The given chanName should follow the given Standard of the IrcClient. The IrcClient will wait for the acknowledge of the server.

Part ( string chanName ) : void

Parts a given channel on the irc server.

The chanName should follow the given Standard of the IrcClient. The IrcClient will wait for the acknowledge of the server.

Quit ( ) : void

Quits the IRC Connection without a Message.

Quit ( string quitMsg ) : void

Quits the IRC connection with a Message.

ReadLine ( ) : IrcLine

Reads a new line from the server.

This method blocks the calling thread until a new line was received from server. Only use this method, if you want to bypass the automatically raised events and kine handling. If you want to have this features use IrcClient.ReceiveLine instead.

ReceiveLine ( ) : void

Reads the next line, raise all events and handle it if needed.

This method does the same as IrcClient.ReadLine does but additionally raise all events of the line. If the line is a PING line, it is handled and automatically answered by an according PONG.

SendLine ( string line ) : void

Sends a raw irc line to the irc server.

You can send anything you want. The text is send as is. There is no checking or something.

SendMessage ( string message, string receiver ) : void

Sends a message to a channel or nick (in a query).

SendNotice ( string message, string receiver ) : void

Sends a message to a channel, nick (directly).

Protected Methods

Method Description
OnError ( string msg ) : void

Fires the Error event.

OnError ( string msg, Exception ex ) : void

Fires the Error event.

OnLineReceived ( IrcLine line ) : void

Fires the LineReceived event.

OnOnConnect ( ) : bool

Fires the OnConnect event.

OnOnLogin ( ) : void

Fires the OnLogin event.

Private Methods

Method Description
HandleLine ( LineReceivedEventArgs e ) : void

Handles a line received from server.

Method Details

Connect() public method

Connects to the irc server addressed by ServerAddress.
public Connect ( ) : void
return void

Dispose() public method

Disposes the object.
public Dispose ( ) : void
return void

IrcClient() public method

Initializes a new instance of the IrcClient class without any address to connect to.
public IrcClient ( ) : System
return System

Join() public method

Joins a given channel on the irc server.
The given chanName should follow the given Standard of the IrcClient. The IrcClient will wait for the acknowledge of the server.
public Join ( string chanName ) : void
chanName string The channel name the client should join.
return void

OnError() protected method

Fires the Error event.
protected OnError ( string msg ) : void
msg string The message for the error.
return void

OnError() protected method

Fires the Error event.
protected OnError ( string msg, Exception ex ) : void
msg string The message for the error.
ex System.Exception The exception that occured.
return void

OnLineReceived() protected method

Fires the LineReceived event.
protected OnLineReceived ( IrcLine line ) : void
line IrcLine The line that was received.
return void

OnOnConnect() protected method

Fires the OnConnect event.
protected OnOnConnect ( ) : bool
return bool

OnOnLogin() protected method

Fires the OnLogin event.
protected OnOnLogin ( ) : void
return void

Part() public method

Parts a given channel on the irc server.
The chanName should follow the given Standard of the IrcClient. The IrcClient will wait for the acknowledge of the server.
public Part ( string chanName ) : void
chanName string The channel name the client should join.
return void

Quit() public method

Quits the IRC Connection without a Message.
public Quit ( ) : void
return void

Quit() public method

Quits the IRC connection with a Message.
public Quit ( string quitMsg ) : void
quitMsg string The message to use when quitting.
return void

ReadLine() public method

Reads a new line from the server.
This method blocks the calling thread until a new line was received from server. Only use this method, if you want to bypass the automatically raised events and kine handling. If you want to have this features use IrcClient.ReceiveLine instead.
public ReadLine ( ) : IrcLine
return IrcLine

ReceiveLine() public method

Reads the next line, raise all events and handle it if needed.
This method does the same as IrcClient.ReadLine does but additionally raise all events of the line. If the line is a PING line, it is handled and automatically answered by an according PONG.
public ReceiveLine ( ) : void
return void

SendLine() public method

Sends a raw irc line to the irc server.
You can send anything you want. The text is send as is. There is no checking or something.
public SendLine ( string line ) : void
line string The raw line to send.
return void

SendMessage() public method

Sends a message to a channel or nick (in a query).
public SendMessage ( string message, string receiver ) : void
message string The message to send.
receiver string The receiver (a channel or a nick).
return void

SendNotice() public method

Sends a message to a channel, nick (directly).
public SendNotice ( string message, string receiver ) : void
message string The message to send.
receiver string The receiver (a channel or a nick).
return void