xsockets.net

XSockets.NET 4.0 - new controller instance created on method call


After upgrading my .NET server and client projects to 4.0 RC I get NullReference exceptions because my custom State object is null. I instantiate the state property in OnOpen event handler, but inside the method body of the first call it is already null.

I have checked in debugger and see that this.GetHashCode() returns different values in OnOpen event handler and in method, which means it is a different instance.

Is it a known issue? I assume it is very basic behavior and probably I have missed something during upgrade to new version.

Thanks in advance.


Solution

  • When using alias there is a bug (as you have found out). The workaround is to either use the class name of the controller or only have alias in lower casing.

    In your case using

    [XSocketMetadata(PluginAlias = "test")]
    

    would work.

    Regards Uffe