Skip to content

Commit

Permalink
Merge pull request #8 from spirinvladimir/master
Browse files Browse the repository at this point in the history
v1.2.2
  • Loading branch information
podgorniy authored Jun 13, 2016
2 parents 91676a9 + a509e69 commit abe1125
Show file tree
Hide file tree
Showing 21 changed files with 210 additions and 308 deletions.
6 changes: 3 additions & 3 deletions lib/command.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export declare class Command {
private msg;
clientMsgId: string;
promise: JQueryDeferred<any>;
constructor(msg: any);
constructor(params: any);
done(respond: any): void;
fail(): void;
fail(respond: any): void;
private destroy();
}
10 changes: 5 additions & 5 deletions lib/command.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/command.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions lib/command.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
export class Command {

private msg: any;
public clientMsgId: string;
public promise: JQueryDeferred<any>;

constructor(msg: any) {
this.msg = msg;
constructor(params) {
this.clientMsgId = params.clientMsgId;
this.promise = $.Deferred();
}

Expand All @@ -19,6 +18,6 @@ export class Command {
}

private destroy() {
delete this.msg;
delete this.clientMsgId;
}
}
7 changes: 3 additions & 4 deletions lib/commands.d.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { Command } from './command';
export declare class Commands {
private state;
private send;
private openCommands;
constructor(params: any);
create(msg: any): JQueryDeferred<any>;
findAndResolve(msg: any, clientMsgId: string): boolean;
create(params: any): JQueryDeferred<any>;
fail(): void;
private find(clientMsgId);
private delete(command);
extract(clientMsgId: string): Command;
}
48 changes: 26 additions & 22 deletions lib/commands.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/commands.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 13 additions & 10 deletions lib/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,23 @@ export class Commands {

private state: State;
private send: any;
private openCommands: any;
private openCommands: Command[];

constructor(params: any) {
this.state = params.state;
this.send = params.send;
this.openCommands = [];
}

public create(msg: any): JQueryDeferred<any> {
public create(params): JQueryDeferred<any> {
var clientMsgId = params.clientMsgId;
var msg = params.msg;

var openCommands = this.openCommands;

var command = new Command(msg);
var command = new Command({
clientMsgId: clientMsgId
});

openCommands.push(command);

Expand All @@ -38,18 +43,16 @@ export class Commands {
}
}

public extract(clientMsgId: string): any {
public extract(clientMsgId: string): Command {
var openCommands = this.openCommands;
var openCommandsLength = openCommands.length;
var command;
var index = 0;
while (index < openCommandsLength) {
var command = openCommands[index];
if (command.msg.clientMsgId === clientMsgId) {
openCommands.splice(index, 1);
for (var i = 0; i < openCommandsLength; i += 1) {
command = openCommands[i];
if (command.clientMsgId === clientMsgId) {
openCommands.splice(i, 1);
return command;
}
index += 1;
}
}

Expand Down
48 changes: 8 additions & 40 deletions lib/connect.d.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,5 @@
import { EventEmitter } from 'events';
export declare class GuaranteedCommand {
private msg;
promise: JQueryDeferred<any>;
constructor(msg: any);
done(msg: any): void;
fail(msg: any): void;
private destroy();
}
export declare class GuaranteedCommands {
private state;
private send;
private openCommands;
constructor(params: any);
create(msg: any): JQueryDeferred<any>;
resend(): void;
extract(clientMsgId: string): any;
}
export declare class Command {
private msg;
promise: JQueryDeferred<any>;
constructor(msg: any);
done(respond: any): void;
fail(respond: any): void;
private destroy();
}
export declare class Commands {
private state;
private send;
private openCommands;
constructor(params: any);
create(msg: any): JQueryDeferred<any>;
fail(): void;
extract(clientMsgId: string): any;
}
export interface IConnectionParams {
adapter: any;
encodeDecode: any;
protocol: any;
}
Expand All @@ -46,17 +11,20 @@ export declare class Connect extends EventEmitter {
private guaranteedCommands;
private commands;
constructor(params: IConnectionParams);
getAdapter(): any;
setAdapter(adapter: any): void;
private initialization();
start(): JQueryDeferred<{}>;
start(): JQueryPromise<void>;
private onData(data);
private onOpen();
sendGuaranteedCommand(payloadType: any, params: any): JQueryDeferred<any>;
sendCommand(payloadType: any, params: any): JQueryDeferred<any>;
private send(msg);
sendGuaranteedCommand(payloadType: number, params: any): JQueryDeferred<any>;
sendCommand(payloadType: number, params: any): JQueryDeferred<any>;
private send(data);
private onMessage(data);
private processData(clientMsgId, payloadType, msg);
private extractCommand(clientMsgId);
protected isError(payloadType: any): boolean;
protected processMessage(msg: any, clientMsgId: string, payloadType: number): void;
protected processMessage(command: any, msg: any, payloadType: any): void;
protected processPushEvent(msg: any, payloadType: any): void;
private _onEnd(e);
isDisconnected(): boolean;
Expand Down
Loading

0 comments on commit abe1125

Please sign in to comment.