This is the C# port of aktos-dcs platform.
- Download and install aktos-dcs
- Between C# and Python applications:
2. Run
aktos-dcs/examples/ponger.py
3. Runaktos-dcs-cs/examples/pinger
solution 4. See if they are pinging and ponging each other. - Between C# applications:
- Run
aktos-dcs/examples/foo.py
(in order to create a router) - Run
examples/ponger
solution. - Run
examples/pinger
solution - See they are messaging.
- Run
-
Create a new project
-
Add
aktos-dcs-cs
references in your project.- In "Solution Explorer", click
Add -> Solution
, browse to selectaktos-dcs-cs/aktos-dcs-cs/aktos-dcs-cs.csproj
- In "Solution Explorer", in your new project, click "add references", navigate to "projects/solution" on the left bar, add "aktos_dcs_cs"
- In "Solution Explorer", click
-
In your project, add
using aktos_dcs_cs;
line at the top of the file. -
Create and use classes that are using
Actor
s. (see below) -
Prevent your program from ending.
Add something that will block your main loop's execution (like "Press a key to continue" line) or if your application is a GUI application, it probably has its own main loop, which will suffice. You may also simply add
Actor.wait_all()
at the end of program, which is a forever sleeping loop under the hood. -
See your objects are messaging with each other.
There are 2 way of usage aktos_dcs_cs.Actor
in your application.
- Create classes that are inherited from
Actor
and do any of your application work in these classes. - Create an
Actor
based class and use it in another class as a communicator object.
- Create any number of classes which are inherited from
Actor
- Do your blocker works in
public override action(){ ... }
method - Send any message to others via
send(object)
method - Receive others' messages via
public override receive(message){ ... }
method - Receive others' messages via
public handle_SUBJECT(message){...}
methods if you know the subject. - Initialize your objects from these
Actor
based classes
-
Create a class (
MyCommunicator
) based onActor
which will serve youranother class
as a communicator object (like in the example) -
In your communicator class, define events as
public event msg_callback event_SUBJECT;
. Any message which has theSUBJECT
subject will trigger this event. -
Define a handler in your
another class
that will handle messages aboutSUBJECT
, preferably define them asprivate void handle_SUBJECT(Dictionary<string, object> msg) { // use "msg" now as incoming message }
-
Create a
communicator_object
and add your handler method to the event handler in youranother class
' constructor, like:MyCommunicator comm = new MyCommunicator(); comm.event_SUBJECT += handle_SUBJECT;
-
Send any message to others via
comm
object'ssend()
method, ascomm.send(object)
.
Note: DO_NOT perform blocker operations in receiver methods.