https://github.com/luisvalgoi/websocket-playground
Repository dedicated to learn more about the usage of WebSockets.
https://github.com/luisvalgoi/websocket-playground
websocket websockets
Last synced: about 1 year ago
JSON representation
Repository dedicated to learn more about the usage of WebSockets.
- Host: GitHub
- URL: https://github.com/luisvalgoi/websocket-playground
- Owner: LuisValgoi
- Created: 2021-08-05T01:23:10.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2021-08-05T03:44:50.000Z (almost 5 years ago)
- Last Synced: 2025-02-05T13:42:55.967Z (over 1 year ago)
- Topics: websocket, websockets
- Language: TypeScript
- Homepage:
- Size: 234 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Objective
This repository is dedicated to learn more about the usage of WebSockets.
# Reference
[https://www.youtube.com/watch?v=1BfCnjr_Vjg&ab_channel=Fireship](https://www.youtube.com/watch?v=1BfCnjr_Vjg&ab_channel=Fireship)
https://www.valentinog.com/blog/socket-react/
# What is
- it enables you to build real-time features between a client & server
# Example
- multiplayer game
- telefone communication
# Process
1 - client sends an HTTP open-connection request
```bash
GET ws://some-url HTTP/1.1
Connection: Upgrade
Upgrade: websocket
```
2 - if the server agrees, it sends an accept response
```bash
HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
```
3 - handshake is complete.
4 - A `TCP/IP` is left opened and allows bi-directional data exchange with low latency (aka `FULL-DUPLEX`)
5 - It will stay open until one of the party drops off
# Usage
- `node .`.
- `yarn start`.
- `open` 2 tabs.
- `type` in the input.
- `press` send.