Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aaronpowell/delivr
A port of Delivery.js to SignalR
https://github.com/aaronpowell/delivr
Last synced: about 1 month ago
JSON representation
A port of Delivery.js to SignalR
- Host: GitHub
- URL: https://github.com/aaronpowell/delivr
- Owner: aaronpowell
- License: mit
- Created: 2012-03-01T21:36:46.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2012-06-06T10:38:21.000Z (over 12 years ago)
- Last Synced: 2024-11-17T19:55:27.446Z (about 2 months ago)
- Language: JavaScript
- Homepage:
- Size: 532 KB
- Stars: 16
- Watchers: 5
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# DelivR
DelivR is a port of [Delivery.js](https://github.com/liamks/Delivery.js), a Node.js library for sending files over persistent connections, such as websockets or AJAX long-polling.
DelivR aims to bring the same concepts to the .NET platform, built on top of [SignalR](https://github.com/SignalR/SignalR/), a .NET async signaling library
# Get it on NuGet
*Soooooon :P*
# Usage
## Server
To create your own file sending you need to inhert from the `DelivR.FileConnection` class:
public class Basic : FileConnection
{
}
This is a layer on top of the [PersistentConnection](https://github.com/SignalR/SignalR/wiki/PersistentConnection) that SignalR provides with some helpful methods for sending images. To send an image to a particular client you can do this:protected override Task OnConnectedAsync(IRequest request, IEnumerable groups, string connectionId)
{
this.SendImage(connectionId, @"c:\Path\To\Image.png");
return base.OnConnectedAsync(request, groups, connectionId);
}You also need to register your route still as per the PersistentConnection documentation.
## Client
On the client add a reference to the `delivR.js` file included in the package and then create a new instance of `DelivR`:
$(document).ready(function () {
var basic = new DelivR('basic');
});
You need to pass in the name for the route, what you gave it in the route definition so that DelivR knows where to find it ;).Then you need to listen to the events you want like so:
basic.on('receive', function(e, file) {
//do cool stuff
});
The first argument is the type of message to listen for, with `receive` being the message type emitted when you use the `SendImage` methods on the server.Finally to display the image you can interact with the file provided like so:
basic.on('receive', function (e, file) {
$('')
.attr('src', file.dataUri())
.appendTo(document.body);
});
Done!# License
[MIT](https://github.com/aaronpowell/delivR/blob/master/LICENSE.md)