Skip to content

Latest commit

 

History

History
57 lines (43 loc) · 2.1 KB

09_websockets_1.md

File metadata and controls

57 lines (43 loc) · 2.1 KB

Lesson 9: WebSockets 1

These two lessons will focus on fast client-server communication using WebSockets. We will discuss when to use WebSockets (versus AJAX) and the many applications of it.
In the working session we will build a simple chat and a bare-bones multiplayer game using the Socket.io library.


Lecture

Websockets

  • Basically a way to send "messages" (data) back and forth between client and server.
  • It establishes a persistent client-server connection, where both are constantly "listening" to each other.
  • AJAX vs Websockets
  • You'll use it when your app needs low-latency ("realtime") communication.
  • Cases:
    • your users communicate with each other
      • chats
      • online editing tools
      • multiplayer games
    • your website is constantly changing based on the user interaction
      • social media feeds
      • location-based apps
      • online education websites
  • WebSockets examples
  • WebSockets libraries

Working Session: Socket.io

  • Simple Chat

    • Application Diagram
    • Adding the socket.io library
    • Messaging
      • Listeners
  • Multiplayer

    • Application Diagram
    • Updating the server data
    • Updating the client view

Extra


Assignment

Project #2 proposal

Now that you have seen some use cases for WebSockets, think about what you would do with it. Try to come up with a proposal as detailed as possible. Who is it for? How does it work? What technologies — third-party APIs, mobile, NodeJS modules, etc — do you need? Does it require a database? What is the data model?