From b4c61b6c2dbb819451b9e86d85a1bb27722e88ef Mon Sep 17 00:00:00 2001 From: Pawel Kadluczka Date: Wed, 6 Sep 2017 12:22:59 -0700 Subject: [PATCH] Client side method names should be case insensitive --- .../HubConnection.ts | 4 ++-- .../wwwroot/js/hubConnectionTests.js | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/client-ts/Microsoft.AspNetCore.SignalR.Client.TS/HubConnection.ts b/client-ts/Microsoft.AspNetCore.SignalR.Client.TS/HubConnection.ts index 4c257c6d20..8c36667fc3 100644 --- a/client-ts/Microsoft.AspNetCore.SignalR.Client.TS/HubConnection.ts +++ b/client-ts/Microsoft.AspNetCore.SignalR.Client.TS/HubConnection.ts @@ -75,7 +75,7 @@ export class HubConnection { } private invokeClientMethod(invocationMessage: InvocationMessage) { - let method = this.methods.get(invocationMessage.target); + let method = this.methods.get(invocationMessage.target.toLowerCase()); if (method) { method.apply(this, invocationMessage.arguments); if (!invocationMessage.nonblocking) { @@ -202,7 +202,7 @@ export class HubConnection { } on(methodName: string, method: (...args: any[]) => void) { - this.methods.set(methodName, method); + this.methods.set(methodName.toLowerCase(), method); } set onClosed(callback: ConnectionClosed) { diff --git a/client-ts/Microsoft.AspNetCore.SignalR.Test.Server/wwwroot/js/hubConnectionTests.js b/client-ts/Microsoft.AspNetCore.SignalR.Test.Server/wwwroot/js/hubConnectionTests.js index 97b9d3d508..f58435025a 100644 --- a/client-ts/Microsoft.AspNetCore.SignalR.Test.Server/wwwroot/js/hubConnectionTests.js +++ b/client-ts/Microsoft.AspNetCore.SignalR.Test.Server/wwwroot/js/hubConnectionTests.js @@ -136,7 +136,12 @@ describe('hubConnection', function () { var message = "你好 SignalR!"; - hubConnection.on("Message", function (msg) { + // client side method names are case insensitive + var methodName = 'message'; + var idx = Math.floor(Math.random() * (methodName.length - 1)); + methodName = methodName.substr(0, idx) + methodName[idx].toUpperCase() + methodName.substr(idx + 1); + + hubConnection.on(methodName, function (msg) { expect(msg).toBe(message); done(); });