Test
This commit is contained in:
@@ -56,13 +56,13 @@ namespace Client
|
|||||||
return bytes[5] == 0x02;
|
return bytes[5] == 0x02;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static byte[] getMessage(byte[] payload, byte messageId)
|
public static byte[] getMessage(byte[] payload, byte messageId)
|
||||||
{
|
{
|
||||||
byte[] res = new byte[payload.Length + 5];
|
byte[] res = new byte[payload.Length + 6];
|
||||||
|
|
||||||
Array.Copy(BitConverter.GetBytes(payload.Length + 5), 0, res, 0, 4);
|
Array.Copy(BitConverter.GetBytes(payload.Length + 6), 0, res, 0, 4);
|
||||||
res[4] = messageId;
|
res[4] = messageId;
|
||||||
Array.Copy(payload, 0, res, 5, payload.Length);
|
Array.Copy(payload, 0, res, 6, payload.Length);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ using System.Linq;
|
|||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using Client;
|
||||||
using Newtonsoft;
|
using Newtonsoft;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
@@ -124,12 +125,25 @@ namespace Server
|
|||||||
{
|
{
|
||||||
Console.WriteLine("Data " + packet);
|
Console.WriteLine("Data " + packet);
|
||||||
dynamic json = JsonConvert.DeserializeObject(packet);
|
dynamic json = JsonConvert.DeserializeObject(packet);
|
||||||
//json.
|
if (json.data.name == json.data.password)
|
||||||
|
{
|
||||||
|
dynamic payload = new
|
||||||
|
{
|
||||||
|
data = new
|
||||||
|
{
|
||||||
|
status = "ok"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Message.Message message = new Message.Message(Message.Identifier.LOGIN, JsonConvert.SerializeObject(payload));
|
||||||
|
Write(message.Serialize());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Write(string data)
|
private void Write(string data)
|
||||||
{
|
{
|
||||||
|
byte[] bytes = DataParser.getMessage(Encoding.ASCII.GetBytes(data), 0x01);
|
||||||
|
stream.Write(bytes, 0, bytes.Length);
|
||||||
|
stream.Flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user