mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-11 20:40:20 +00:00
Merge pull request #1713 from pushplay/master
Added definitions for XSockets.net JSAPI.
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
/// <reference path="XSockets.d.ts" />
|
||||
|
||||
var conn = new XSockets.WebSocket('ws://localhost:4502/Generic');
|
||||
|
||||
conn.on(XSockets.Events.open,function (clientInfo) {
|
||||
console.log('Open', clientInfo);
|
||||
});
|
||||
|
||||
conn.on(XSockets.Events.onError, function (err) {
|
||||
console.log('Error', err);
|
||||
});
|
||||
|
||||
conn.on(XSockets.Events.close, function () {
|
||||
console.log('Closed');
|
||||
});
|
||||
|
||||
conn.publish('foo', {text:'Hello Real-Time World'});
|
||||
|
||||
conn.on('foo', function(data) {
|
||||
console.log('subscription to foo fired with data = ', data);
|
||||
});
|
||||
|
||||
conn.unbind('foo');
|
||||
|
||||
conn.one('foo', function(data) {
|
||||
console.log('subscription to foo fired with data = ', data);
|
||||
});
|
||||
|
||||
conn.many('foo',4, function(data) {
|
||||
console.log('subscription to foo fired with data = ', data);
|
||||
});
|
||||
|
||||
conn.on('foo', function (data) {
|
||||
console.log('subscription to foo fired with data = ', data);
|
||||
}, function (confirmation) {
|
||||
console.log('subscription confirmed',confirmation);
|
||||
conn.publish('foo', { text: 'Hello Real-Time World' });
|
||||
});
|
||||
|
||||
conn.publish(XSockets.Events.storage.set, {
|
||||
Key: "yourKey",
|
||||
Value: {
|
||||
Name: "John Doe",
|
||||
Age: 40,
|
||||
Likes: ["Beer", "Food", "Coffe"]
|
||||
}
|
||||
});
|
||||
|
||||
conn.publish(XSockets.Events.storage.remove, {Key: 'yourKey'});
|
||||
|
||||
conn.on(XSockets.Events.storage.getAll, function (data) {
|
||||
data.forEach(function (item) {
|
||||
console.log(item);
|
||||
});
|
||||
});
|
||||
|
||||
conn.publish(XSockets.Events.storage.getAll, {});
|
||||
|
||||
conn.publish('set_MyProp',{value:'New Value'});
|
||||
|
||||
conn.on('get_MyProp',function(prop){console.log('Value Of MyProp',prop)});
|
||||
@@ -0,0 +1 @@
|
||||
""
|
||||
Vendored
+38
@@ -0,0 +1,38 @@
|
||||
// Type definitions for XSockets.NET 3.0
|
||||
// Project: http://xsockets.net/
|
||||
// Definitions by: Jeffery Grajkowski <https://github.com/pushplay>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
declare module XSockets {
|
||||
export class WebSocket {
|
||||
id: string;
|
||||
constructor(url: string, subprotocol?: string, settings?: any);
|
||||
on(event: string, handler: (data: any) => void, confirmation?: (arg: ConfirmationArgument) => void): void;
|
||||
one(event: string, handler: (data: any) => void, confirmation?: (arg: ConfirmationArgument) => void): void;
|
||||
many(event: string, times: number, handler: (data: any) => void, confirmation?: (arg: ConfirmationArgument) => void): void;
|
||||
unbind(event: string): void;
|
||||
publish(topic: string, data: any): void;
|
||||
}
|
||||
export interface ConfirmationArgument {
|
||||
event: string;
|
||||
}
|
||||
export module Events {
|
||||
export var close: string;
|
||||
export var onBlob: string;
|
||||
export var onError: string;
|
||||
export module bindings {
|
||||
export var completed: string;
|
||||
}
|
||||
export var open: string;
|
||||
export module pubSub {
|
||||
export var subscribe: string;
|
||||
export var unsubscribe: string;
|
||||
}
|
||||
export module storage {
|
||||
export var get: string;
|
||||
export var getAll: string;
|
||||
export var remove: string;
|
||||
export var set: string;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
""
|
||||
Reference in New Issue
Block a user