11import { CString , Uint32_t , Uint8_tArray } from "@rustymotors/binary" ;
22import { PacketBody } from "./types.js" ;
33import { UserInfo } from "./UserInfo.js" ;
4- import { getServerLogger } from "rusty-motors-shared" ;
5-
6- const log = getServerLogger ( "RoomServer.LoginRequest" , "roomserver" ) ;
74
85export class LoginRequest implements PacketBody {
96 private _userInfo : UserInfo = new UserInfo ( ) ;
@@ -21,13 +18,6 @@ export class LoginRequest implements PacketBody {
2118 ) ;
2219 }
2320
24- if ( v . length !== this . size ( ) ) {
25- log . warn (
26- { expectedSize : this . size ( ) , actualSize : v . length } ,
27- "Message smaller than expected size" ,
28- ) ;
29- }
30-
3121 try {
3222 let offset = 0 ;
3323 this . _userInfo . set ( v . slice ( 0 , this . _userInfo . size ( ) ) ) ;
@@ -36,45 +26,44 @@ export class LoginRequest implements PacketBody {
3626 v . slice ( offset , offset + this . _customerNumber . size ( ) ) ,
3727 ) ;
3828 offset += this . _customerNumber . size ( ) ;
39- this . _flags . set ( v . slice ( offset , offset + this . _flags . size ( ) ) ) ;
40- offset += this . _flags . size ( ) ;
41- this . _version . set ( v . slice ( offset , offset + this . _version . size ( ) ) ) ;
42- offset += this . _version . size ( ) ;
43- this . _hostName . set ( v . slice ( offset , offset + this . _hostName . size ( ) ) ) ;
44- offset += this . _hostName . size ( ) ;
45- this . _ipAddress . set ( v . slice ( offset , offset + this . _ipAddress . size ( ) ) ) ;
46- offset += this . _ipAddress . size ( ) ;
29+ this . _flags . set ( v . slice ( offset , offset + this . _flags . size ( ) ) ) ;
30+ offset += this . _flags . size ( ) ;
31+ this . _version . set ( v . slice ( offset , offset + this . _version . size ( ) ) ) ;
32+ offset += this . _version . size ( ) ;
33+ this . _hostName . set ( v . slice ( offset , offset + this . _hostName . size ( ) ) ) ;
34+ offset += this . _hostName . size ( ) ;
35+ this . _ipAddress . set ( v . slice ( offset , offset + this . _ipAddress . size ( ) ) ) ;
36+ offset += this . _ipAddress . size ( ) ;
4737 this . _keyHash . set ( v . slice ( offset , offset + this . _keyHash . size ( ) ) ) ;
38+ offset += this . _keyHash . size ( ) ;
4839 } catch ( error ) {
49- log . error (
50- { error, self : this , value : v } ,
51- `Error setting LoginRequest: ${ ( error as Error ) . message } ` ,
52- ) ;
53- throw error ;
40+ const e = new Error ( `Error setting LoginRequest: ${ ( error as Error ) . message } ` ) ;
41+ e . cause = error ;
42+ throw e ;
5443 }
5544 }
5645
5746 serialize ( ) : Uint8Array {
5847 return new Uint8Array ( [
5948 ...this . _userInfo . get ( ) ,
6049 ...this . _customerNumber . get ( ) ,
61- ...this . _flags . get ( ) ,
62- ...this . _version . get ( ) ,
63- ...this . _hostName . get ( ) ,
64- ...this . _ipAddress . get ( ) ,
65- ...this . _keyHash . get ( ) ,
50+ ...this . _flags . get ( ) ,
51+ ...this . _version . get ( ) ,
52+ ...this . _hostName . get ( ) ,
53+ ...this . _ipAddress . get ( ) ,
54+ ...this . _keyHash . get ( ) ,
6655 ] ) ;
6756 }
6857
6958 size ( ) : number {
7059 return (
7160 this . _userInfo . size ( ) +
7261 this . _customerNumber . size ( ) +
73- this . _flags . size ( ) +
74- this . _version . size ( ) +
75- this . _hostName . size ( ) +
76- this . _ipAddress . size ( ) +
77- this . _keyHash . size ( )
62+ this . _flags . size ( ) +
63+ this . _version . size ( ) +
64+ this . _hostName . size ( ) +
65+ this . _ipAddress . size ( ) +
66+ this . _keyHash . size ( )
7867 ) ;
7968 }
8069
0 commit comments