Protocols - digitalideation/studio_webmobile2_2021 GitHub Wiki
How would you build a cross-device application? How can devices communicate with each other? Which protocols do you know? How do you choose the right one?
Your tasks
- Research HTTP, WebSocket, WebRTC and Server-sent events. There are some resources below, you can also find additional ones or use Wikipedia. For each protocol, draw the communication patterns in this Miro board. HTTP is already there as an example.
- Read the HTTP deep dive section below and try to anwser the questions.
- Do the Postman exercise.
- Do the socket.io tutorial.
HTTP deep dive
Try to answer the following questions using the resources listed below. Answer the questions for yourself, you don't need to hand-in anything.
- How are HTTP requests structured?
- Which HTTP methods exist?
- Which HTTP methods are idempotent, which are safe?
- What HTTP response status codes should I know?
HTTP resources
- HTTP overview
- HTTP methods
- Safe HTTP methods
- Idempotent HTTP methods
- HTTP headers
- HTTP response status codes
- HTTP status ranges in a nutshell
Postman exercise
Postman is an app for testing HTTP APIs. You can download it here. Note that you don't need to create an account and sign in if you don't want to. You can still use the app. Using Postman do the following exercises:
- Send an HTTP GET request to known servers, for example http://hslu.ch
- Inspect the response
- Look at the response time
- Do you get the same result every time?
- Try to find a really fast server and a really slow response time. Record your results in this Google Doc
- What factors can impact the response time?
- Try to provoke a response code that is not OK. What request did you send to which address and what response do you get? Record your results in the Google Doc
Debugging network and timing issues
Modern browser developer tools come with a network tab to help you find issues in the communication over a network. Open the browser of your choice and open the network tab, then (re)load a website. What do you see?
WebSockets and Socket.io
Socket.io is a library for real-time, bidirectional and event-based communication. Under the hood it uses WebSockets, but is a bit easier to use and provides additional functionality on top. We will work through the Socket.io tutorial together. Alternatively you can work through it by yourself. If you have time left, choose some of the exercise listed as Homework and try implement them.