Skip to content

Commit

Permalink
refactor(packets): update ServerPacket constructor usage
Browse files Browse the repository at this point in the history
  • Loading branch information
drazisil committed Oct 10, 2024
1 parent 77d691a commit e5f913b
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 6 deletions.
3 changes: 2 additions & 1 deletion packages/mcots/src/messageProcessors/processServerLogin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ export async function processServerLogin(
log.debug(`Sending LoginCompleteMessage: ${response.toString()}`);

// Send response packet
const responsePacket = new ServerPacket(response.getMessageId());
const responsePacket = new ServerPacket();
responsePacket.setMessageId(response.getMessageId());
responsePacket.setDataBuffer(response.serialize());
responsePacket.setSequence(message.sequence);

Expand Down
3 changes: 2 additions & 1 deletion packages/mcots/src/messageProcessors/processStockCarInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ export async function processStockCarInfo(
responsePacket.setDealerId(lotOwnerId);
responsePacket.setBrandId(brandId);

const response = new ServerPacket(141);
const response = new ServerPacket();
response.setMessageId(141);

if (inventoryCars.inventory.length > StockCarInfo.MAX_CARS_PER_MESSAGE) {
log.error(
Expand Down
3 changes: 2 additions & 1 deletion packages/mcots/src/messageProcessors/sendSuccess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ export function sendSuccess(
pReply.setMessageId(101);
pReply.msgReply = 438;

const response = new ServerPacket(101);
const response = new ServerPacket();
response.setMessageId(101);
response.setDataBuffer(pReply.serialize());
response.setSequence(message.sequence);

Expand Down
4 changes: 2 additions & 2 deletions packages/transactions/src/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export async function receiveTransactionsData({

// Normalize the message

const inboundMessage = new ServerPacket(0);
const inboundMessage = new ServerPacket();
inboundMessage.deserialize(message.serialize());

log.debug(
Expand Down Expand Up @@ -168,7 +168,7 @@ export async function receiveTransactionsData({
response.messages.forEach((message) => {
log.debug(`[${connectionId}] Processing outbound message`);

const outboundMessage = new ServerPacket(0);
const outboundMessage = new ServerPacket();
outboundMessage.deserialize(message.serialize());

if (outboundMessage.isPayloadEncrypted()) {
Expand Down
2 changes: 1 addition & 1 deletion packages/transactions/src/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export async function login({
log,
}: MessageHandlerArgs): Promise<MessageHandlerResult> {
// Normalize the packet
const incomingPacket = new ServerPacket(0);
const incomingPacket = new ServerPacket();
incomingPacket.deserialize(packet.serialize());

log.debug(
Expand Down

0 comments on commit e5f913b

Please sign in to comment.