Skip to content

Instantly share code, notes, and snippets.

Created October 8, 2012 20:32
Show Gist options
  • Save anonymous/3854796 to your computer and use it in GitHub Desktop.
Save anonymous/3854796 to your computer and use it in GitHub Desktop.
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