How to map parameters in TscHubConnection.Register method?

Discussion of open issues, suggestions and bugs regarding network security and data protection solution - SecureBridge
Post Reply
oscar
Posts: 1
Joined: Tue 17 Feb 2009 09:14

How to map parameters in TscHubConnection.Register method?

Post by oscar » Wed 11 Mar 2020 12:23

Hi All,

This snippet is how we setup our client in javascript:
...
this.connection = new signalR.HubConnectionBuilder()
.withUrl(URL_ENDPOINT, { accessTokenFactory: () => this.loginToken })
.build();
this.connection.on("ReceiveNotification", (info, kind) => this.receiveNotification(info, kind));
yield this.connection.start();
...

Where the info is an object (marshalled as json) & kind is an enum (int).

When setting up a TscHubConnection in Delphi,
how do i map these expected parameters to the TscHubConnection.Register method?

eg:
hubConnection.Register('ReceiveNotification', HandleReceiveNotification, [var??, var??] );

Tia, Rj

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: How to map parameters in TscHubConnection.Register method?

Post by ViktorV » Wed 11 Mar 2020 15:13

The type of the parameter should match the type of the method declared on the server. For example, if the method is declared in the following way:

Code: Select all

public async Task ReceiveNotification(string info, int kind)
then the method should be registered as follows

Code: Select all

hubConnection.Register('ReceiveNotification', HandleReceiveNotification, [varString, varInteger]);

oscar
Posts: 1
Joined: Tue 17 Feb 2009 09:14

Re: How to map parameters in TscHubConnection.Register method?

Post by oscar » Wed 11 Mar 2020 15:40

Hi VictorV,

Our SignalR server has been implemented in asp.net core,
and the first parameter (info) I reffered to is a C# class, used as a POCO.
So the question still remains, what's the TVarType i have to use?

Thanks, Rj

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: How to map parameters in TscHubConnection.Register method?

Post by ViktorV » Thu 12 Mar 2020 13:33

You can assign the type varString to the parameter info, in which case you'll be able to read the responce as a JSON string and use it at your discretion.

oscar
Posts: 1
Joined: Tue 17 Feb 2009 09:14

Re: How to map parameters in TscHubConnection.Register method?

Post by oscar » Thu 12 Mar 2020 14:36

Hi,

Thanks for your suggestion, i have tried it, and my callback function gets called, however Values array has zero elements!?
Any ideas?

Tia, Rj

oscar
Posts: 1
Joined: Tue 17 Feb 2009 09:14

Re: How to map parameters in TscHubConnection.Register method?

Post by oscar » Thu 12 Mar 2020 14:56

Hi,

Little update here...
After a restart of my session, i have a json-payload as parm in my callback!

Thanks, Rj

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: How to map parameters in TscHubConnection.Register method?

Post by ViktorV » Fri 13 Mar 2020 10:01

Thank you for interest to our product.
Feel free to contact us if you have any further questions about our products.

Post Reply