NgRepeat and ngReact are Angular directives for displaying lists of data. NgRepeat uses Angular templates and two-way binding, while ngReact uses React components for a virtual DOM. The document provides demos of each approach and notes that the chat system uses WebSockets, Redis for data storage, and auto-scaling servers for load balancing. It also mentions that Hitbox is hiring.
6. WebSocket Load
balancing
Permission and
security model
(Admin, Mods, ...)
Frontend Server Backend Server
UI
Chat System
Frontend
Server
NodeJs
data storage
Redis
Cluster
hitbox
REST-API
PHP
Nginx
Backend
Server
NodeJs
Auto scaling
Auto scaling
Long Polling Fallback
Fallback
Server
NodeJs
And this is a watchpage. On eintegrap part of it is the schat on the right, where poeple communicate with the broadcaster
-start with lean -> with just as much effort,as required and when the idea is proved, restructure and make it more maintainable
-the hitbox application were made in lean, so we have legacy code-but the idea has proved, and now we are stabilizing the application/making it better-first thing was the chat
This is how the chat is build
What i want to talk about
-fun part -> message bodies (HTML) were generated as string properties of js objects, which is bad practice, but we didnt change this, because we could reuse the exact same message body with react like before, this allowed us to change to ngReact fast, without too much effort, but if you start from scratch, dont do this
we had to use $scope.$apply on each message, so if we had 80messages/sec that triggered 80diggest loops/sec. If you do the math, basically you have 16ms for everything to get 60fps on the browser, for the simplicity, let's just say we have 16ms for the digest loops (in reality 16ms is for everything, including all js, render, etc..), if you divide 16/80 that means, you have 0.2ms (200袖s) for the digest loop, and we know, in a complex application, a digest loop below 1ms is rare
so
so
What i want to talk about
What i want to talk about
- we have a separate service for messages, called chatMessages
- the react component have a state array which will be used in the template, and the react component subscribes with a callback function(setItems) for new messages in the chatMessages service
- a websocket message can push new message into an array in the chatMessages service
so
while we push to the array, we limit the length of the messages array to 300 [MAX this is only for you: what we do is we check if the length is above 300, and if it is, we limit the messages array to 150, however we could just limit it to 300, and forget this 150 thing. I don't remember why I implemented like this, but I think we could just let 300 messages to be in the DOM all the time]