about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBen Harris <ben@tilde.team>2020-04-28 00:44:58 -0400
committerBen Harris <ben@tilde.team>2020-04-28 00:44:58 -0400
commitf1c4ed9ae8d5a8d1b7da5f59c4802cef8326a7e2 (patch)
tree01c18fe680d94e1cb37e88c47b0c6e760c580719
parent80afa2c0aec37b7f98cc22615417c36672e695da (diff)
fix order of nick and user in example
-rw-r--r--Sample/Client.cs27
-rw-r--r--Sample/Program.cs10
2 files changed, 15 insertions, 22 deletions
diff --git a/Sample/Client.cs b/Sample/Client.cs
index b756adf..70444de 100644
--- a/Sample/Client.cs
+++ b/Sample/Client.cs
@@ -1,36 +1,36 @@
-using IrcTokens;
-using System;
+using System;
 using System.Collections.Generic;
 using System.Net.Sockets;
+using IrcTokens;
 
 namespace TokensSample
 {
     public class Client
     {
-        private readonly Socket _socket;
+        private readonly byte[] _bytes;
         private readonly StatefulDecoder _decoder;
         private readonly StatefulEncoder _encoder;
-        private readonly byte[] _bytes;
+        private readonly Socket _socket;
 
         public Client()
         {
             _decoder = new StatefulDecoder();
             _encoder = new StatefulEncoder();
-            _socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP);
-            _bytes = new byte[1024];
+            _socket  = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP);
+            _bytes   = new byte[1024];
         }
 
         public void Start()
         {
             _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> { "tokensbot" } });
+            Send(new Line {Command = "NICK", Params = new List<string> {"tokensbot"}});
+            Send(new Line {Command = "USER", Params = new List<string> {"username", "0", "*", "real name"}});
 
             while (true)
             {
                 var bytesReceived = _socket.Receive(_bytes);
-                var lines = _decoder.Push(_bytes);
+                var lines         = _decoder.Push(_bytes);
 
                 if (bytesReceived == 0)
                 {
@@ -46,10 +46,10 @@ namespace TokensSample
                     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;
                     }
                 }
@@ -60,10 +60,7 @@ namespace TokensSample
         {
             Console.WriteLine($"> {line.Format()}");
             _encoder.Push(line);
-            while (_encoder.PendingBytes.Length > 0)
-            {
-                _encoder.Pop(_socket.Send(_encoder.PendingBytes));
-            }
+            while (_encoder.PendingBytes.Length > 0) _encoder.Pop(_socket.Send(_encoder.PendingBytes));
         }
     }
 }
diff --git a/Sample/Program.cs b/Sample/Program.cs
index eda312f..c3a0885 100644
--- a/Sample/Program.cs
+++ b/Sample/Program.cs
@@ -1,6 +1,6 @@
-using IrcTokens;
-using System;
+using System;
 using System.Collections.Generic;
+using IrcTokens;
 
 namespace TokensSample
 {
@@ -14,11 +14,7 @@ namespace TokensSample
             Console.WriteLine(line.Format());
 
             // formatting
-            var line2 = new Line
-            {
-                Command = "USER",
-                Params = new List<string> { "user", "0", "*", "real name" }
-            };
+            var line2 = new Line {Command = "USER", Params = new List<string> {"user", "0", "*", "real name"}};
             Console.WriteLine(line2);
             Console.WriteLine(line2.Format());