Skip to content

Commit

Permalink
Added an onNegotiated event that allows a user to modify negotiate va…
Browse files Browse the repository at this point in the history
…lues

#1638
  • Loading branch information
NTaylorMullen committed Aug 16, 2013
1 parent 7c4ee62 commit fc0a52b
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/Microsoft.AspNet.SignalR.Client.JS/jquery.signalR.core.js
Expand Up @@ -48,6 +48,7 @@
events = {
onStart: "onStart",
onStarting: "onStarting",
onNegotiated: "onNegotiated",
onReceived: "onReceived",
onError: "onError",
onConnectionSlow: "onConnectionSlow",
Expand Down Expand Up @@ -671,6 +672,8 @@
onFailed(signalR._.error(resources.errorParsingNegotiateResponse, error), connection);
return;
}

$(connection).triggerHandler(events.onNegotiated, res);

keepAliveData = connection.keepAliveData;
connection.appRelativeUrl = res.Url;
Expand Down Expand Up @@ -754,6 +757,17 @@
return connection;
},

negotiated: function (callback) {
/// <summary>Adds a callback that will be invoked after negotiate has finished and before any data from the result has been read.</summary>
/// <param name="callback" type="Function">A callback function to execute after negotiate, the negotiate response is passed in.</param>
/// <returns type="signalR" />
var connection = this;
$(connection).bind(events.onNegotiated, function (e, data) {
callback.call(connection, data);
});
return connection;
},

send: function (data) {
/// <summary>Sends data over the connection</summary>
/// <param name="data" type="String">The data to send over the connection</param>
Expand Down

0 comments on commit fc0a52b

Please sign in to comment.