forked from SignalR/SignalR
-
Notifications
You must be signed in to change notification settings - Fork 0
SignalR JS Client
davidfowl edited this page Nov 5, 2011
·
32 revisions
The SignalR javascript client comes in the form of a jQuery plugin.
Include the following scripts on your page:
<script src="Scripts/jquery-1.6.2.min.js" type="text/javascript"></script>
<script src="Scripts/jquery.signalR.min.js" type="text/javascript"></script>
NOTE: In an MVC application use Url.Content to reference scripts.
Creates a new connection.
- Returns a connection.
- NOTE: There is currently no cross domain support
Example
var connection = $.connection('/echo');
-
handler(data) - A function to execute each time data is received.
-
Returns a connection.
-
NOTE: data is a JSON object
Example
connection.received(function(data) {
console.log(data);
});
-
handler(error) - A function to execute each time an error occurs.
-
Returns a connection.
Example
connection.error(function(error) {
console.warn(error);
});
- handler - A function to execute before the transport establishes a connection to the server.
Starts the connection using the default settings.
- NOTE: A connection cannot send or receive messages until the start method has been called and the connection successfully established.
Starts the connection using the default settings and executes the passed callback once the connection has been established.
Starts the connection using the passed settings.
- data - data to send over the connection.
Example
connection.send("Hello World");