Skip to content

Latest commit

 

History

History
85 lines (55 loc) · 2.53 KB

OLD-README.md

File metadata and controls

85 lines (55 loc) · 2.53 KB

ms-signalr-client

Unofficial package for the SignalR JS Client

This is a package for Microsoft's ASP.NET SignalR JavaScript Library.

Current packaged version is v2.2.2-pre.

Note regarding jQuery3

  • The intent of this package is to simply act as a packaged version of the current official Microsoft SignalR JS client. I do not fix any bugs in the official implementation. Bug fixes filter down to this package after Microsoft fixes them in the official client.

  • If you need a version of the SignalR client with jQuery3 support, see Paul Giletich's fork.

Usage

Include the library in your page using one of the following methods:

ES6 Loader

import $ from 'jquery';
import 'ms-signalr-client';

require JS

require('jquery');
require('ms-signalr-client');

HTML

<script src="../node_modules/jquery/dist/jquery.js"></script>
<script src="../jquery.signalR.js"></script>

Set up a connection to a signalR host, and Hub. Make sure you update the [address], [port], and [hubname] values to suit your environment.

var connection = $.hubConnection('http://[address]:[port]');
var proxy = connection.createHubProxy('[hubname]');

// receives broadcast messages from a hub function, called "broadcastMessage"
proxy.on('broadcastMessage', function(message) {
    console.log(message);
});

// atempt connection, and handle errors
connection.start({ jsonp: true })
.done(function(){ console.log('Now connected, connection ID=' + connection.id); })
.fail(function(){ console.log('Could not connect'); });
}

Tests

To run tests, run the following command:

$ npm run test

Tests will be run using:

  • PhantomJS (headless browser)
  • Mocha (test runner)
  • Chai (assertion library)

Version numbering

The build number is a little ahead of the offical jquery.signalr repo. This is due to fixes to this package requiring a package version bump.

Problems

If you have problems with this package, log them on the bug tracker. If you have issues with the jquery.signalr library, go to the SignalR bug tracker.

Licence Information

As per the following:

  • All client code is Copyright (C) Microsoft Corporation. All rights reserved.

I make no claims on this code, but I have kindly packaged it up for you. :)