A simple, hackable, remote code hosting platform.
NLC (Not Lite Code) is a simplified version of LiteCode by DragonHunter, which provides native RPC and other useful features without any external dependencies.
Traditionally RPC/RMI implements a stub interface and is tightly coupled. NLC however can function without a stub interface by using BinaryFormatter
to serialize & deserialize objects on the fly at runtime allowing it to be loosly coupled. NLC also allows communication over SSLStream
for security.
NLC creates a unique instance for every client allowing you to keep stateful data alongside their functions in the SharedClass
.
As of 1.4 NLC's networking core is now asynchronous and will invoke calls in a new Task once the data is received. Thus any synchronization must either be ensured in the client invoking the methods or inside the SharedClass functions themselves.
SharedClass.cs
[NLCCall("MagicNumber")]
public bool IsMagicNumber(int number)
{
return number == 7;
}
Program.cs
server = new Server<SharedClass>();
server.Start();
Program.cs
public static async Task<bool> IsMagicNumber(int number) =>
await client.RemoteCall<bool>("MagicNumber", number);
client = new Client();
client.Connect("localhost", 1337);
Console.WriteLine(await IsMagicNumber(-10)); // False
Console.WriteLine(await IsMagicNumber(7)); // True
LiteCode by DragonHunter