1
0
Fork 0

Add files I missed

This commit is contained in:
Starbeamrainbowlabs 2017-01-27 21:25:49 +00:00
parent abbcb7a8c8
commit 504f8daed2
5 changed files with 105 additions and 1 deletions

View File

@ -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()
{
}
}
}

View File

@ -0,0 +1,13 @@
using System;
namespace Nibriboard.Client.Messages
{
public class Message
{
public readonly DateTime TimeSent = DateTime.Now;
public Message()
{
}
}
}

View File

@ -15,7 +15,7 @@ namespace Nibriboard.Client
private Dictionary<string, Type> messageEventTypes = new Dictionary<string, Type>()
{
["handshake"] =
};
public NibriClient(NibriClientManager inManager, WebSocket inClient)

View File

@ -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);
}
}
}
}

View File

@ -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
);
}
}
}