From 933a4f85604e21445c9bac8272d64cf3e6f65e00 Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Wed, 22 Apr 2020 16:28:51 -0400 Subject: rename to IrcSharp also tidy up formatting with vs tools --- Sample/Client.cs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'Sample/Client.cs') diff --git a/Sample/Client.cs b/Sample/Client.cs index e9e286f..b756adf 100644 --- a/Sample/Client.cs +++ b/Sample/Client.cs @@ -1,10 +1,9 @@ -using System; +using IrcTokens; +using System; using System.Collections.Generic; using System.Net.Sockets; -using System.Text; -using IrcTokens; -namespace Sample +namespace TokensSample { public class Client { @@ -25,15 +24,15 @@ namespace Sample { _socket.Connect("127.0.0.1", 6667); - Send(new Line {Command = "USER", Params = new List {"username", "0", "*", "real name"}}); - Send(new Line {Command = "NICK", Params = new List {"statefulbot"}}); + Send(new Line { Command = "USER", Params = new List { "username", "0", "*", "real name" } }); + Send(new Line { Command = "NICK", Params = new List { "tokensbot" } }); while (true) { var bytesReceived = _socket.Receive(_bytes); var lines = _decoder.Push(_bytes); - if (lines.Count == 0) + if (bytesReceived == 0) { Console.WriteLine("! disconnected"); _socket.Shutdown(SocketShutdown.Both); @@ -47,10 +46,10 @@ namespace Sample switch (line.Command) { case "PING": - Send(new Line {Command = "PONG", Params = line.Params}); + Send(new Line { Command = "PONG", Params = line.Params }); break; case "001": - Send(new Line {Command = "JOIN", Params = new List {"#channel"}}); + Send(new Line { Command = "JOIN", Params = new List { "#channel" } }); break; } } @@ -62,7 +61,9 @@ namespace Sample Console.WriteLine($"> {line.Format()}"); _encoder.Push(line); while (_encoder.PendingBytes.Length > 0) + { _encoder.Pop(_socket.Send(_encoder.PendingBytes)); + } } } } -- cgit 1.4.1