Compare commits
2 Commits
3f88804156
...
e5b64f600c
| Author | SHA1 | Date | |
|---|---|---|---|
| e5b64f600c | |||
| 4d70b98802 |
@ -1,10 +1,14 @@
|
||||
using Articulate_Network;
|
||||
using Articulate_Network.Events;
|
||||
using Articulate_Network.Managers;
|
||||
using MIT_Packets;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MIT_Master_Server
|
||||
@ -13,26 +17,28 @@ namespace MIT_Master_Server
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
var watch = Stopwatch.StartNew();
|
||||
|
||||
TestPacket.Register();
|
||||
|
||||
Server server = new Server();
|
||||
|
||||
//server.Get<PacketManager>()
|
||||
var packet = server.Get<PacketManager>().Send<TestPacket>(new TestPacket()
|
||||
{
|
||||
TestOne = 50,
|
||||
TestTwo = true,
|
||||
TestThree = "Hello I'm a test"
|
||||
});
|
||||
|
||||
Console.WriteLine(packet.TestThree);
|
||||
|
||||
server.Start("127.0.0.1", 50).ContinueWith(t =>
|
||||
{
|
||||
Console.WriteLine($"Server listening on port 50");
|
||||
|
||||
watch.Stop();
|
||||
Console.WriteLine();
|
||||
Console.WriteLine($"Server listening on port 50, took {watch.ElapsedMilliseconds} ms");
|
||||
});
|
||||
|
||||
Console.ReadKey();
|
||||
server.ClientConnected += Server_ClientConnected;
|
||||
|
||||
Console.ReadLine();
|
||||
}
|
||||
|
||||
private static void Server_ClientConnected(object sender, ClientConnectedEventArgs e)
|
||||
{
|
||||
Console.WriteLine($"Client Connected from: {(e.TcpClient.Client.RemoteEndPoint as IPEndPoint).Address}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
14
MIT Packets/AnnouncePacket.cs
Normal file
14
MIT Packets/AnnouncePacket.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MIT_Packets
|
||||
{
|
||||
public class AnnouncePacket
|
||||
{
|
||||
public int Type { get; set; }
|
||||
public bool RequestConfig { get; set; }
|
||||
}
|
||||
}
|
||||
@ -11,7 +11,6 @@ namespace MIT_Packets
|
||||
public class TestPacket : IPacket
|
||||
{
|
||||
public int TestOne { get; set; }
|
||||
[PacketIgnore]
|
||||
public bool TestTwo { get; set; }
|
||||
public string TestThree { get; set; }
|
||||
public static void Register()
|
||||
|
||||
@ -16,7 +16,12 @@ namespace MIT_Builder_Client
|
||||
|
||||
client.Connect("127.0.0.1", 50).ContinueWith(t =>
|
||||
{
|
||||
Console.WriteLine($"Connection result: {t.Result.Connected}");
|
||||
if (t.Result.Connected)
|
||||
{
|
||||
Console.WriteLine("Successfully connected to master server.");
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
Console.ReadLine();
|
||||
|
||||
Reference in New Issue
Block a user