diff --git a/client/client_recv.js b/client/client_recv.js index 7e6bcac..c62a9b9 100644 --- a/client/client_recv.js +++ b/client/client_recv.js @@ -296,24 +296,35 @@ async function handle_message(state, context, d) { switch (message_type) { case MESSAGE.JOIN: case MESSAGE.INIT: { - state.me = des_u32(d); state.server_lsn = des_u32(d); state.online = true; - init_player_defaults(state, state.me); - if (state.server_lsn > state.lsn) { // Server knows something that we don't state.lsn = state.server_lsn; } + let color = config.default_color; + let width = config.default_width; + if (message_type === MESSAGE.JOIN) { localStorage.setItem('sessionId', des_u32(d)); if (config.debug_print) console.debug('join in'); } else { + color = des_u32(d); + width = des_u16(d); + state.me = parseInt(localStorage.getItem('sessionId')); if (config.debug_print) console.debug('init in'); } + init_player_defaults(state, state.me); + + const color_code = color_from_u32(color).substring(1); + + switch_color(state, document.querySelector(`.color[data-color="${color_code}"]`)); + document.querySelector('#stroke-width').value = width; + fire_event(state, width_event(width)); + const event_count = des_u32(d); const user_count = des_u32(d); diff --git a/client/index.html b/client/index.html index 6bd240a..77df1a3 100644 --- a/client/index.html +++ b/client/index.html @@ -7,20 +7,20 @@ - + - - - - - - - - + + + + + + + + - - - + + +