Skip to content

TheBlueLines/Debris

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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#

Resources

License

Stars

2 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors

Languages