Code Monkey home page Code Monkey logo

actorsnet's Introduction

ActorsNet v0.1.0

Asp.Net MVC + SignalR meets Actors!

Call the sever-side actors within your javascript. Initialize your actor system and done!


Modules description

ActorsNet

Abstraction layer over actor system or framework.

ActorsNet.AkkaNet

Concrete implementation for ActorsNet classes using Akka.Net

ActorsNet.SignalR

Module that allows async calls between server and client.

ActorsNet.JavascriptGenerator

Generates factories for creating strongly typed messages (possibility to save generated js and use it for code completion instead of writing message type names by hand).

ActorsNet.{SignalR, JavaScriptGenerator}.Autofac

Projects that contains initializer classes that can be used with Autofac IoC.

ActorsNet.Web

Example application, contains actor system creation code, initializers and example calls.

Contains script for creating ActorSystem proxy on the client-side and call server-side actors [actorsnet.js]

Change app.js to test communication with hand-written messages or generated ones.

Examples

Server-side

Define actors and messages

    public class EchoActor : ReceiveActor
    {
        public EchoActor()
        {
            Receive<Echo>(echo =>Sender.Tell(echo, Self));
        }
    }

	public class Echo
    {
        public Echo(string message)
        {
            Message = message;
        }
		public string Message { get; private set; }
    }
	//if Javascript generator is used
	builder.RegisterJavascriptGenerator(new MessagesBySystemNameProvider()
												.Add<Echo>(ActorSystemName)
												.Add<Greet>(ActorSystemName));

Create actor system, and initialize it in the container

builder.RegisterActorSystem(actorSystem);	

Example without ActorsNet.JavascriptGenerator

	(function() {
    var actorSystem = new ActorsNetSystem("MySystem");
    actorSystem
        .open()
        .then(function() { //system ready
            var echoActor = actorSystem.actorFor("/echo");
            var echoMsg = actorSystem.createMessage("ActorsNet.Web.Messages.Echo");
            echoMsg.setMessageData({ Message: "SignalR ask test" });
			//send message
            echoActor.send(echoMsg);
            //or ask and wait for response 
            echoActor
                .ask(echoMsg)
                .then(function(response) {
                    alert(response);
                });
        });
	})();

Example with JavascriptGenerator

	(function() {
	    var mySystem = ActorsNet.MySystem.create();
	    mySystem
	        .open()
	        .then(function() {
	            var echoActor = mySystem.actorFor("/echo");
	            var echoMessage = ActorsNet.MySystem.ActorsNet_Web_Messages_Echo.create();
	            echoMessage.setMessageData({ Message: "Eccchoooo!" });
	            //send message
				echoActor.send(echoMessage);
				//or ask and wait for response
	            echoActor
	                .ask(echoMessage)
	                .then(function(response) {
	                    alert(response);
	                });
	        });
	})();

TODOs

  • Add more tests
  • Make nuget packages
  • Implement and test different Akka.Net ActorFinder strategies (akka.tcp/cluster)
  • Integration with client side actors library (https://github.com/mental/webactors ?) to allow communication between JS actors
  • Implementation of a server side router actor to allow calls from server to client-side declared actors (Actorish-WebWorkers)
  • Different implementation of ActorSystem (Microsoft Orleans)

actorsnet's People

Contributors

lemmit avatar

Watchers

 avatar  avatar

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.