dsuryd / dotNetify

Simple, lightweight, yet powerful way to build real-time web apps.
https://dotnetify.net
Other
1.17k stars 164 forks source link

Configuration with MessagePack Hub protocol with dotnetify #260

Closed chiragmansata closed 4 years ago

chiragmansata commented 4 years ago

Hello, I have been using this library to create a real time react application and would say it's a great library, and simplifies the integration with react. Actually am new to C# and stuck at a point, so seeking help. Am trying to configure my application to communicate using MessagePack hub protocol and did the following steps according to documentation:

1) On React Side index.js (Also tried on the class where VM is connected) import dotnetify from 'dotnetify': import { MessagePackHubProtocol } from '@aspnet/signalr-protocol-msgpack';

const protocol = new MessagePackHubProtocol(); dotnetify.hubOptions.connectionBuilder = builder => builder.withHubProtocol(protocol);

2) On C# side in Startup.cs under ConfigureServices:

services.AddSignalR().AddMessagePackProtocol();

But still it is communicating using JSON, requesting to please help may be with an example or please share some pointers if I am missing anything or doing incorrectly. Thanks in advance.

dsuryd commented 4 years ago

The steps are correct. Here's a working example: https://github.com/dsuryd/dotNetify/commit/4ca711c9bd2ea49cdd7430fad652829efc359a5e
image

chiragmansata commented 4 years ago

Thanks for the quick response. It's working now, I was running on an older version of dotnetify, updating the same solved the issue for me.

However have another query, I am trying to change the default hub url name (currently set to 'dotnetify') and tried below things on startup.cs 1) app.UseEndpoints(endpoints => { endpoints.MapHub("/customURL"); endpoints.MapControllers(); }); 2) app.UseSignalR(routes => { routes.MapDotNetifyHub(); routes.MapHub("/customURL"); });

But its still not getting updated, can you please help on this. Thanks

dsuryd commented 4 years ago

Closing this issue as resolved. Create new ones for new unrelated issues. As for changing new hub url, I can't help you with that. The hub name is associated with this library's identity and should never be changed.