export default class ServerMessage { pointer : number ; id : number ; tokens : string [ ] ; constructor ( data ) { this . pointer = 0 ; this . tokens = data . split ( SEPARATOR ) ; this . id = this . popInt ( ) ; } popToken ( ) { if ( this . tokens . length > this . pointer ) { return this . tokens [ this . pointer ++ ] ; } return "" ; } popInt ( ) { return parseInt ( this . popToken ( ) ) ; } popFloat ( ) { return parseFloat ( this . popToken ( ) ) ; } popString ( ) { const tickets = this . popInt ( ) ; let str = this . popToken ( ) ; for ( let i = 0 ; i < tickets ; i ++ ) { str += SEPARATOR + this . popToken ( ) ; } return str ; } popBoolean ( ) { return this . popInt ( ) === 1 ; } } const SEPARATOR = '|' ;