MonaSolutions / MonaServer2

Temporary project planned to replace MonaServer
GNU General Public License v3.0
274 stars 36 forks source link

Language Agnostic VM integration for server side application development in C++ project #29

Open al-sabr opened 4 years ago

al-sabr commented 4 years ago

Greetings again!

I was wondering how complicated can it be to just give MonaServer2 connection handle to this AS3 virtual machine for validating a connection and decide if the connection will happen or not?

It seems that it is well implemented I am just wondering how complicated is it? Is there any tutorial available to where to go to maybe able to try a small implementation in code...

https://github.com/drywolf/caspin

There is a sample folder how to use it and it doesn't seem to be a mystical process...

https://github.com/drywolf/caspin/tree/master/samples Let me know

thanx

thomasjammet commented 4 years ago

Hi

I do not recommend to add support to AS3 anymore as all projects of AS3 implementation in the browser like Tamarin are obsolete now. Though if you are decided to give it a try you can easily implement your own MonaTiny onConnection implementation. To reject a connection you just have to set an exception after this line : https://github.com/MonaSolutions/MonaServer2/blob/master/MonaTiny/sources/MonaTiny.cpp#L99 Like this :

void MonaTiny::onConnection(Exception& ex, Client& client, DataReader& inParams, DataWriter& outParams) {
    DEBUG(client.protocol, " ", client.address, " connects to ", client.path.empty() ? "/" : client.path)
    ex.set<Ex::Permission>("Forbidden");
    const auto& it(_applications.find(client.path));
    if (it == _applications.end())
        return;
    client.setCustomData<App::Client>(it->second->newClient(ex,client, inParams, outParams));
}

In this source file you can easily custom your MonaTiny version, take a look at onPublish and onSubscribe methods which allow to reject publications and subscriptions too.

And Happy New Year !

al-sabr commented 4 years ago

Thank you for the quick response. I am not planning to do anything in the browser as you suggested. I was more thinking about the possibility next to Lua as a scripting language you could provide the possibility with your API an abstraction level where we could just plug any kind of VM like AVM2 or Yaegi which can interpret Golang code.

AS3 in the Browser is not dead at all. To get the correct facts concerning AS3 you can run your actual apps in browser without Flash plugin with Apache Royale. You can also make CLI applications with redtamarin on Windows Linux and MacOs. And there's a dude who started an wasm2swf compiler and a swf2wasm.

al-sabr commented 4 years ago

It would be great that Mona2 is Lua agnostic. IMHO this would be a better design choice.

Happy new year as well :grinning:

al-sabr commented 4 years ago

OK I did some research and IMHO the following is the best design decision I've come up with because of my dissatisfaction of the possibility to bring some handicap to Mona2 and force Lua down the throat for everyone. These are the marvelous possibilities which are ahead of us for Mona2 and will make it the unrivaled solution for the future.

al-sabr commented 4 years ago
al-sabr commented 4 years ago

I will change the title of this thread to Language Agnostic VM integration for server side application development.

al-sabr commented 4 years ago

Any feedback for this design implementation idea?

thomasjammet commented 4 years ago

Hi,

Those are all interesting VM and if you find time to implement one of them it is definitely possible. As you know MonaTiny is the MonaServer version without LUA support so it is a good start to add another VM support by watching how LUA is integrated in MonaServer code. Though it is time consuming to add support to another VM and LUA is not event yet perfectly added to MonaServer2 (still in test) so we absolutely can't do it by ourself. By the way we have chosen luajit for its extremly good performances, the possibility to rebuild server applications at runtime and its small weight (less than 500Kb). You can write complex server application in lua and use C library to extend the possibilities.

al-sabr commented 4 years ago

How about coming up with an abstraction level API that is language agnostic don't you think that is an important thing to think about?

al-sabr commented 4 years ago

What are the part of Mona which needs to be sent on the VM side so that the VM can manipulate objects while it's executing its code?

al-sabr commented 4 years ago

I also don't understand why is it not possible with Mona to directly use C++ plug-ins system instead of Lua. CppMicroservices is actually that runtime interface for C++ native extensions as DLL/dynlib/so.