Skip to content

[v7.0] Sessions, Reconnecting and Chats!

Latest
Compare
Choose a tag to compare
@evolutionleo evolutionleo released this 04 Dec 05:11

This is a very big update, below is a (non-complete) list of things I've added/changed since v6.0

  • Added Temporary accounts
  • Added Sessions
  • Session tokens are saved to a local file client-side and used to login automatically on each game start
  • If no session token is present - a new temporary account will be created, with a new session token assigned to it
  • Temporary accounts are used to save player progress and identify different clients, without the need for a login screen
  • Registering while logged into a temporary account upgrades it to a permanent account instead
  • Clients now have a reconnect_timer and don't get destroyed immediately after a socket is disconnected. If another socket connects using the same session until the timer expires, that socket will automatically take place of the old Client and continue as normal (from the same lobby, room, etc.)
  • Removed the nested keys object in PlayerEntity's key inputs (entity.inputs.keys.k* -> entity.inputs.k*)
  • Refactored sending/receiving player inputs for easier adding/removing of keys (now you only need to change code in 2 places instead of 4)
  • Merged utility functions from schemas/account, schemas/profile and util/hash_passwords into a single file util/auth
  • Refactored the old login functions to use async/await instead of Promises (for better readability)
  • Replaced uuid.v4() with crypto.randomUUID() (~4x faster)
  • Removed redundant/unused dependencies: "uuid", "extend", "module-alias", "0x", "performance-now", "rbush", getting rid of the "critical vulnerability" warnings in npm from unused code
  • Replaced var with let in a lot of the old code
  • Changed data.status variable type from string to boolean in a lot of functions for more consistency and simplicity
  • Fixed bug where an entity being removed twice or more in the same frame could remove other unrelated entities
  • Updated all entity collision functions to accept an optional parameter collider, default to this.collider to have secondary colliders
  • Updated entity colliders to use scale (Entity.updateCollider() no longer creates a brand new collider every time you change the scale of the entity)
  • Entity.updateCollider() is now automatically called after each collision check
  • Added Entity.origin and Entity.collider_origin variables to support sprite origins other than the top left corner (these are 2D variables with x/y values from 0 to 1, 0 meaning top/left, and 1 = bottom/right)
  • Changed the way default/guest names are generated
  • Moved a function from #util/entity_functions to #concepts/entity
  • Added Chats
  • Added a mongoose schema for Chats, keeping track of messages and members' profile ids
  • Clients now have a chats attribute with all their current active chats
  • Profile schema now has a chats attribute (an array of references to Chat objects in the database)
  • Renamed variables from lobbyid -> lobby_id, profileid -> profile_id, etc. across the codebase for consistency and readability reasons
  • Renumbered most initializers (changing file names and order of execution)
  • Fixed initializers/00_exit_handler.ts not handing Ctrl+C exit from the process on Windows correctly
  • ...and more!

Enjoy! And please report any bugs to my Discord server

- Evoleo