Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using SignalR core with Unity and IL2CPP (AOT) #12102

Open
thorgeirk11 opened this issue Jul 11, 2019 · 64 comments
Open

Using SignalR core with Unity and IL2CPP (AOT) #12102

thorgeirk11 opened this issue Jul 11, 2019 · 64 comments
Labels
affected-few This issue impacts only small number of customers area-signalr Includes: SignalR clients and servers enhancement This issue represents an ask for new feature or an enhancement to an existing one investigate severity-major This label is used by an internal tool
Milestone

Comments

@thorgeirk11
Copy link

thorgeirk11 commented Jul 11, 2019

I am having a similar issue as #10080. I am using preview 6 of asp.net core SignalR client inside of unity and compiling with IL2CPP. I created a small git repo with the code I use to reproduce this issue

I am running into an exception when starting the connection:

connection = new HubConnectionBuilder()
   .WithUrl("http://localhost:5000/gamehub")
   .Build(); // works fine

await connection.StartAsync(); // takes a few sec before failing

The connection.StartAsync fails with the following exception:

InvalidDataException: Missing required property 'connectionId'.
  at Microsoft.AspNetCore.Http.Connections.NegotiateProtocol.ParseResponse (System.ReadOnlySpan`1[T] content)

Unity's IL2CPP strips unused assemblies. It caused another issue but I fixed that by adding link.xml file. So the issue described here should not be affected by code stripping.

Here are the server and client traces.

@thorgeirk11 thorgeirk11 changed the title Using SignalR core with Unity using IL2CPP (AOT) Using SignalR core with Unity and IL2CPP (AOT) Jul 11, 2019
@BrennanConroy BrennanConroy added the area-signalr Includes: SignalR clients and servers label Jul 11, 2019
@BrennanConroy
Copy link
Member

I don't currently have unity on any of my work machines, but I might try this out on a personal machine to see if I can figure anything out.

Meanwhile, is it possible for you to grab the network trace so we can verify what payload the client is receiving from the server?

@thorgeirk11
Copy link
Author

thorgeirk11 commented Jul 14, 2019

@BrennanConroy I am not sure how to take a network trace. I set both of my server and client to verbose debug logging. The logs are included in the git repo above (server and client)

If I can provide better traces please let me know how :)

Also of note, when I build with the mono runtime the handshake succeeds. I would guess this is a client side error instead of server side.

Thanks for the help!

@analogrelay
Copy link
Contributor

@thorgeirk11 We have some guidance on network traces here: https://docs.microsoft.com/en-us/aspnet/core/signalr/diagnostics?view=aspnetcore-2.2

InvalidDataException: Missing required property 'connectionId'.

This indicates that the response from the server is incorrect (missing a required property). Can you provide a sample response from the localhost:5000/gamehub/negotiate endpoint (you can just use a browser to do this).

@analogrelay analogrelay added the Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. label Jul 16, 2019
@thorgeirk11
Copy link
Author

thorgeirk11 commented Jul 17, 2019

Unity apparently doesn't play well with fiddler so after testing out different tools I managed to get a network trace through WireShark. See NetworkTraces.zip

As far as I can see both the IL2CPP and Mono receive the same response.

Request:

POST /gamehub/negotiate HTTP/1.1
User-Agent: Microsoft.AspNetCore.Http.Connections.Client/3.0.0-preview6.19307.2
X-Requested-With: XMLHttpRequest
Content-Length: 0
Connection: keep-alive
Host: signalr-il2cpp-test.azurewebsites.net

Response:

HTTP/1.1 200 OK
Content-Length: 252
Content-Type: application/json
Server: Microsoft-IIS/10.0
X-Powered-By: ASP.NET
Set-Cookie: ARRAffinity=cfe9d88b4d05c4f99a90649b783196ca671405478765ab764374675d71877225;Path=/;HttpOnly;Domain=signalr-il2cpp-test.azurewebsites.net
Date: Wed, 17 Jul 2019 18:40:52 GMT

{"connectionId":"5wLJLrzOr3q7VfCRrGx-7w","availableTransports":[{"transport":"WebSockets","transferFormats":["Text","Binary"]},{"transport":"ServerSentEvents","transferFormats":["Text"]},{"transport":"LongPolling","transferFormats":["Text","Binary"]}]}

Can you investigate if the deserialization mechanism is AOT (IL2CPP) compatible?
Unity has wide adoption of IL2CPP and on some platform that is the only scripting runtime available, such as iOS and WebGL.

Please let me know if I can provide more info, check out the git repo for my simple project that reproduces this error.

@BrennanConroy BrennanConroy added investigate and removed Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. labels Jul 17, 2019
@BrennanConroy
Copy link
Member

I haven't gotten the chance to try out the repo project yet (thanks for that btw!).

I did take a glance at the project though, and how does it know what version of the client to download and use?

Also, could you try to replace the json protocol to use Newtonsoft and see if it works with that?

Here are the steps to switch to newtonsoft, note you need to add another package (for the link.xml file).

@crevelop
Copy link

@thorgeirk11 any update/success connecting from IL2CPP Unity client?

Sort of having the same issue ages ago and decided to use a plugin from the AssetStore by then.

But really looking fwd to using asp.net core SignalR client straight into Unity instead.

@aL3891
Copy link

aL3891 commented Aug 29, 2019

We would also really like to use the official signalR client in unity

@thorgeirk11
Copy link
Author

@crevelop Nope not yet, I guess the problem would be solved by switching out the serializer for an AOT friendly implementation. I have not spent much time on it. The game I am working on is on standalone and currently using Mono. However, in the coming months, I would like the option to switch to IL2CPP to export to WebGL.

@parkycai
Copy link

parkycai commented Sep 9, 2019

You may need to use Linker.xml to avoid field stripping

@thorgeirk11
Copy link
Author

Check out my repo. I induded a Linker.xml for all of the SignalR binaries.

@samoteph
Copy link

Hello @thorgeirk11 ! Is the SignalR core running with Unity finally ? I would like to integrate it on Hololens but at this time I've not found any documentation to do this. You are my last hope :)

@thorgeirk11
Copy link
Author

@samoteph It works out of the box for any platform that does not require IL2CPP.
However, it appears that MessagePack supports IL2CPP platforms. I will have to test it out for myself, but it looks promising.

@neal2018
Copy link

We also encounter this problem : (
Hope that it will get fixed.

@jhofer
Copy link

jhofer commented Feb 25, 2020

@samoteph It works out of the box for any platform that does not require IL2CPP.
However, it appears that MessagePack supports IL2CPP platforms. I will have to test it out for myself, but it looks promising.

Did you have any luck with messagepack?

@samoteph
Copy link

Finally, I rewrote my own sharing service with WebSocket as a communication channel

@samuelgoldenbaum
Copy link

Anyone get messagepack working? I added an entry to my link.xml file to the Microsoft.AspNetCore.SignalR.Protocols.MessagePack.dll, but I get missing constructor error.

@thorgeirk11
Copy link
Author

Yeah, we are currently using Messagepack successfully

@samuelgoldenbaum
Copy link

Yeah, we are currently using Messagepack successfully

@thorgeirk11 great to hear - to confirm: are you using it with IL2CPP (iOS)?

After downloading v3.1.2, I have extracted the netstandard2.0 Microsoft.AspNetCore.SignalR.Protocols.MessagePack.dll

I then added an additional entry in my link.xml file as follows:
<assembly fullname="Microsoft.AspNetCore.SignalR.Protocol.MessagePackHubProtocol" preserve="all"/>

Yet when I run it on a device, I get the following error:

InvalidOperationException: A suitable constructor for type 'Microsoft.AspNetCore.SignalR.Protocol.MessagePackHubProtocol' could not be located. Ensure the type is concrete and services are registered for all parameters of a public constructor.
  at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateConstructorCallSite (Microsoft.Extensions.DependencyInjection.ServiceLookup.ResultCache lifetime, System.Type serviceType, System.Type implementationType, Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteChain callSiteChain) [0x00000] in <00000000000000000000000000000000>:0 

Could you list the steps you guys are taking to get it working in your project?

My link.xml file:

<linker>
	<assembly fullname="System.Core">
		<type fullname="System.Linq.Expressions.Interpreter.LightLambda" preserve="all" />
	</assembly>
	<assembly fullname="MessagePack" preserve="all"/>
	<assembly fullname="Microsoft.AspNetCore.Connections.Abstractions" preserve="all"/>
	<assembly fullname="Microsoft.AspNetCore.Http.Features" preserve="all"/>
	<assembly fullname="Microsoft.AspNetCore.SignalR.Common" preserve="all"/>
	<assembly fullname="Microsoft.AspNetCore.SignalR.Protocol.MessagePackHubProtocol" preserve="all"/>
	<assembly fullname="Microsoft.Extensions.DependencyInjection.Abstractions" preserve="all"/>
	<assembly fullname="Microsoft.Extensions.Options" preserve="all"/>
	<assembly fullname="Microsoft.Extensions.Primitives" preserve="all"/>
	<assembly fullname="System.Buffers" preserve="all"/>
	<assembly fullname="System.IO.Pipelines" preserve="all"/>
	<assembly fullname="System.Memory" preserve="all"/>
	<assembly fullname="System.Numerics.Vectors" preserve="all"/>
	<assembly fullname="System.Runtime.CompilerServices.Unsafe" preserve="all"/>
	<assembly fullname="System.Threading.Tasks.Extensions" preserve="all"/>
	<assembly fullname="Microsoft.AspNetCore.Http.Connections.Client" preserve="all"/>
	<assembly fullname="Microsoft.AspNetCore.Http.Connections.Common" preserve="all"/>
	<assembly fullname="Microsoft.AspNetCore.SignalR.Client.Core" preserve="all"/>
	<assembly fullname="Microsoft.AspNetCore.SignalR.Client" preserve="all"/>
	<assembly fullname="Microsoft.AspNetCore.SignalR.Protocols.Json" preserve="all"/>
	<assembly fullname="Microsoft.Extensions.Configuration.Abstractions" preserve="all"/> 
	<assembly fullname="Microsoft.Extensions.Configuration.Binder" preserve="all"/>
	<assembly fullname="Microsoft.Extensions.Configuration" preserve="all"/>
	<assembly fullname="Microsoft.Extensions.DependencyInjection" preserve="all"/>
	<assembly fullname="Microsoft.Extensions.Logging.Abstractions" preserve="all"/>
	<assembly fullname="Microsoft.Extensions.Logging" preserve="all"/>
	<assembly fullname="System.ComponentModel.Annotations" preserve="all"/>
	<assembly fullname="System.Text.Json" preserve="all"/>
	<assembly fullname="System.Threading.Channels" preserve="all"/>
	<assembly fullname="Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson" preserve="all"/>
</linker>

@thorgeirk11
Copy link
Author

thorgeirk11 commented Mar 20, 2020

Ah I have yet to Port my project over to IL2CPP however I assume to get that working you would have to pre-compile a message pack parser.

@samuelgoldenbaum
Copy link

Ah I have yet to Port my project over to IL2CPP however I assume to get that working you would have to pre-compile a message pack parser.

Works fine under mono - but iOS now only allows IL2CPP which is the stumbling block.

Could you advise on process to pre-compile a message pack parser.

@youtpout
Copy link

youtpout commented Jan 9, 2021

Hello,
finally I can use SignalR on mobile with link.xml, but If i use enum in my model, the connection.On method in my client is never call, no problem on Unity editor.
If I replace enum by int it's work on both.

@jwittner
Copy link

@youtpout - mind sharing more details about your working setup? E.g. the link.xml file, how you configured the dlls, etc. Would love to get this working for us too. =)

@youtpout
Copy link

Exemple of project who works with enum in editor but not in IL2CPP mobile
https://github.com/youtpout/SignalREnum
https://github.com/youtpout/UnityEnum

@jwittner see UnityEnum, you have plugins folder with all files who works for me

@xabio
Copy link

xabio commented Feb 21, 2021

@youtpout how do you workaround the fact that sígnalr only works with 11.0.0 version of newtonsoft.json?
I am facing that issue.
I try to use the one ported to unity ecosystem but without luck(it is based on 12.0.0)
Thanks

@youtpout
Copy link

@xabio I use v12 without problem, see my project test plugins folder
https://github.com/youtpout/UnityEnum/tree/master/Assets/Plugins

@xabio
Copy link

xabio commented Feb 21, 2021

@youtpout And how did you managed to do that? last version of signalr depends on netwonsoft 11.0.0 right?
Did you managed to recompile it or how? Please your help is really important, I am really desesperated

@youtpout
Copy link

@xabio My bad, SignalR use textjson I think
https://www.nuget.org/packages/Microsoft.AspNetCore.SignalR.Common/
Dependencies
.NETStandard 2.0
Microsoft.AspNetCore.Connections.Abstractions (>= 5.0.3)
Microsoft.Extensions.Options (>= 5.0.0)
System.Text.Json (>= 5.0.1)

I include Newtosoft because I use HttpClient for rest api call on my real project.

@MGG2020
Copy link

MGG2020 commented Apr 13, 2021

Has anyone solved the problem with IL2CPP and SignalR Core?

@youtpout
Copy link

Has anyone solved the problem with IL2CPP and SignalR Core?

I can use SignalR Core with IL2CPP, the only problem for me is to use Messagepack...

See my project SignalREnum and UnityEnum

@michalpypek
Copy link

SignalR uses MessagePack in an unsupported way on Unity + IL2CPP:
it uses the nongeneric serialization method with signature:
public static void Serialize(Type type, ref MessagePackWriter writer, object obj, MessagePackSerializerOptions options = null)
and the nongeneric deserialization method with signature:
public static object Deserialize(Type type, ref MessagePackReader reader, MessagePackSerializerOptions options = null)

both of which are unsupported when building with IL2CPP.

1.See the lines on MessagePack's repository:
https://github.com/neuecc/MessagePack-CSharp/blob/1551f9344c28e822f08f3a00971ddb26229e5910/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePackSerializer.NonGeneric.cs#L247

https://github.com/neuecc/MessagePack-CSharp/blob/1551f9344c28e822f08f3a00971ddb26229e5910/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePackSerializer.NonGeneric.cs#L225

2.Notice that the SignalR code is calling both of them: https://github.com/dotnet/aspnetcore/blob/main/src/SignalR/common/Protocols.MessagePack/src/Protocol/DefaultMessagePackHubProtocolWorker.cs

3.SignalR won't work with MessagePack built with IL2CPP

NotSupportedException: MessagePackWriter/Reader overload is not supported in MessagePackSerializer.NonGenerics.
  at MessagePack.MessagePackSerializer+CompiledMethods.ThrowRefStructNotSupported () [0x00000] in <00000000000000000000000000000000>:0 
  at MessagePack.MessagePackSerializer+CompiledMethods+<>c.<.ctor>b__13_4 (MessagePack.MessagePackWriter& x, System.Object y, MessagePack.MessagePackSerializerOptions z) [0x00000] in <00000000000000000000000000000000>:0 
  at MessagePack.MessagePackSerializer+CompiledMethods+MessagePackWriterSerialize.Invoke (MessagePack.MessagePackWriter& writer, System.Object value, MessagePack.MessagePackSerializerOptions options) [0x00000] in <00000000000000000000000000000000>:0 
  at MessagePack.MessagePackSerializer.Serialize (System.Type type, MessagePack.MessagePackWriter& writer, System.Object obj, MessagePack.MessagePackSerializerOptions options) [0x00000] in <00000000000000000000000000000000>:0 
  at Microsoft.AspNetCore.SignalR.Protocol.DefaultMessagePackHubProtocolWorker.Serialize (MessagePack.MessagePackWriter& writer, System.Type type, System.Object value) [0x00000] in <00000000000000000000000000000000>:0 
  at Microsoft.AspNetCore.SignalR.Protocol.MessagePackHubProtocolWorker.WriteArgument (System.Object argument, MessagePack.MessagePackWriter& writer) [0x00000] in <00000000000000000000000000000000>:0 
  at Microsoft.AspNetCore.SignalR.Protocol.MessagePackHubProtocolWorker.WriteInvocationMessage (Microsoft.AspNetCore.SignalR.Protocol.InvocationMessage message, MessagePack.MessagePackWriter& writer) [0x00000] in <00000000000000000000000000000000>:0 
  at Microsoft.AspNetCore.SignalR.Protocol.MessagePackHubProtocolWorker.WriteMessageCore (Microsoft.AspNetCore.SignalR.Protocol.HubMessage message, MessagePack.MessagePackWriter& writer) [0x00000] in <00000000000000000000000000000000>:0 
  at Microsoft.AspNetCore.SignalR.Protocol.MessagePackHubProtocolWorker.WriteMessage (Microsoft.AspNetCore.SignalR.Protocol.HubMessage message, System.Buffers.IBufferWriter`1[T] output) [0x00000] in <00000000000000000000000000000000>:0 
  at Microsoft.AspNetCore.SignalR.Protocol.MessagePackHubProtocol.WriteMessage (Microsoft.AspNetCore.SignalR.Protocol.HubMessage message, System.Buffers.IBufferWriter`1[T] output) [0x00000] in <00000000000000000000000000000000>:0 
  at Microsoft.AspNetCore.SignalR.Client.HubConnection.SendHubMessage (Microsoft.AspNetCore.SignalR.Client.HubConnection+ConnectionState connectionState, Microsoft.AspNetCore.SignalR.Protocol.HubMessage hubMessage, System.Threading.CancellationToken cancellationToken) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <00000000000000000000000000000000>:0 
  at Microsoft.AspNetCore.SignalR.Client.HubConnection.SendHubMessage (Microsoft.AspNetCore.SignalR.Client.HubConnection+ConnectionState connectionState, Microsoft.AspNetCore.SignalR.Protocol.HubMessage hubMessage, System.Threading.CancellationToken cancellationToken) [0x00000] in <00000000000000000000000000000000>:0 
  at Microsoft.AspNetCore.SignalR.Client.HubConnection.InvokeCore (Microsoft.AspNetCore.SignalR.Client.HubConnection+ConnectionState connectionState, System.String methodName, Microsoft.AspNetCore.SignalR.Client.Internal.InvocationRequest irq, System.Object[] args, System.String[] streams, System.Threading.CancellationToken cancellationToken) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <00000000000000000000000000000000>:0 
  at Microsoft.AspNetCore.SignalR.Client.HubConnection.InvokeCore (Microsoft.AspNetCore.SignalR.Client.HubConnection+ConnectionState connectionState, System.String methodName, Microsoft.AspNetCore.SignalR.Client.Internal.InvocationRequest irq, System.Object[] args, System.String[] streams, System.Threading.CancellationToken cancellationToken) [0x00000] in <00000000000000000000000000000000>:0 
  at Microsoft.AspNetCore.SignalR.Client.HubConnection.InvokeCoreAsyncCore (System.String methodName, System.Type returnType, System.Object[] args, System.Threading.CancellationToken cancellationToken) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[TResult].Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <00000000000000000000000000000000>:0 
  at Microsoft.AspNetCore.SignalR.Client.HubConnection.InvokeCoreAsyncCore (System.String methodName, System.Type returnType, System.Object[] args, System.Threading.CancellationToken cancellationToken) [0x00000] in <00000000000000000000000000000000>:0 
  at Microsoft.AspNetCore.SignalR.Client.HubConnection.InvokeCoreAsync (System.String methodName, System.Type returnType, System.Object[] args, System.Threading.CancellationToken cancellationToken) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[TResult].Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <00000000000000000000000000000000>:0 
  at Microsoft.AspNetCore.SignalR.Client.HubConnection.InvokeCoreAsync (System.String methodName, System.Type returnType, System.Object[] args, System.Threading.CancellationToken cancellationToken) [0x00000] in <00000000000000000000000000000000>:0 
  at Microsoft.AspNetCore.SignalR.Client.HubConnectionExtensions.InvokeCoreAsync[TResult] (Microsoft.AspNetCore.SignalR.Client.HubConnection hubConnection, System.String methodName, System.Object[] args, System.Threading.CancellationToken cancellationToken) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[TResult].Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <00000000000000000000000000000000>:0 
  at Microsoft.AspNetCore.SignalR.Client.HubConnectionExtensions.InvokeCoreAsync[TResult] (Microsoft.AspNetCore.SignalR.Client.HubConnection hubConnection, System.String methodName, System.Object[] args, System.Threading.CancellationToken cancellationToken) [0x00000] in <00000000000000000000000000000000>:0 
  at Microsoft.AspNetCore.SignalR.Client.HubConnectionExtensions.InvokeAsync[TResult] (Microsoft.AspNetCore.SignalR.Client.HubConnection hubConnection, System.String methodName, System.Object arg1, System.Threading.CancellationToken cancellationToken) [0x00000] in <00000000000000000000000000000000>:0 
 

@thorgeirk11
Copy link
Author

@BrennanConroy @davidfowl this issue is still causing problems. @michalpypek has digged into the cause of the problem.

Can you please take a look at this issue before .net 6 arrives. Our game is using SignalR and MessagePack to great effect and this issue is preventing us form using this stack for an IL2CPP mobile game.

@davidfowl
Copy link
Member

We never attempted to make unity work with the default SignalR client, especially not with IL2CPP. It's not on the list for .NET 6 and we're near the end. Unless it's a trivial fix, this won't be something that we work on for the upcoming release.

@youtpout
Copy link

Finally I buy a plugin on asset store for call SignalR with Messagepack on IL2CPP.
But you can use SignalR with Json without problem on IL2CPP.

@thorgeirk11
Copy link
Author

@davidfowl we would highly appreciate you giving it a chance.
@neuecc would you be willing to give them a hand?

This issue doesn't sound as a major effort. The heavy lifting has already been done the MessagePack Generator. Can you have someone investigate if this could be fixed in the coming release?

@BrennanConroy
Copy link
Member

If there is a trivial fix, then someone could try it out by copying the MessagePackHubProtocol and worker, modify it with the fix, then try it out on the client.

class MyCustomHubProtocol : IHubProtocol
{
    // modified from MessagePackHubProtocol
}
hubConnectionBuilder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IHubProtocol, MyCustomHubProtocol>());

We don't have any cycles during the last leg of .NET 6 to work on this.

@ghost
Copy link

ghost commented Jul 22, 2021

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

@TCROC
Copy link

TCROC commented Jul 27, 2021

We are also experiencing this issue as we try to build to Android in Unity IL2CPP

@wegylexy
Copy link
Contributor

wegylexy commented Oct 4, 2021

MessagePack hub protocol also fails for .NET 7 NativeAOT.
Here I replaced the transport with named pipe which is covered by my xunit test. wegylexy/SignalRTunnel/.../src/Native/Native.cs#L100-L109
All managed test cases pass, and the native wrapper can start and stop the hub connection successfully. I haven't implemented invoke/send yet, but on fails. The event handler is never called back.

I guess the problem lies around here: dotnet/aspnetcore/.../src/Protocol/MessagePackHubProtocol.cs#L80-L113

@wegylexy
Copy link
Contributor

wegylexy commented Oct 5, 2021

I've got On() to work.
Here I can copy raw bytes of encoded arguments to the On handler: wegylexy/SignalRTunnel/.../src/Native/Protocol.cs#L65
Then here you can use your source-generated deserializers: wegylexy/SignalRTunnel/.../src/Native/Connection.cs#L103
In my case, I just pass it to native code and deserialize there with C++ macro-generated unpack functions. But I believe you can somehow invoke corresponding C# source-generated Deserialize<T>() in managed code as well.

Next, I'll work on InvokeCoreAsync() and SendCoreAsync().

@wegylexy
Copy link
Contributor

wegylexy commented Oct 6, 2021

After implementing native invoke and send, another issue appears: #37340

@wegylexy
Copy link
Contributor

wegylexy commented Oct 8, 2021

Boilerplate for quick fix:

switch every custom type used in your project and invoke the generic variant with source generation.

@wegylexy
Copy link
Contributor

Check out FlyByWireless.SignalRTunnel.Client.Native and wegylexy/SignalRTunnel/tree/native#nativeaot-usage.

Built-in types would work out-of-the-box.
For custom types, you will need to configure your generated serializers.

@Lailore
Copy link

Lailore commented May 8, 2023

Any update? MessagePack still not work on il2cpp

@xabio
Copy link

xabio commented May 8, 2023 via email

@agacanergunritimus
Copy link

for android : add this code to AndroidManifest.xml

<uses-permission android:name="android.permission.INTERNET" />

for ios : add this code to Info.plist
<key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> <true/> </dict>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affected-few This issue impacts only small number of customers area-signalr Includes: SignalR clients and servers enhancement This issue represents an ask for new feature or an enhancement to an existing one investigate severity-major This label is used by an internal tool
Projects
None yet
Development

No branches or pull requests