Fix RW to file
This commit is contained in:
@@ -111,8 +111,8 @@ export class Center extends SmppSession {
|
||||
username: this.username,
|
||||
password: this.password,
|
||||
status: this.status,
|
||||
defaultSingleJob: this.defaultSingleJob,
|
||||
defaultMultipleJob: this.defaultMultipleJob,
|
||||
defaultSingleJob: this.defaultSingleJob.serialize(),
|
||||
defaultMultipleJob: this.defaultMultipleJob.serialize(),
|
||||
processors: this.pduProcessors.map(p => p.serialize()),
|
||||
};
|
||||
}
|
||||
|
@@ -43,8 +43,8 @@ export class Client extends SmppSession {
|
||||
this.password = password;
|
||||
this.url = url;
|
||||
|
||||
this.setDefaultSingleJob(Job.createEmptySingle());
|
||||
this.setDefaultMultipleJob(Job.createEmptyMultiple());
|
||||
this.defaultSingleJob = Job.createEmptySingle();
|
||||
this.defaultMultipleJob = Job.createEmptyMultiple();
|
||||
|
||||
this.logger = new Logger(`Client-${id}`);
|
||||
}
|
||||
@@ -96,8 +96,8 @@ export class Client extends SmppSession {
|
||||
username: this.username,
|
||||
password: this.password,
|
||||
status: this.status,
|
||||
defaultSingleJob: this.defaultSingleJob,
|
||||
defaultMultipleJob: this.defaultMultipleJob,
|
||||
defaultSingleJob: this.defaultSingleJob.serialize(),
|
||||
defaultMultipleJob: this.defaultMultipleJob.serialize(),
|
||||
processors: this.pduProcessors.map(p => p.serialize()),
|
||||
};
|
||||
}
|
||||
|
@@ -46,11 +46,11 @@ export class Job {
|
||||
}
|
||||
|
||||
static deserialize(serialized: any): Job {
|
||||
if (!serialized._pdu) {
|
||||
if (!serialized.pdu || !serialized.pdu.command) {
|
||||
return Job.createEmptyMultiple();
|
||||
}
|
||||
let pdu: any = new smpp.PDU(serialized._pdu.command, serialized._pdu);
|
||||
return new Job(pdu, serialized._perSecond, serialized._count);
|
||||
let pdu: any = new smpp.PDU(serialized.pdu.command, serialized.pdu);
|
||||
return new Job(pdu, serialized.perSecond, serialized.count);
|
||||
}
|
||||
|
||||
static createEmptySingle(): Job {
|
||||
@@ -63,7 +63,7 @@ export class Job {
|
||||
|
||||
serialize(): object {
|
||||
return {
|
||||
pdu: JSON.stringify(this.pdu),
|
||||
pdu: this.pdu,
|
||||
perSecond: this.perSecond,
|
||||
count: this.count
|
||||
};
|
||||
|
@@ -57,13 +57,6 @@ export abstract class SessionManager {
|
||||
});
|
||||
}
|
||||
|
||||
serialize(): object {
|
||||
this.logger.log1(`Serializing ${this.sessions.length} clients`);
|
||||
return this.sessions.map((session: SmppSession) => {
|
||||
return session.serialize();
|
||||
});
|
||||
}
|
||||
|
||||
createSession(arg: any, username: string, password: string): Promise<SmppSession> {
|
||||
return new Promise<SmppSession>((resolve, reject) => {
|
||||
this.logger.log1(`Creating session of type ${this.ManagedSessionClass.name} with arg ${arg}`);
|
||||
@@ -113,6 +106,13 @@ export abstract class SessionManager {
|
||||
fs.writeFileSync(this.StorageFile, JSON.stringify(this.serialize(), null, 4));
|
||||
}
|
||||
|
||||
serialize(): object {
|
||||
this.logger.log1(`Serializing ${this.sessions.length} clients`);
|
||||
return this.sessions.map((session: SmppSession) => {
|
||||
return session.serialize();
|
||||
});
|
||||
}
|
||||
|
||||
getExisting(arg: any): Promise<SmppSession> {
|
||||
return new Promise<SmppSession>((resolve, reject) => {
|
||||
this.logger.log1(`Looking for session with arg ${arg}...`);
|
||||
|
Reference in New Issue
Block a user