How to put a command into a DLL library

Apr 24, 2012 at 6:26 PM

Hi,

I created custom server, session, subprotocol classes, and I put all custom implementation code into a DLL library, so that I can be easily integrate it into EXE in future. It also makes it easy to test customer server logic.

The server code include some command, such as:

public class MYCOMMAND: SubCommandBase<MyServerSession>
{
    public override void ExecuteCommand(MyServerSession session, StringCommandInfo commandInfo)
    {
        session.DoMyWork(commandInfo.Data);
    }
}

I found that if putting MYCOMMAND class in my final EXE, it works. But, if in DLL and linked into EXE, it does not work. I do not fully understand how COMMAND framework works in supersocket at present. My question is if possible, to put MYCOMMAND into DLL and link it into EXE. For example, this will make it easier for me to test the DLL with NUNIT.

 

Thanks.

Coordinator
Apr 25, 2012 at 2:14 AM

I am not quite understand you. But the test project is a NUnit test project which can give you some guide.

Apr 25, 2012 at 8:16 AM

Hi Kerry,

Sorry for not clearly describe the issue. This is what I am doing:

1) Create websocket server.exe and client.exe.

2) Create class MYCOMMAND in server.exe. In client.exe, it calls the command. The server is able to get the call from client. It works as expected!!!

3) I want to make server project little flexible. And I put class MYCOMMAND file (such as classMycommand.cs) into a DLL, called serverlib.dll. I link serverlib.dll with server.exe.

4) If client.exe makes same call to MYCOMMAND, the server.exe is not able to receive the call from client.

5) serverlib.dll has a lot of other business logic. MYCOMMAND class is part of it. That's the reason serverlib.dll is created. I can be link it with NUnit or web server.

6) I have to add the file classMycommand.cs into server.exe, then server is able to receive client call. Basically, MYCOMMAND in serverlib.dll is useless.

I am not sure if I missed something. My question is is it suppose to work or not? If it should, what I missed.

Thanks.

 

Coordinator
Apr 25, 2012 at 8:26 AM

Sorry, I don't know what is your the link action?

1) By default, SuperSocket only search commands in the assembly where AppServer is defined.

2) You can define your sub protocol assemblies in configuration:

http://superwebsocket.codeplex.com/SourceControl/changeset/view/76679#1409288

3) You also can pass in the sub protocol command assemblies by BasicSubProtocol, the constructor of class BasicSubProtocol accept assemblies parameter

http://superwebsocket.codeplex.com/SourceControl/changeset/view/76679#1410241