diff options
author | Ben Harris <ben@tilde.team> | 2020-04-22 16:28:51 -0400 |
---|---|---|
committer | Ben Harris <ben@tilde.team> | 2020-04-22 16:28:51 -0400 |
commit | 933a4f85604e21445c9bac8272d64cf3e6f65e00 (patch) | |
tree | 5b300ca37beff5cf11ed67a8b6e3550d24cf18a3 /Sample/Client.cs | |
parent | 338763fde71ba2dc0de8ea5e2437d24ee365874b (diff) |
rename to IrcSharp
also tidy up formatting with vs tools
Diffstat (limited to 'Sample/Client.cs')
-rw-r--r-- | Sample/Client.cs | 19 |
1 files changed, 10 insertions, 9 deletions
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<string> {"username", "0", "*", "real name"}}); - Send(new Line {Command = "NICK", Params = new List<string> {"statefulbot"}}); + Send(new Line { Command = "USER", Params = new List<string> { "username", "0", "*", "real name" } }); + Send(new Line { Command = "NICK", Params = new List<string> { "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<string> {"#channel"}}); + Send(new Line { Command = "JOIN", Params = new List<string> { "#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)); + } } } } |