Created
October 8, 2012 20:32
-
-
Save anonymous/3854796 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Threading; | |
using System.Threading.Tasks; | |
using System.Net.Sockets; | |
using System.Net; | |
namespace Irc | |
{ | |
public class Client: IDisposable | |
{ | |
Socket _socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.TCP); | |
#region Properties | |
public string Host { get; private set; } | |
public short Port { get; private set; } | |
public string Username { get; private set; } | |
public string Name { get; private set; } | |
public string Nickname { get; set; } | |
#endregion | |
public Client(string host, short port = 6667) | |
{ | |
Host = host; | |
Port = port; | |
} | |
public async Task ConnectAsync() | |
{ | |
await _socket.BeginConnect(Host, Port); | |
// Wait for the server to send AUTH messages and such | |
await Task.Delay(1000); | |
await SendCommandAsync(String.Format("USER {0} 8 * :{1}", Username, Name)); | |
await SendCommandAsync(String.Format("NICK {0}", Nickname)); | |
} | |
public void Dispose() | |
{ | |
_socket.Dispose(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment