Client side method names should be case insensitive

This commit is contained in:
Pawel Kadluczka 2017-09-06 12:22:59 -07:00
parent 2cc72d72cd
commit b4c61b6c2d
2 changed files with 8 additions and 3 deletions

View File

@ -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) {

View File

@ -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();
});