fix user chat log parser

This commit is contained in:
dank074 2021-10-14 01:31:41 -05:00
parent a13c1591a7
commit e4ce462c79

View File

@ -1,19 +1,16 @@
import { IMessageDataWrapper, IMessageParser } from '../../../../../core'; import { IMessageDataWrapper, IMessageParser } from '../../../../../core';
import { ModtoolUserChatlogParserChatlog } from './utils/ModtoolUserChatlogParserChatlog'; import { ChatRecordData } from './utils/ChatRecordData';
import { ModtoolUserChatlogParserVisit } from './utils/ModtoolUserChatlogParserVisit';
export class ModtoolUserChatlogParser implements IMessageParser export class ModtoolUserChatlogParser implements IMessageParser
{ {
private _id: number; private _userId: number;
private _username: string; private _username: string;
private _size: number; private _roomVisits: ChatRecordData[] = [];
private _roomVisits: ModtoolUserChatlogParserVisit[] = [];
public flush(): boolean public flush(): boolean
{ {
this._id = null; this._userId = null;
this._username = null; this._username = null;
this._size = null;
this._roomVisits = []; this._roomVisits = [];
return true; return true;
@ -23,43 +20,20 @@ export class ModtoolUserChatlogParser implements IMessageParser
{ {
if(!wrapper) return false; if(!wrapper) return false;
this._id = wrapper.readInt(); this._userId = wrapper.readInt();
this._username = wrapper.readString(); this._username = wrapper.readString();
this._size = wrapper.readInt(); const size = wrapper.readInt();
for(let i = 0; i < this._size; i++) for(let i = 0; i < size; i++)
{ {
wrapper.readByte(); this._roomVisits.push(new ChatRecordData(wrapper));
wrapper.readShort();
wrapper.readString();
wrapper.readByte();
const roomName = wrapper.readString();
wrapper.readString();
wrapper.readByte();
const roomId = wrapper.readInt();
const chatlogs = [];
const chatlogSize = wrapper.readShort();
for(let i = 0; i < chatlogSize; i++)
{
const timestamp = wrapper.readString();
const userId = wrapper.readInt();
const userName = wrapper.readString();
const message = wrapper.readString();
const bool = wrapper.readBoolean();
chatlogs.push(new ModtoolUserChatlogParserChatlog(timestamp, userId, userName, message, bool));
}
this._roomVisits.push(new ModtoolUserChatlogParserVisit(roomName, roomId, chatlogs));
} }
return true; return true;
} }
public get id(): number public get userId(): number
{ {
return this._id; return this._userId;
} }
public get username(): string public get username(): string
@ -67,7 +41,7 @@ export class ModtoolUserChatlogParser implements IMessageParser
return this._username; return this._username;
} }
public get roomVisits(): ModtoolUserChatlogParserVisit[] public get roomVisits(): ChatRecordData[]
{ {
return this._roomVisits; return this._roomVisits;
} }