or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Syncing
xxxxxxxxxx
How-to: Make your application real-time
https://hackmd.io/p/parisjs-realtime
We'll invite you to play with us!
Get ready to join with your phone or laptop.
Join the Demo!
https://hackmd.io/parisjs-realtime-demo
HackMD
Build community with open collaboration
Techstars backed
Helping developers to enjoy writing documentations.
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →Help open source technologies to build an active developer community.
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →Max Wu
CTO of HackMD
I love great product and build them.
I'm developing my dream with code.
What is real-time?
Enable users to receive information as soon as it is published by its authors.
How fast will you consider it's real-time?
60 FPS makes a smooth video.
60 frames per second (FPS)
1000 millisecond / 60 frames
~= 16.67 ms/frame
16.67 ms
for such a computation
The average network latency is
70 ms
Hard to feel it's real-time
if it only shows when data arrives
So you fake it!
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →that's what most modern web app does
Optimistic lock
What makes web real-time?
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →traditional HTTP model
It's one way communication
server can't actively push data to client
real-time requires to send updates to client
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →long-polling HTTP model
Still one way communication
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →traffic flows only go one direction at a time
reduntant information sent with every request and response
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →WebSocket comes to rescue!
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →WebSocket
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →ref.
Efficiency
ref.
What can you build with WebSocket?
see some examples
Collaborative text editor
HackMD
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →Agar.io
An online multipleplayer game
Online chat room
https://socketio-chat-example.now.sh/
GitHub
also uses it to update pages
There's always a catch
https://caniuse.com/#search=websocket
Time for
Image Not Showing
Possible Reasons
Socket.IO
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →Socket.IO
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →Everyone now is happy
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →Socket.IO
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →Let's make a chat room with
Socket.IO
Installation
Client
Include
socket.io-client
script in the html.Installation
Server
Install
socket.io
from npmCreate HTTP server and bind with
socket.io
in the node.js app.Client establishes connection
Client tries to connect chat room
Server listens on connection
Server accepts client connection
Server broadcasts to everyone
Server broadcasts room status
Client emits event
Client emits chat message to room
Server listens on event
Server receives the message
Server sends to everyone
excepts for a certain socket
Server broadcasts chat message to other clients
read more
emit cheatsheet
Server-Sent Events
an alternative for sending from server to client
Server-Sent Events
There's always a catch, again
Can be easily polyfilled!
https://caniuse.com/#search=server sent
Comparsion
TL;DR
Socket.IO
is the one for allThanks for listening!
Do you have any question?
@jackycute
HackMD.io
References
References