Skip to content

Commit

Permalink
feat(ClientChannel): expose onSessionFinished and onSessionFailed
Browse files Browse the repository at this point in the history
… events of ClientChannel class
  • Loading branch information
arthurxavierx committed Oct 19, 2016
1 parent 823866c commit 70e97bd
Showing 1 changed file with 27 additions and 18 deletions.
45 changes: 27 additions & 18 deletions src/Lime/Protocol/Client/ClientChannel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,25 @@ export class ClientChannel extends Channel {

switch (session.state) {
case SessionState.NEGOTIATING:
this.onSessionNegotiating(session);
this._onSessionNegotiating(session);
break;
case SessionState.AUTHENTICATING:
this.onSessionAuthenticating(session);
this._onSessionAuthenticating(session);
break;
case SessionState.ESTABLISHED:
this.onSessionEstablished(session);
this._onSessionEstablished(session);
break;
case SessionState.FINISHED:
this.transport.close().then(() => this.onSessionFinished(session));
this.transport.close().then(() => {
this.onSessionFinished(session);
this._onSessionFinished(session);
});
break;
case SessionState.FAILED:
this.transport.close().then(() => this.onSessionFailed(session));
this.transport.close().then(() => {
this.onSessionFailed(session);
this._onSessionFailed(session);
});
default:
}
}
Expand All @@ -74,8 +80,8 @@ export class ClientChannel extends Channel {
}

let promise = new Promise<Session>((resolve, reject) => {
this.onSessionFailed = reject;
this.onSessionNegotiating = this.onSessionAuthenticating = resolve;
this._onSessionFailed = reject;
this._onSessionNegotiating = this._onSessionAuthenticating = resolve;
});

const session: Session = {
Expand All @@ -92,8 +98,8 @@ export class ClientChannel extends Channel {
}

let promise = new Promise<Session>((resolve, reject) => {
this.onSessionFailed = reject;
this.onSessionAuthenticating = resolve;
this._onSessionFailed = reject;
this._onSessionAuthenticating = resolve;
});

const session: Session = {
Expand All @@ -113,8 +119,8 @@ export class ClientChannel extends Channel {
}

let promise = new Promise<Session>((resolve, reject) => {
this.onSessionFailed = reject;
this.onSessionEstablished = resolve;
this._onSessionFailed = reject;
this._onSessionEstablished = resolve;
});

const session: Session = {
Expand All @@ -135,8 +141,8 @@ export class ClientChannel extends Channel {
}

let promise = new Promise<Session>((resolve, reject) => {
this.onSessionFailed = reject;
this.onSessionFinished = resolve;
this._onSessionFailed = reject;
this._onSessionFinished = resolve;
});

const session: Session = {
Expand All @@ -148,9 +154,12 @@ export class ClientChannel extends Channel {
return promise;
}

private onSessionNegotiating(session: Session) {}
private onSessionAuthenticating(session: Session) {}
private onSessionEstablished(session: Session) {}
private onSessionFinished(session: Session) {}
private onSessionFailed(session: Session) {}
onSessionFinished(session: Session) {}
onSessionFailed(session: Session) {}

private _onSessionNegotiating(session: Session) {}
private _onSessionAuthenticating(session: Session) {}
private _onSessionEstablished(session: Session) {}
private _onSessionFinished(session: Session) {}
private _onSessionFailed(session: Session) {}
}

0 comments on commit 70e97bd

Please sign in to comment.