Search Unity

WAMP Protocol in Unity?

Discussion in 'Multiplayer' started by Selzier, Dec 31, 2017.

  1. Selzier

    Selzier

    Joined:
    Sep 23, 2014
    Posts:
    652
    WAMP is an open standard WebSocket subprotocol that provides two application messaging patterns in one unified protocol: Remote Procedure Calls + Publish & Subscribe
    http://wamp-proto.org/

    Because multiplayer games use RPCs calls, this seems very useful in Unity. I've found a C# project called WampSharp:
    https://github.com/Code-Sharp/WampSharp

    I've imported the DLLs into Unity 2017.3.0f3 but I'm getting an error:

    Code (CSharp):
    1.  
    2. Exception: RemoteCertificateChainErrors
    3. Rethrow as AggregateException: One or more errors occurred.
    4. System.Threading.Tasks.Task.ThrowIfExceptional (System.Boolean includeTaskCanceledExceptions) (at <c95265f74fdf4905bfb0d5a4b652216c>:0)
    5. System.Threading.Tasks.Task.Wait (System.Int32 millisecondsTimeout, System.Threading.CancellationToken cancellationToken) (at <c95265f74fdf4905bfb0d5a4b652216c>:0)
    6. System.Threading.Tasks.Task.Wait (System.Int32 millisecondsTimeout) (at <c95265f74fdf4905bfb0d5a4b652216c>:0)
    7. WAMPClientTest.Main () (at Assets/WAMPClientTest.cs:27)
    8.  
    I've reported the error as an Issue at GitHub:
    https://github.com/Code-Sharp/WampSharp/issues/224

    However, it's possible I've just made a mistake or there's a problem with experimental 4.6 API build in Unity?

    If you have any insight, please help out :)
     
  2. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
  3. Selzier

    Selzier

    Joined:
    Sep 23, 2014
    Posts:
    652
    I could not get the DLLs to work inside of Unity, even using .Net 4.6 build. Here's the exception:
    Code (CSharp):
    1.  
    2. InvalidCastException: Specified cast is not valid.
    3. System.Reactive.PlatformServices.PlatformEnlightenmentProvider.CreatePlatformProvider () (at <688278ad98cb433c8f7d49b6fa93b621>:0)
    4. System.Reactive.PlatformServices.PlatformEnlightenmentProvider..cctor () (at <688278ad98cb433c8f7d49b6fa93b621>:0)
    5. Rethrow as TypeInitializationException: The type initializer for 'System.Reactive.PlatformServices.PlatformEnlightenmentProvider' threw an exception.
    6. System.Reactive.Linq.QueryServices.Initialize () (at <dae9ef48b730438fa95f19e6ce1d672c>:0)
    7. System.Reactive.Linq.QueryServices..cctor () (at <dae9ef48b730438fa95f19e6ce1d672c>:0)
    8. Rethrow as TypeInitializationException: The type initializer for 'System.Reactive.Linq.QueryServices' threw an exception.
    9. System.Reactive.Linq.Observable..cctor () (at <dae9ef48b730438fa95f19e6ce1d672c>:0)
    10. Rethrow as TypeInitializationException: The type initializer for 'System.Reactive.Linq.Observable' threw an exception.
    11. WampSharp.V2.WampClientSubject.CreateObservable (WampSharp.V2.Client.IWampTopicProxy topic, WampSharp.V2.Client.IWampClientConnectionMonitor monitor) (at C:/Users/Selzier/Desktop/WampSharp-1.2.7.45-beta/src/net45/WampSharp/WAMP2/V2/Api/Rx/WampClientSubject.cs:27)
    12. WampSharp.V2.WampClientSubject..ctor (WampSharp.V2.Client.IWampTopicProxy topic, WampSharp.V2.Client.IWampClientConnectionMonitor monitor) (at C:/Users/Selzier/Desktop/WampSharp-1.2.7.45-beta/src/net45/WampSharp/WAMP2/V2/Api/Rx/WampClientSubject.cs:22)
    13. WampSharp.V2.WampRealmProxyServiceProvider.GetSubject (System.String topicUri) (at C:/Users/Selzier/Desktop/WampSharp-1.2.7.45-beta/src/net45/WampSharp/WAMP2/V2/Api/Client/WampRealmProxyServiceProvider.cs:104)
    14. WampSharp.V2.WampRealmProxyServiceProvider.GetSubject[TEvent] (System.String topicUri) (at C:/Users/Selzier/Desktop/WampSharp-1.2.7.45-beta/src/net45/WampSharp/WAMP2/V2/Api/Client/WampRealmProxyServiceProvider.cs:93)
    15. WAMPClientTest.Main () (at Assets/WAMPClientTest.cs:40)
    16.  
    I opened an issue on Gibhub and the developer indicated there seems to be an issue with System.Reactive:
    https://github.com/Code-Sharp/WampSharp/issues/224
    He asked me to try to reference the .NET Standard 2.0 dlls, which means I would have to wait for the 2018 Beta.
     
    Last edited: Jan 3, 2018
  4. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    I meant, were you able to get WAMP working OUTSIDE of Unity first, as a test.
     
  5. OC01

    OC01

    Joined:
    Sep 25, 2017
    Posts:
    1
    I got the same InvalidCastException in my app. My app refers to System.Reactive.Core/Linq/Interface 3.1.1 nuget packages.

    The static constructor of the Observable class in System.Reactive.Core tries to load System.Reactive.PlatformServices by reflection if it exists. In Unity, the PlatformServices is found in MonoBleedingEdge/lib/mono/4.5 but its version is 2.2.0. And then, the cast is invalid because of loading the same class from other versions.