SupperWebSocket: Multiple command Assembly not work

Jan 11, 2016 at 9:24 AM
Dear Mr. Kerry Jiang
I'm Tuyen come from Vietnam.
First, sorry for low level my English skill.

I have downloaded SupperWebSocket source code and try use your sample [C-StartByConfig]. In the config file [app.config] I see your comment [you can add more command assemblies]. And I add [SupperWebSocket.Samples.JsonCommandAssembly] (by [F-JsonCommandAssembly] project).
Now, in the config file have 2 command assembly (SupperWebSocket.Samples.JsonCommandAssembly and SupperWebSocket.Samples.CommandAssembly).
After that, I start server [C-StartByConfig] and in the log file [logs\debug.log] only show list commands of JsonCommandAssembly, list commands of [SupperWebSocket.Samples.CommandAssembly] not loaded.
I try swap order of config in <commands> node:
[SupperWebSocket.Samples.JsonCommandAssembly] fist, [SupperWebSocket.Samples.CommandAssembly] last,
and I restart server. Now, see in logfile, only commands of [SupperWebSocket.Samples.CommandAssembly] loaded.

I have review source code and see:
In the CommandConfig class (namespace SupperWebSocket.Config), the function OnDeserializeUnrecongnizeAttribute, the Options variable always null and only assigned last value of <commands> config node.

Plz help me use this sample to load more command assembly.

Thanks you very much
Tuyen
Coordinator
Jan 11, 2016 at 11:36 AM
Could you show me your configuration file?

BTW, your commands should be public.
Jan 11, 2016 at 12:53 PM
Edited Jan 11, 2016 at 12:55 PM
Dear Mr. Kerry Jiang
This is my config file:
I added [<add assembly="SuperWebSocket.Samples.JsonCommandAssembly"/>] . [SuperWebSocket.Samples.JsonCommandAssembly] is your assembly builded from [F-JsonCommandAssembly] project.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="superSocket" type="SuperSocket.SocketEngine.Configuration.SocketServiceConfig, SuperSocket.SocketEngine"/>
  </configSections>
  <appSettings>
    <add key="ServiceName" value="SuperWebSocket"/>
  </appSettings>
  <superSocket>
    <servers>
      <server name="SuperWebSocket"
              serverTypeName="SuperWebSocket">
        <certificate filePath="localhost.pfx" password="supersocket"></certificate>
        <listeners>
          <add ip="Any" port="2012"/>
          <add ip="Any" port="2013" security="tls"/>
        </listeners>
       
        <subProtocols>
          <protocol>
            <commands>
              <add assembly="SuperWebSocket.Samples.CommandAssembly"/>
             <!--Tuyen added-->
              <add assembly="SuperWebSocket.Samples.JsonCommandAssembly"/>
              <!--
              you can add more command assemblies
              <add assembly="SuperWebSocket.Samples.CommandAssembly2"/>
              <add assembly="SuperWebSocket.Samples.CommandAssembly3"/>
              -->
            </commands>
          </protocol>
        </subProtocols>
      </server>
    </servers>
    <serverTypes>
      <add name="SuperWebSocket"
           type="SuperWebSocket.WebSocketServer, SuperWebSocket" />
    </serverTypes>
  </superSocket>
</configuration>
and this is log file:
2016-01-11 15:58:42,879 [5192] DEBUG DefaultBootstrap - The server instance SuperWebSocket has been created!
2016-01-11 15:58:42,962 [5192] DEBUG SuperWebSocket - SubProtocol Basic found the commands below:
ADD
ADDX
CHAT
ECHO

2016-01-11 15:58:42,981 [5192] DEBUG DefaultBootstrap - The server instance SuperWebSocket has been initialized!
2016-01-11 15:58:44,493 [5192] DEBUG DefaultBootstrap - The PerformanceMonitor has been initialized!
2016-01-11 15:58:44,493 [5192] DEBUG DefaultBootstrap - The Bootstrap has been initialized!
2016-01-11 15:58:44,504 [5192] DEBUG SuperWebSocket - Listener (0.0.0.0:2012) was started
2016-01-11 15:58:44,504 [5192] DEBUG SuperWebSocket - Listener (0.0.0.0:2013) was started
2016-01-11 15:58:44,508 [5192] DEBUG DefaultBootstrap - The PerformanceMonitor has been started!
logfile only found the commands of [SuperWebSocket.Samples.JsonCommandAssembly]. Not have commands of [SuperWebSocket.Samples.CommandAssembly].

Thanks for your support
Tuyen
Coordinator
Jan 13, 2016 at 11:36 AM
Could you show me the code of the command which is not discovered?
Jan 14, 2016 at 6:54 AM
Dear Mr. Kerry Jiang
This is MULT command which is not discovered:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SuperWebSocket.SubProtocol;

namespace SuperWebSocket.Samples.CommandAssembly
{
    public class MULT : SubCommandBase
    {
        public override void ExecuteCommand(WebSocketSession session, SubRequestInfo requestInfo)
        {
            var paramArray = requestInfo.Body.Split(' ');

            session.Send((int.Parse(paramArray[0]) * int.Parse(paramArray[1])).ToString());
        }
    }
}
Jan 14, 2016 at 7:11 AM
Dear Mr. Kerry Jiang
My source code is your source code downloaded from:
https://superwebsocket.codeplex.com/releases/view/101471

I only add
 <!--Tuyen added-->
              <add assembly="SuperWebSocket.Samples.JsonCommandAssembly"/>
into [SuperWebSocket.Samples.StartByConfig.exe.config] of [C-StartByConfig]