reading-notes

View the Project on GitHub TrunkOfUkuleles/reading-notes

Questions

  1. What is the benefit of transforming data into packets? regular shape and consistancy, and ability to transfer on lower bandwidth channels.

  2. UDP is often refereed to as a connectionless protocol. Why is this? User Datagram Protocol is designed to allow for quick communication where a request is not needed before information can be sent.

  3. Can a socket server application have multiple socket connections? yes, but each server socket listend in a single port.

  4. Can a socket connection application be connected to multiple socket servers? as long as it is paired with unique client side IP/PORT?

  5. Can an application be both a socket server and a socket connection? if yopu REEEEAAAALLLLLY want to.

Vocab

Observer Pattern - software design where a object (Subject) maintains a list of dependents (observers) to update as related states change Listener - a running call that will trigger if an event of the chosen name is activated, to then run a snippet of code Event Handler - the callback that performs the code when an event happens. Event Driven Programming - programming style where you build off of the structure of events you want to be the flow for the app. Event Loop - under the hood process of how the engine handles actions that are starting to stack up (or Queue) Event Queue - the ordering for actions in reaction to events, when they must be executed in a particular order Call Stack - the JS engine stack that handles execution contexts and function handling. Emit/Raise/Trigger - methods on the events…. to cause an artificial event to occur oin command. Subscribe - establishing a connection with a web app that allows for real time updating. database - store for information that should not be widely visible.

Preview

Which 3 things had you heard about previously and now have better clarity on? Emit, observer pattern, socket.io Which 3 things are you hoping to learn more about in the upcoming lecture/demo? how this informatioon is handled and transfered. What are you most excited about trying to implement or see how it works? the real time aspect and how easy - fiddly it is once it is up.

Web Socket

            const socket = new WebSocket('ws://game.example.com:12010/updates');
            socket.onopen = function () {
                setInterval(function() {
                    if (socket.bufferedAmount == 0)
                    socket.send(getUpdateData());
                }, 50);
            };

Wikipedia

communications protocol, like HTML, but it provides full-duplex communication over a single TCP connection. For what we think of as modern web design - “live” apps that track and update state automatically during use - Web Socket is key. It has a much lower overhead than HTML, and allows for a connection to stay open to pass information back and foth as needed without an explicit call to the server for every action.

Socket.IO

JS library for real-time web applications. enables bidirectional communication between the client and server in real time. The client library runs the browser, and the server side helps with a library for Node.js - covering both ends. to be a 'real-time' app, it must feel or function immediately, or with a sense of keeping curent. Thing like messengers, push notifications and anything a little more interactive and timing focused. There are a lot of event handlers that help map out the sort of interactions possible, along with systems for 'subscribing' to an event for when it is 'broadcast'. 

Socket.io init

npm install –save express socket.io

WebSocket vs Socket.io

WS schema