Author Topic: FOnlineServer with Mono  (Read 21637 times)

Offline Bartosz

  • Rotator
  • There'd better be a killer reason...
FOnlineServer with Mono
« on: December 06, 2012, 10:25:08 am »
Hello,

As of rev383 of the SDK I decided to commit the files of the (rather big) functionality I've been working on lately: embedding Mono runtime in the server to allow write scripts in .NET languages.

The files are placed under Server/mono directory and do not affect the current state of SDK. They're meant for testing purposes (the work done was rather large, and sometimes tedious, many bugs could slipped in).

Instructions

To try it out, follow the steps:
1. Replace your FOnlineServer.exe and FOnlineServer.pdb files with the one from mono directory.
2. Check the mono/FOnlineServer.cfg file and copy the lines from # Mono runtime section, most importantly:
Code: [Select]
MonoEnabled=1
MonoLibDir=mono/lib
  The rest is optional.
3. Use either Visual Studio or MonoDevelop to build the provided solution file: mono/FOnline.Mono.sln. The resulting files will be copied to Server directory.
4. Run the server, you should see some mono related messages, most notably 'Initializing mono' and 'Init from mono!' that will tell you everything is OK.

Debugging
There are several ways you can debug your code (and even aid in debugging AS code).

REPL console:

It's possible to start server with console that is evaluating C# statements on the fly. Just add -mono_repl to your server command line.


Line-by-line debugging with MonoDevelop' Soft Debugger:

1. Fetch mono runtime (latest version is 3.0.2, the server currently is integrated with 3.0.1, it should work fine) from their download page.
2. Install it.
3. Fetch MonoDevelop, install it, and before starting, set MONODEVELOP_SDB_TEST environment variable to 1.
4. Now, start MonoDevelop, go to Tools->Options->.NET runtimes and add the one you've installed in step 2. Mark it as default.
5. Open FOnline.Mono.sln, place some breakpoint and choose Run->Run with...->Custom Command Mono Soft Debugger and enter the path to FOnlineServer.exe in Command textbox
6. Choose whatever command line you wish, and add -mono_debug
7. Click listen, and wait for server to be started and your breakpoint hit.
8. Enjoy:


More info
The project contains few scripts that mimic few scripts from Den location, this is to show briefly how writing scripts in C# looks like. For more information refer to: wiki page on our trac.
« Last Edit: December 06, 2012, 12:54:30 pm by scypior »

Offline Gob

  • The Good
Re: FOnlineServer with Mono
« Reply #1 on: December 06, 2012, 12:21:16 pm »
So what? Instead of AngelScript I can now do VB.NET or C# or C++?

Offline Bartosz

  • Rotator
  • There'd better be a killer reason...
Re: FOnlineServer with Mono
« Reply #2 on: December 06, 2012, 12:25:46 pm »
...or F#.

And not really 'instead', rather 'additionally'.

Offline Gob

  • The Good
Re: FOnlineServer with Mono
« Reply #3 on: December 06, 2012, 12:27:10 pm »
F# huh? I might give it a try. This sure is good news.

Offline Bartosz

  • Rotator
  • There'd better be a killer reason...
Re: FOnlineServer with Mono
« Reply #4 on: December 06, 2012, 12:45:41 pm »
Added info about debugging.

Offline Gob

  • The Good
Re: FOnlineServer with Mono
« Reply #5 on: December 06, 2012, 11:18:37 pm »
Error: Forbidden
WIKI_VIEW privileges are required to perform this operation on MonoScripting

Offline Bartosz

  • Rotator
  • There'd better be a killer reason...
Re: FOnlineServer with Mono
« Reply #6 on: December 06, 2012, 11:29:30 pm »
You need to login with you forum credentials.

Offline wladimiiir

  • Rotator
  • Independent FOnline developer
Re: FOnlineServer with Mono
« Reply #7 on: December 07, 2012, 12:39:24 am »
Very impressive and exciting. :)

Would it be technically possible to use Java the same way?

Offline Bartosz

  • Rotator
  • There'd better be a killer reason...
Re: FOnlineServer with Mono
« Reply #8 on: December 07, 2012, 05:40:39 am »
Apperently, there is some possibility to run Java under mono, but I wouldn't even try...why everyone asks about that Java lang. Is it any good?  ;D

Offline wladimiiir

  • Rotator
  • Independent FOnline developer
Re: FOnlineServer with Mono
« Reply #9 on: December 07, 2012, 07:39:47 am »
Sure, Java is the best. Well, almost... ;D
Java is platform independent and has better IDE support, maybe that's why it rules the world. ;)

But I would like to use it because I am used to it (which makes it faster to develop) and it really has better IDE support than .NET.

But thanks anyway, I found some possibility to use Java from Mono, too, I will have a look and keep you informed whether it is worth it. ;)

Offline Bartosz

  • Rotator
  • There'd better be a killer reason...
Re: FOnlineServer with Mono
« Reply #10 on: December 07, 2012, 08:49:10 am »
Well, but if you are talking about IDE, you would probably want to check if there is mono soft debugger plugin for it, otherwise you won't be able to debug your code in it (and I think debugging is significant part of IDE functionality).
« Last Edit: December 07, 2012, 09:31:38 am by scypior »

Offline wladimiiir

  • Rotator
  • Independent FOnline developer
Re: FOnlineServer with Mono
« Reply #11 on: December 07, 2012, 09:27:02 am »
Code completion, refactoring and debugging, for sure. Thanks, I'll have a look.

Offline Mr Feltzer

  • FOnline: Australia
    • The Core Gaming Australia's Website
Re: FOnlineServer with Mono
« Reply #12 on: December 24, 2012, 02:22:36 am »
Oh this sort of Debugging method would have been very helpful a long time ago. Still, Notepad++ has grown on me..
Founder of Fallout Online Australia

Re: FOnlineServer with Mono
« Reply #13 on: February 10, 2013, 06:14:59 pm »
I cant get it working .After " Initializing mono" it crashes.
Code: [Select]
[00:038] FOnline server, version 0504-EB.
[01:621] ***   Starting initialization   ****
[01:630] Initializing mono...
I tried it on newest downloaded sdk. I did it like you said in first post.
I replaced .exe and .pdb files
I added in .cfg:
Code: [Select]
MonoEnabled=1
MonoLibDir=mono/lib
and i built solution file (with some warnings) in visual studio 2012
additionally i had to copy from mono dir file mono-2.0.dll otherwise server wont start
Can you tell me what i'm doing wrong?
I can give you dumps if needed.

(windows 7 x64)

Offline Bartosz

  • Rotator
  • There'd better be a killer reason...
Re: FOnlineServer with Mono
« Reply #14 on: February 10, 2013, 06:37:46 pm »
I think there is problem with latest mono-2.0.dll, could you try with one from rev383?