about summary refs log tree commit diff
path: root/Sample
diff options
context:
space:
mode:
authorBen Harris <ben@tilde.team>2020-04-28 01:52:24 -0400
committerBen Harris <ben@tilde.team>2020-04-28 01:52:24 -0400
commit8bc9eb4b7556fab6ceea811e66267a5c7f7ecdc2 (patch)
treea47828482ebe083d55bfcafd6081140d05b77595 /Sample
parentf1c4ed9ae8d5a8d1b7da5f59c4802cef8326a7e2 (diff)
fix some stateful stuff
Diffstat (limited to 'Sample')
-rw-r--r--Sample/Client.cs13
1 files changed, 9 insertions, 4 deletions
diff --git a/Sample/Client.cs b/Sample/Client.cs
index 70444de..933cab7 100644
--- a/Sample/Client.cs
+++ b/Sample/Client.cs
@@ -25,12 +25,11 @@ namespace TokensSample
             _socket.Connect("127.0.0.1", 6667);
 
             Send(new Line {Command = "NICK", Params = new List<string> {"tokensbot"}});
-            Send(new Line {Command = "USER", Params = new List<string> {"username", "0", "*", "real name"}});
+            Send(new Line {Command = "USER", Params = new List<string> {"tokensbot", "0", "*", "real name"}});
 
             while (true)
             {
                 var bytesReceived = _socket.Receive(_bytes);
-                var lines         = _decoder.Push(_bytes);
 
                 if (bytesReceived == 0)
                 {
@@ -39,6 +38,8 @@ namespace TokensSample
                     break;
                 }
 
+                var lines = _decoder.Push(_bytes);
+                
                 foreach (var line in lines)
                 {
                     Console.WriteLine($"< {line.Format()}");
@@ -49,7 +50,10 @@ namespace TokensSample
                             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> {"#test"}});
+                            break;
+                        case "PRIVMSG":
+                            Send(new Line {Command = "PRIVMSG", Params = new List<string> {line.Params[0], "hello there"}});
                             break;
                     }
                 }
@@ -60,7 +64,8 @@ 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));
         }
     }
 }