Merge pull request #6921 from lpotapczuk/master

Ng-stomp definitions
This commit is contained in:
Masahiro Wakame
2015-12-01 22:56:20 +09:00
2 changed files with 85 additions and 0 deletions
+49
View File
@@ -0,0 +1,49 @@
/// <reference path="../angularjs/angular.d.ts" />
/// <reference path="ng-stomp.d.ts" />
module ngStompTesting {
"use strict";
var ngStompTest = "ngStompTest";
class test {
constructor(private ngstomp:ngStomp) {
var connectHeaders ={
"Auth": "user",
"Accept": "lol"
};
ngstomp.connect('/endpoint', connectHeaders)
// frame = CONNECTED headers
.then(function (frame) {
this.subscription = ngstomp.subscribe('/dest', function (payload, headers, res) {
this.payload = payload;
}, {
"headers": "are awesome"
});
// Unsubscribe
this.subscription.unsubscribe();
// Send message
ngstomp.send('/dest', {
message: 'body'
}, {
priority: 9,
custom: 42 //Custom Headers
});
// Disconnect
ngstomp.disconnect(function () {
});
});
}
}
angular.module("app").controller(ngStompTest, test);
}
+36
View File
@@ -0,0 +1,36 @@
// Type definitions for ngStomp
// Project: https://github.com/beevelop/ng-stomp
// Definitions by: Lukasz Potapczuk <https://github.com/lpotapczuk>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../angularjs/angular.d.ts" />
interface ngStomp {
sock:any;
stomp:any;
debug:any;
off: any;
setDebug:(callback:Function)=> void;
connect: (endpoint:string, headers?:Headers)=> angular.IHttpPromise<any>;
disconnect: (callback:()=>void) => angular.IHttpPromise<any>;
subscribe: (destination:string, callback:(payload:string, headers:Headers, res:Function)=>void, headers?:Headers, scope?:any) => any;
unsubscribe: () => any;
send: (destination:string, body:any, headers:Headers)=> any;
}
interface Headers {
[key: string]: any;
}