WEEK 10:
MQTT & Web Sockets
NOTEs
TCP is a polite protocol. it checks if the client receives the message, and acknowledges to the client that the feedback is received. UTP is faster. It does not care if some bytes are dropped. ex. audio and video glitches.
Network Sockets are temporary. It is built when a connection starts and is dismantled when the communication ends.
Ports are like doors of a room for information to enter. You may listen to only one port and you can even close the other doors. 80 for HTTP, and 443 for HTTPS. If you send a request to the wrong port, the connection will not be built. So the server must inform the clients of the port number it is listening to, just like telling other people your phone number, so others can call you.
request.rawHeaders : everything you send to the server, including information such as User Agent.


MQTT

Data Storage: The MQTT broker sends data to any MQTT client, for example, a glitch node.js file. Then the glitch makes an HTTP request to send the data to Google spreadsheet.
ParseInt : transfer string to number.

Glitch Sample
Glitch is like a postman standing in between the client and my server. Though Glitch itself is a server, you need to have your own server on the Glitch server so the Glitch know where to pass the client's message to.
Light Remote Contro
.png)
The github HTTP server allows the phone to access to the MQTT broker and send message. Everone can have access to this page.
This client cannot directly communicate with the light. It only transfer what it want the light to do to the broker.
Anyone have access to the QR code can send message to the broker.
This page listens to the hue data from the broker.
This is a private client. The light can be changed only if this client allows the change order to be passed to the Hue hub.
If this client is not running, the phone will still send datato the broker, but the light will not get the data.
WebSocket
