logo logo

 Back to main page

The NWNX Community Forum

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
.Net plugin?

 
Post new topic   Reply to topic    nwnx.org Forum Index -> Windows development
View previous topic :: View next topic  
Author Message
Baaleos



Joined: 02 Sep 2007
Posts: 830

PostPosted: Mon Apr 02, 2012 14:33    Post subject: .Net plugin? Reply with quote

Hi Anyone-
Could someone please try to re-create the .Net plugin for nwnx2.

Eg - A plugin that can then call methods within a .Net managed code assembly.


There was one by Ronchese however the links are now dead, and cannot find it anywhere on the web.
Back to top
View user's profile Send private message
Baaleos



Joined: 02 Sep 2007
Posts: 830

PostPosted: Wed Apr 04, 2012 12:33    Post subject: would this work? Reply with quote

ok - In absence of an answer or help.
Could someone even at least give me their opinion as to whether this would be the right way to impliment a nwnx_DotNet plugin


Im thinking

1. Arguements passed from nwn to nwnx would be

SetLocalString(GetModule(),"NWNX!DOTNET!EXECUTE","NameOfAssembly¬MethodToCall¬Args");
//MethodToCall would be the method we want to call - Execution can be done via a Hashtable storing associations between names of functions, and the functions themselves. (allows referencing the functions by name)
//Args could be delimitated by some other character

2. In the nwnx plugin, we would have a class or implimentation like this
http://www.codeproject.com/Articles/12662/Unmanaged-to-Managed-calls-C-to-C-without-Regasm

3. So nwnx receives a request
NWNX!DOTNET!EXECUTE - with value of
"MailFuncs¬SendEmail¬Sir|Hi There this is a test of an e-mail DLL"

It decides that it needs to
Make a call to MailFuncs.dll
Execute the Method SendEmail
and Feed in the Arguments
Sir, and Hi There this is a ...... (you get the picture)


SendEmail then uses these arguments to send the relevant e-mail.


At the moment, e-mail functionality and such can be done via odbc and cron-jobs in php etc.

This way, you could actually get complex .Net functionality to be kicked off immediately from inside a game, without relying on the heartbeat event.

It also possibly adds the possibility of Thread Creation for background tasks.

eg- If you want to do a complex task such as Mass Mailing all your players - you dont necessarily want to do this on the nwnx thread.

The ideal solution would be to kick of another thread that does the task, and then just return a 1 to the nwnx thread (return value for game), to indicate that the thread was kicked off, then after that point - we just forget about the thread, and hope we have enough error handling inside to handle any situation.


So - can anyone tell me
Does the code referenced at the website Address I found - look like it could be used in a nwnx plugin?
I'd like to try - but I dont want to waste my time if it turns out to be impossible.

C# Dll's/Functionality I have in mind include
FetchWebsite - trigger complex functions stored on php pages, via a call to the php page.
TcpClient or UDPClient - I have a Resource Downloader application that players use to download custom content and music. Checking to see if the Player responds on the tcp port would indicate presence of the Resource Downloader app - therefore indicating they have the custom content.

and im sure lots more possibilities would open up with .Net C# becoming available.
Back to top
View user's profile Send private message
ronchese



Joined: 30 Dec 2007
Posts: 30

PostPosted: Thu Sep 13, 2012 18:47    Post subject: Re: .Net plugin? Reply with quote

Do you still need it? I have the source code right at my hand.


Baaleos wrote:
Hi Anyone-
Could someone please try to re-create the .Net plugin for nwnx2.

Eg - A plugin that can then call methods within a .Net managed code assembly.


There was one by Ronchese however the links are now dead, and cannot find it anywhere on the web.
Back to top
View user's profile Send private message
Baaleos



Joined: 02 Sep 2007
Posts: 830

PostPosted: Thu Sep 13, 2012 20:26    Post subject: Reply with quote

Hell yeah!!
Baaleos@azmodan.net
Please
Back to top
View user's profile Send private message
ronchese



Joined: 30 Dec 2007
Posts: 30

PostPosted: Thu Sep 13, 2012 21:05    Post subject: Done Reply with quote

Sent. If anyone else need it, just ask.
Back to top
View user's profile Send private message
Baaleos



Joined: 02 Sep 2007
Posts: 830

PostPosted: Fri Sep 14, 2012 0:12    Post subject: thanks Reply with quote

Thanks,
Im working on the nwnxAssembly project now - Im creating a c# version that is capable of accessing other dll's in a plugin centric approach.
(currently working on the conversion of the regex class to c#)
I have the following code from a project I worked on before - that used c# plugin systems.

I plan on making it possible for your nwnx .net plugin, to not only call c# methods inside the nwnxAssembly (the dotNet one), but to use it, to then call other dll's in a plugin centric fassion.



This function more a less assumes that the dll being targetted will have a common interface with which to connect to/instantiate.
If it does- it creates an instance of it, and then stores it for later - allowing it to receive commands.
The commands are then fed into the stored instance, and output can be returned to the caller.
Code:

 private void LoadPlugins()
        {
            IsLoadingPlugins = true;
            string path = System.Windows.Forms.Application.StartupPath;
            string[] pluginFiles = Directory.GetFiles(path, "*.dll");
            ipi = new IPlugin[pluginFiles.Length];

            for (int i = 0; i < pluginFiles.Length; i++)
            {
                string args = pluginFiles[i].Substring(
                    pluginFiles[i].LastIndexOf("\\") + 1,
                    pluginFiles[i].IndexOf(".dll") -
                    pluginFiles[i].LastIndexOf("\\") - 1);

                Type ObjType = null;
                //IPlugin ipi;
                // load the dll
                try
                {
                    // load it
                    Assembly ass = null;
                    ass = Assembly.Load(args);
                    if (ass != null)
                    {
                        ObjType = ass.GetType(args + ".PlugIn");
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                try
                {
                    // OK Lets create the object as we have the Report Type
                    if (ObjType != null)
                    {
                        ipi[i] = (IPlugin)Activator.CreateInstance(ObjType);
                        ipi[i].Host = this;
                        //Console.WriteLine("ipi.Add(1,2)=" + ipi[i].Add(1, 2));
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }

                //            Start(assemname);
            }
            IsLoadingPlugins = false;
        }


Back to top
View user's profile Send private message
ronchese



Joined: 30 Dec 2007
Posts: 30

PostPosted: Fri Sep 14, 2012 0:25    Post subject: Plugins on Plugins? =] Reply with quote

Hehe now we opened the nested plugins gate! Thats interesting, and C# will make things real easier (I prefer C# nowadays).

If you need some help, just ask.
Back to top
View user's profile Send private message
Baaleos



Joined: 02 Sep 2007
Posts: 830

PostPosted: Fri Sep 14, 2012 0:30    Post subject: Reply with quote

Yeah C# is alot easier to understand.

The project I worked on before, was a plugin based application for work (it monitored lab machines etc, and each plugin did a different function)

I plan on changing your vb assembly, to be a c# PluginHost assembly, that then calls other assemblies etc.


The funny querk is - I dont really need this functionality - I just think it would be cool to have.Lol

Kinda like the tattoo im getting on saturday - it looks so good in the sims.
http://dl4sims.wordpress.com/2012/06/22/lgp-tattoo-131/

LMAO
Back to top
View user's profile Send private message
Zunath



Joined: 06 Jul 2006
Posts: 183

PostPosted: Tue Dec 25, 2012 23:12    Post subject: Reply with quote

Any chance I could get a copy of this as well? Maybe even get it posted to the vault so everyone can access it?

Thanks
Back to top
View user's profile Send private message
Baaleos



Joined: 02 Sep 2007
Posts: 830

PostPosted: Wed Dec 26, 2012 17:49    Post subject: Reply with quote

A copy of what specifically?

The DotNet plugin is already public
Back to top
View user's profile Send private message
Zunath



Joined: 06 Jul 2006
Posts: 183

PostPosted: Thu Dec 27, 2012 0:53    Post subject: Reply with quote

Found the link.

Just in case anyone needs it in the future here it is: http://www.nwnx.org/phpBB2/viewtopic.php?t=1002
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Windows development All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group