|
|
@@ -1,4 +1,5 @@
|
|
|
import {Interfaces} from "./Interfaces";
|
|
|
+import ConversationStateInterface = Interfaces.ConversationState;
|
|
|
|
|
|
export module Conversations {
|
|
|
|
|
|
@@ -103,7 +104,7 @@ export module Conversations {
|
|
|
|
|
|
duration: number = 0;
|
|
|
|
|
|
- private conversationState: (value?: Interfaces.ConversationState) => Interfaces.ConversationState;
|
|
|
+ private conversationState: (value?: Interfaces.ConversationState) => ConversationStateInterface;
|
|
|
|
|
|
private apiConnector: Interfaces.ApiConnectorInterface;
|
|
|
private initiator: Interfaces.ClientInterface;
|
|
|
@@ -117,13 +118,13 @@ export module Conversations {
|
|
|
this.logger = logger;
|
|
|
this._id = id;
|
|
|
let state = Interfaces.ConversationState.INIT();
|
|
|
- this.conversationState = (value?: Interfaces.ConversationState) => {
|
|
|
+ this.conversationState = (value?: ConversationStateInterface) => {
|
|
|
if (value !== undefined)
|
|
|
state = value;
|
|
|
return state;
|
|
|
};
|
|
|
|
|
|
- this.state = Interfaces.ConversationState.INIT();
|
|
|
+ this.state = ConversationStateInterface.INIT();
|
|
|
}
|
|
|
|
|
|
getInitiator(): Interfaces.ClientInterface {
|
|
|
@@ -144,15 +145,15 @@ export module Conversations {
|
|
|
|
|
|
set state(state: Interfaces.ConversationState) {
|
|
|
if (!this.state.isEqualsTo(state)) {
|
|
|
- if (state.isEqualsTo(Interfaces.ConversationState.INIT())) {
|
|
|
+ if (state.isEqualsTo(ConversationStateInterface.INIT())) {
|
|
|
}
|
|
|
- if (state.isEqualsTo(Interfaces.ConversationState.RUNNING())) {
|
|
|
+ if (state.isEqualsTo(ConversationStateInterface.RUNNING())) {
|
|
|
this.setRunning();
|
|
|
}
|
|
|
- if (state.isEqualsTo(Interfaces.ConversationState.PAUSED())) {
|
|
|
+ if (state.isEqualsTo(ConversationStateInterface.PAUSED())) {
|
|
|
this.setPaused();
|
|
|
}
|
|
|
- if (state.isEqualsTo(Interfaces.ConversationState.STOPPED())) {
|
|
|
+ if (state.isEqualsTo(ConversationStateInterface.STOPPED())) {
|
|
|
this.setStopped();
|
|
|
}
|
|
|
this.conversationState(state);
|
|
|
@@ -174,7 +175,7 @@ export module Conversations {
|
|
|
this.recipient.payedTime += Math.round(interval * this.recipient.coefficient);
|
|
|
if (this.initiator.payedTime < 0) {
|
|
|
this.logger.debug(`User with ID=${this.initiator.id} is ran out of money`);
|
|
|
- this.state = Interfaces.ConversationState.STOPPED();
|
|
|
+ this.state = ConversationStateInterface.STOPPED();
|
|
|
}
|
|
|
}, 1000);
|
|
|
}
|