diff --git a/ss-utils/ss-utils-tests.ts b/ss-utils/ss-utils-tests.ts
index 52ac7151b..5ecaaef96 100644
--- a/ss-utils/ss-utils-tests.ts
+++ b/ss-utils/ss-utils-tests.ts
@@ -1,18 +1,7 @@
///
///
-declare var EventSource : sse.IEventSourceStatic;
-
-declare module sse {
- interface IEventSourceStatic extends EventTarget {
- new (url: string, eventSourceInitDict?: IEventSourceInit):IEventSourceStatic;
- url: string;
- }
-
- interface IEventSourceInit {
- withCredentials?: boolean;
- }
-}
+declare var EventSource : ssutils.IEventSourceStatic;
function test_ssutils() {
$.ss.eventReceivers = { "document": document };
@@ -23,7 +12,8 @@ function test_ssutils() {
onConnect: function(connect:ssutils.SSEConnect) {},
onHeartbeat: function(msg:ssutils.SSEHeartbeat, e:MessageEvent){},
onJoin: function(msg:ssutils.SSEJoin) {},
- onLeave: function(msg:ssutils.SSELeave) {}
+ onLeave: function(msg:ssutils.SSELeave) {},
+ onUpdate: function(msg:ssutils.SSEUpdate) {}
},
receivers: {
tv: {
@@ -74,6 +64,8 @@ function test_ssutils_Static(){
var qs:{ [index: string]: string } = $.ss.queryString("http://google.com?a=b&c=d");
var relativePath = $.ss.createUrl("/path/to/{File}", {File:"file.js"});
var readableText = $.ss.humanize("TheVariableName");
+ $.ss.parseResponseStatus('{"message":"test"}');
+ $.ss.postJSON("/path/to/url", {json:"data"}, function(r:any) {});
$.ss.listenOn = "click onmousedown";
$.ss.eventReceivers = { "document": document };
diff --git a/ss-utils/ss-utils.d.ts b/ss-utils/ss-utils.d.ts
index 3d6ddfbf4..9154e478f 100644
--- a/ss-utils/ss-utils.d.ts
+++ b/ss-utils/ss-utils.d.ts
@@ -23,9 +23,18 @@ declare namespace ssutils {
queryString: (url: string) => { [index: string]: string };
createUrl: (route: string, args?: any) => string;
humanize: (s: string) => string;
+ parseResponseStatus: (json: string, defaultMsg?: string) => any;
+ postJSON: (url: string, data: Object | String, success?: Function, error?: Function) => any;
listenOn: string;
eventReceivers: any;
+ eventChannels: string[];
+ eventSourceUrl: string;
+ updateSubscriberUrl: string;
+ updateChannels: (channels: string[]) => void;
+ updateSubscriber: (data: UpdateSubscriberOptions, cb?: (user: SSEUpdate) => void, cbError?: Function) => any;
+ subscribeToChannels: (channels: string[], cb?: (user: SSEUpdate) => void, cbError?: Function) => any;
+ unsubscribeFromChannels: (channels: string[], cb?: (user: SSEUpdate) => void, cbError?: Function) => any;
reconnectServerEvents: (opt: ReconnectServerEventsOptions) => any;
}
@@ -62,6 +71,11 @@ declare namespace ssutils {
success?: (selector: string, msg: string, e: any) => void;
}
+ interface UpdateSubscriberOptions {
+ SubscribeChannels?: string;
+ UnsubscribeChannels?: string;
+ }
+
interface ResponseStatus {
errorCode: string;
message: string;
@@ -84,11 +98,13 @@ declare namespace ssutils {
interface SSEHeartbeat extends SSECommand { }
interface SSEJoin extends SSECommand { }
interface SSELeave extends SSECommand { }
+ interface SSEUpdate extends SSECommand { }
interface SSEConnect extends SSECommand {
id: string;
unRegisterUrl: string;
heartbeatUrl: string;
+ updateSubscriberUrl: string;
heartbeatIntervalMs: number;
idleTimeoutMs: number;
}
@@ -97,10 +113,40 @@ declare namespace ssutils {
url?: string;
onerror?: (...args: any[]) => void;
onmessage?: (...args: any[]) => void;
- errorArgs: any[];
+ errorArgs?: any[];
+ }
+
+ /**
+ * EventSource
+ */
+ enum ReadyState { CONNECTING = 0, OPEN = 1, CLOSED = 2 }
+
+ interface IEventSourceStatic extends EventTarget {
+ new (url: string, eventSourceInitDict?: IEventSourceInit): IEventSourceStatic;
+ url: string;
+ withCredentials: boolean;
+ CONNECTING: ReadyState; // constant, always 0
+ OPEN: ReadyState; // constant, always 1
+ CLOSED: ReadyState; // constant, always 2
+ readyState: ReadyState;
+ onopen: Function;
+ onmessage: (event: IOnMessageEvent) => void;
+ onerror: Function;
+ close: () => void;
+ }
+
+ interface IEventSourceInit {
+ withCredentials?: boolean;
+ }
+
+ interface IOnMessageEvent {
+ data: string;
}
}
+//Needs to be declared locally
+//declare var EventSource: ssutils.IEventSourceStatic;
+
interface JQuery {
setFieldError: (name: string, msg: string) => void;
serializeMap: () => { [index: string]: any };
@@ -119,4 +165,4 @@ interface JQueryStatic {
declare module "ss-utils" {
export = ssutils;
-}
\ No newline at end of file
+}