From 504f8daed200c94f842decdf3513de4d02176353 Mon Sep 17 00:00:00 2001
From: Starbeamrainbowlabs <sbrl@starbeamrainbowlabs.com>
Date: Fri, 27 Jan 2017 21:25:49 +0000
Subject: [PATCH] Add files I missed

---
 .../Messages/HandshakeRequestMessage.cs       | 21 ++++++++++
 Nibriboard/Client/Messages/Message.cs         | 13 ++++++
 Nibriboard/Client/NibriClient.cs              |  2 +-
 Nibriboard/Utilities/JsonUtilities.cs         | 30 ++++++++++++++
 Nibriboard/Utilities/PointExtensions.cs       | 40 +++++++++++++++++++
 5 files changed, 105 insertions(+), 1 deletion(-)
 create mode 100644 Nibriboard/Client/Messages/HandshakeRequestMessage.cs
 create mode 100644 Nibriboard/Client/Messages/Message.cs
 create mode 100644 Nibriboard/Utilities/JsonUtilities.cs
 create mode 100644 Nibriboard/Utilities/PointExtensions.cs

diff --git a/Nibriboard/Client/Messages/HandshakeRequestMessage.cs b/Nibriboard/Client/Messages/HandshakeRequestMessage.cs
new file mode 100644
index 0000000..6c0eb6e
--- /dev/null
+++ b/Nibriboard/Client/Messages/HandshakeRequestMessage.cs
@@ -0,0 +1,21 @@
+﻿using System;
+using System.Drawing;
+
+namespace Nibriboard.Client.Messages
+{
+	public class HandshakeRequestMessage : Message
+	{
+		/// <summary>
+		/// The initial visible area on the client's screen.
+		/// Very useful for determining which chunks we should send a client when they first connect.
+		/// </summary>
+		public Rectangle InitialViewport = new Rectangle(
+			0, 0,
+			1366, 768
+		);
+
+		public HandshakeRequestMessage()
+		{
+		}
+	}
+}
diff --git a/Nibriboard/Client/Messages/Message.cs b/Nibriboard/Client/Messages/Message.cs
new file mode 100644
index 0000000..bc184da
--- /dev/null
+++ b/Nibriboard/Client/Messages/Message.cs
@@ -0,0 +1,13 @@
+﻿using System;
+
+namespace Nibriboard.Client.Messages
+{
+	public class Message
+	{
+		public readonly DateTime TimeSent = DateTime.Now;
+
+		public Message()
+		{
+		}
+	}
+}
diff --git a/Nibriboard/Client/NibriClient.cs b/Nibriboard/Client/NibriClient.cs
index 93d08c8..191ed2d 100644
--- a/Nibriboard/Client/NibriClient.cs
+++ b/Nibriboard/Client/NibriClient.cs
@@ -15,7 +15,7 @@ namespace Nibriboard.Client
 
 		private Dictionary<string, Type> messageEventTypes = new Dictionary<string, Type>()
 		{
-
+			["handshake"] = 
 		};
 
 		public NibriClient(NibriClientManager inManager, WebSocket inClient)
diff --git a/Nibriboard/Utilities/JsonUtilities.cs b/Nibriboard/Utilities/JsonUtilities.cs
new file mode 100644
index 0000000..cd51b20
--- /dev/null
+++ b/Nibriboard/Utilities/JsonUtilities.cs
@@ -0,0 +1,30 @@
+﻿using System;
+using System.IO;
+using Newtonsoft.Json;
+
+namespace SBRL.Utilities
+{
+	public static class JsonUtilities
+	{
+		public static T DeserializeProperty<T>(string json, string targetPropertyName)
+		{
+			using (StringReader stringReader = new StringReader(json))
+			using (JsonTextReader jsonReader = new JsonTextReader(stringReader))
+			{
+				while (jsonReader.Read())
+				{
+					if (jsonReader.TokenType == JsonToken.PropertyName
+						&& (string)jsonReader.Value == targetPropertyName)
+					{
+						jsonReader.Read();
+
+						JsonSerializer serializer = new JsonSerializer();
+						return serializer.Deserialize<T>(jsonReader);
+					}
+				}
+				return default(T);
+			}
+		}
+	}
+}
+
diff --git a/Nibriboard/Utilities/PointExtensions.cs b/Nibriboard/Utilities/PointExtensions.cs
new file mode 100644
index 0000000..ad343e7
--- /dev/null
+++ b/Nibriboard/Utilities/PointExtensions.cs
@@ -0,0 +1,40 @@
+﻿using System;
+using System.Drawing;
+
+namespace SBRL.Utilities
+{
+	/// <summary>
+	/// A selection of extensions to the System.Drawing.Point class to make things easier :)
+	/// </summary>
+	public static class PointExtensions
+	{
+		public static Point Add(this Point a, Point b)
+		{
+			return new Point(
+				a.X + b.X,
+				a.Y + b.X
+			);
+		}
+		public static Point Subtract(this Point a, Point b)
+		{
+			return new Point(
+				a.X - b.X,
+				a.Y - b.X
+			);
+		}
+		public static Point Divide(this Point a, int b)
+		{
+			return new Point(
+				a.X / b,
+				a.Y / b
+			);
+		}
+		public static Point Multiply(this Point a, int b)
+		{
+			return new Point(
+				a.X * b,
+				a.Y * b
+			);
+		}
+	}
+}
