diff --git a/.gitignore b/.gitignore
index 5608bbc..d4b2b96 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,3 +3,6 @@
################################################################################
/.vs/UnityServerBasics/v14/.suo
+/UnityServerBasics/bin/Debug
+/UnityServerBasics/obj/Debug
+/UnityServerBasics/UnityServerBasics.csproj.user
diff --git a/UnityServerBasics/Network/NetworkMessage.cs b/UnityServerBasics/Network/NetworkMessage.cs
index c6e752c..1588622 100644
--- a/UnityServerBasics/Network/NetworkMessage.cs
+++ b/UnityServerBasics/Network/NetworkMessage.cs
@@ -11,7 +11,7 @@
namespace UnityServerBasics.Network
{
[Serializable]
- class NetworkMessage
+ class NetworkMessage : Serialization.INetworkSerializer
{
///
/// unique identifier for the networking system.
@@ -57,47 +57,47 @@ public NetworkMessage(string _sMessage, Player _cPlayer, int _iSequence = 0)
Sender = _cPlayer;
}
- ///
- /// Serialize the in to bytes.
- ///
- /// The message to serialize.
- /// A
- public static byte[] Serialize(NetworkMessage _message)
- {
- try
- {
- MemoryStream memStream = new MemoryStream();
- IFormatter formatter = new BinaryFormatter();
- // write the serializable class to the memory stream.
- formatter.Serialize(memStream, _message);
- memStream.Position = 0;
- // return the memory stream as a byte[]
- return memStream.ToArray();
- }
- catch (Exception)
- {
- throw new Exceptions.SerializeNetworkException("The message could not be serialized");
- }
- }
+ /////
+ ///// Serialize the in to bytes.
+ /////
+ ///// The message to serialize.
+ ///// A
+ //public static byte[] Serialize(NetworkMessage _message)
+ //{
+ // try
+ // {
+ // MemoryStream memStream = new MemoryStream();
+ // IFormatter formatter = new BinaryFormatter();
+ // // write the serializable class to the memory stream.
+ // formatter.Serialize(memStream, _message);
+ // memStream.Position = 0;
+ // // return the memory stream as a byte[]
+ // return memStream.ToArray();
+ // }
+ // catch (Exception)
+ // {
+ // throw new Exceptions.SerializeNetworkException("The message could not be serialized");
+ // }
+ //}
- ///
- ///
- ///
- ///
- ///
- public static NetworkMessage Deserialize(byte[] _message)
- {
- try
- {
- MemoryStream memStream = new MemoryStream();
- memStream.Write(_message, 0, _message.Length);
- IFormatter formatter = new BinaryFormatter();
- return (NetworkMessage)formatter.Deserialize(memStream);
- }
- catch (Exception)
- {
- throw new Exceptions.SerializeNetworkException("The message could not be deserialized");
- }
- }
+ /////
+ /////
+ /////
+ /////
+ /////
+ //public static NetworkMessage Deserialize(byte[] _message)
+ //{
+ // try
+ // {
+ // MemoryStream memStream = new MemoryStream();
+ // memStream.Write(_message, 0, _message.Length);
+ // IFormatter formatter = new BinaryFormatter();
+ // return (NetworkMessage)formatter.Deserialize(memStream);
+ // }
+ // catch (Exception)
+ // {
+ // throw new Exceptions.SerializeNetworkException("The message could not be deserialized");
+ // }
+ //}
}
}
diff --git a/UnityServerBasics/Network/Server.cs b/UnityServerBasics/Network/Server.cs
index 76624e4..5d9ce3f 100644
--- a/UnityServerBasics/Network/Server.cs
+++ b/UnityServerBasics/Network/Server.cs
@@ -1,6 +1,7 @@
using System;
using System.Net;
using System.Net.Sockets;
+using System.Text;
using System.Threading;
using UnityServerBasics.Utilities;
@@ -41,10 +42,13 @@ class Server : IDisposable
///
///
///
- public Server(int _port, EventQueue _messageBacklog)
+ public Server(int _port, EventQueue _messageBacklog = null)
{
this._port = _port;
- MessageBacklog = _messageBacklog;
+ if (_messageBacklog != null)
+ MessageBacklog = _messageBacklog;
+ else
+ MessageBacklog = new EventQueue();
Instance = this;
Console.WriteLine("Setting up the server...");
MessageReceived += ParseMessage;
@@ -107,7 +111,7 @@ private void Listener()
///
private void ParseMessage(byte[] _lMessage)
{
- NetworkMessage message = NetworkMessage.Deserialize(_lMessage);
+ NetworkMessage message = NetworkMessage.Deserialize(Encoding.UTF8.GetString(_lMessage));
MessageBacklog.Enqueue(message);
}
diff --git a/UnityServerBasics/Properties/app.manifest b/UnityServerBasics/Properties/app.manifest
new file mode 100644
index 0000000..cd90d8b
--- /dev/null
+++ b/UnityServerBasics/Properties/app.manifest
@@ -0,0 +1,70 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file