TheBlueLines / Debris

Protocol written in C#

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Debris

Network protocol for TTMC applications

Installation

Download the repo and build the solution with:

dotnet build

Add the builded dll file to your project

Solution Explorer > Dependencies > Add Project Reference > Browse > OK

Example

Client

using Debris;
using System.Net.Sockets;

namespace ClientExample
{
	internal class Program
	{
		static void Main(string[] args)
		{
			Client client = new("127.0.0.1", 54321);
			client.handle = new ClientHandle();
			Console.WriteLine("Client started!");

			Packet packet = new Packet()
			{
				id = 1,
				data = Engine.PrefixedString("Szia Világ!")
			};
			client.SendPacket(packet);
			Console.WriteLine("Packet sent!");
			Thread.Sleep(1000);
		}
	}
	public class ClientHandle : Handle
	{
		public override Packet? Message(Packet packet, NetworkStream stream)
		{
			Console.WriteLine("Client got: " + packet.id);
			return null;
		}
	}
}

Server

using Debris;
using System.Net.Sockets;

namespace ServerExample
{
	internal class Program
	{
		static void Main(string[] args)
		{
			Server server = new(54321);
			server.handle = new ServerHandle();
			Console.WriteLine("Server started!");
		}
	}
	public class ServerHandle : Handle
	{
		public override Packet? Message(Packet packet, NetworkStream stream)
		{
			Console.WriteLine("Server got: " + packet.id);
			return packet;
		}
	}
}

License

MIT

About

Protocol written in C#

License:MIT License


Languages

Language:C# 100.0%