@xmobitea/gn-typescript-client
Version:
GearN Typescript Client SDK by XmobiTea (Pro)
54 lines (53 loc) • 1.51 kB
JavaScript
import { OperationRequest } from "./../entity/OperationRequest";
export class OperationPending {
constructor(requestType, role, operationRequest, onOperationResponse, authToken, secretKey, customTags, gameId) {
this.operationRequest = operationRequest;
this.onOperationResponse = onOperationResponse;
this.timeout = Date.now() / 1000 + OperationRequest.defaultTimeOut;
this.firstSend = 0;
this.secondsSend = 0;
this.requestType = requestType;
this.role = role;
this.authToken = authToken;
this.secretKey = secretKey;
this.gameId = gameId;
this.customTags = customTags;
}
getRequestType() {
return this.requestType;
}
getRole() {
return this.role;
}
getAuthToken() {
return this.authToken;
}
getSecretKey() {
return this.secretKey;
}
getGameId() {
return this.gameId;
}
getCustomTags() {
return this.customTags;
}
onSend() {
this.firstSend = Date.now() / 1000;
this.timeout = this.firstSend + this.operationRequest.getTimeout();
}
onRecv() {
this.secondsSend = Date.now() / 1000;
}
getExecuteTimerInMs() {
return (this.secondsSend - this.firstSend);
}
isTimeout() {
return this.timeout < Date.now() / 1000;
}
getOperationRequest() {
return this.operationRequest;
}
getCallback() {
return this.onOperationResponse;
}
}