Ping / circuit latency, break out commands, add typing function for IM, add thinkingTime and charactersPerSecond parameters to typing functions

This commit is contained in:
Casper Warden
2017-12-13 19:55:08 +00:00
parent af71aa597e
commit 4e8feb181f
96 changed files with 2151 additions and 935 deletions

View File

@@ -10,25 +10,39 @@ export class IPAddress
}
public toString = (): string =>
{
return this.ip.toString();
try
{
return this.ip.toString();
}
catch (ignore)
{
return '';
}
};
constructor(buf?: Buffer | string, pos?: number)
{
if (buf !== undefined && buf instanceof Buffer)
try
{
if (pos !== undefined)
if (buf !== undefined && buf instanceof Buffer)
{
const bytes = buf.slice(pos, 4);
this.ip = ipaddr.fromByteArray(bytes);
}
else
{
if (ipaddr.isValid(buf))
if (pos !== undefined)
{
this.ip = ipaddr.parse(buf);
const bytes = buf.slice(pos, 4);
this.ip = ipaddr.fromByteArray(bytes);
}
else
{
if (ipaddr.isValid(buf))
{
this.ip = ipaddr.parse(buf);
}
}
}
}
catch (ignore)
{
this.ip = ipaddr.parse('0.0.0.0');
}
}
writeToBuffer(buf: Buffer, pos: number)
{