This repository has been archived by the owner on Jul 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Crawcik edited this page Feb 1, 2021
·
5 revisions
AnthillNet is a library for network solutions with the simplest feature and a lot of customization settings
- Send and receive simple packet or serialized messages
- You can make events, that can be invoke by server or client
- Calling server or other clients to execute method
- Get logs of operations preformed by host
- Create own events and net_args
- Change protocol to UDP or TCP
- Start, Stop, Pause and Resume host
- Change host tickrate from 0 to 255
- Change to sync or async functions
- Control ticks on your own without making new threads
- Change log priority
- Only AnthillNet.Core namespace without AnthillNet.Event and AnthillNet namespace
- AnthillNet.Core and AnthillNet.Event namespace without AnthillNet
- AnthillNet.Unity in Unity Game Engine
using AnthillNet;
using AnthillNet.Core;
using AnthillNet.Events;
using System;
public class Program
{
public const ushort myPort = 7777;
public static void Main() => new Program().Run();
public void Run()
{
HostSettings settings = new HostSettings()
{
LogPriority = LogType.Info,
Port = 8000,
Protocol = ProtocolType.TCP,
TickRate = 8,
Async = true,
WriteLogsToConsole = true,
MaxConnections = 20,
MaxDataSize = 4096
};
Host host = new Host(HostType.Server); //Or HostType.Client for client obviously
host.Settings = settings;
host.Start(); //You can also set IP but then you can only connect through this one
host.Send(new Message(0, "Test")); //Sending simple message (destinies from 1 to 100 are reserved for events, orders, pings etc. if you using AnthillNet.Events)
while (true)
{
char x = Console.ReadKey().KeyChar;
switch (x)
{
case 'o':
host.Order.Call(OrderTest); //You can also send method with argument
break;
case 'q':
break;
}
if (x == 'q')
break;
}
host.Stop();
host.Dispose();
}
[Order(toClient: true, toServer: true)]
public void OrderTest()
{
Console.WriteLine("This method is called by client or server");
}
}