GithubHelp home page GithubHelp logo

agency's Introduction

Agency

MyGet monarchsolutions MyGet Build Status

Nobody outruns the Agency. - Benjamin Travis, Division chief of ICA

Agency is a .NET lib for Remote Dynamic.

It's achieved by Trinity Force: Dynamitey · Serialize.Linq · ExpressionTree

Agent and Handler works in unity. - Diana Burnwood, ICA Handler

Agency works on .NET and mono(Unity). .NET Core is not supported currently because it has neither .NET Remoting nor WCF Server support.

Remote Dynamic? WTF?

Remote Dynamic means to share objects between processes (usually using .NET Remoting) without the type to be known (using dynamic instead). It will be useful when the type is complex or changes frequently.

Demo

Server:

class Agent47
{
    public string Weapon { get; set; } = "Fiber Wire";

    public void PointShooting(int enemy)
    {
        Console.WriteLine($"Target eliminated: {enemy}");
    }
}
static void Main(string[] args)
{
    var agent = new Agent47();
    Agency.RegisterAgent("47", agent, new IpcHandler());
    Console.ReadLine();
	//Run Client here
    Console.WriteLine($"Current Weapon: {agent.Weapon}"); //weapon changed to `Silverballer`
    Console.ReadLine();
}

Client:

static void Main(string[] args)
{
    dynamic agent;
    try
    {
        agent = Agency.SpawnAgent("47", new IpcHandler());
    }
    catch (Exception e)
    {
        Console.WriteLine(e);
        return;
    }
    Console.WriteLine($"Current Weapon: {agent.Weapon}"); //get
    var weapon = "Silverballer";
    agent.Weapon = weapon; //set
    for (int i = 0; i < 5; i++)
    {
        agent.PointShooting(i); //Called on server
    }
    Console.ReadLine();
}

Here is another demo to show how you can share an object between an Unity(mono) program and a .NET(CLR) program, to implement a chat system with comfortable syntax.

UnityDemo

Handler

Handler implements the communication way between processes.

Currently Agency has implemented IpcHandler(faster but only for local CLR & Windows) and TcpHandler (slower but mono compatible) which uses .NET Remoting IPC. You can implement your handler as well.

Events

Example

You can subscribe a server object's event using a client method. When event is triggered on server, the method executes on client. (The subscription can be slow!)

Even more, you can also subscribe a server object's event using Expression<T> and it will be compiled and executed on server!


by Ulysses ([email protected])

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.