WebSocket使Web伺服器可以與客戶端建立專用連接,原始數據可以在任何時間,任何方向流動,而無需請求/響應周期和HTTP協議的「個性」。與Socket.IO等高級協議配合使用,您將獲得功能強大且易於使用的雙向低延遲通信框架,並且客戶端可用於Python,JavaScript,Java,iOS,Android,C ++ 、. Net和更多。 Flask是用於Python的輕量級且非常流行的Web框架,它使編寫Web伺服器變得簡單而有趣,而不會犧牲任何功能。將WebSocket,Socket.IO和Flask結合使用會發生什麼?在本演講中,我將向您展示將這些技術結合使用時可以構建的一些很酷的應用程序,包括流音頻和視頻,實時感測器數據,自動投票等等!
#WebSocket #Flask。
1:53 what is websocket
http limited to request/response interacation
4:20 socket.io protocol
!1 that is built on top of pure websocket and HTTP
!2 socket.io can switch to HTTP long polling( for dummy IE )
!3 you can think of socket.io as a way for the server code to invoke a function in the client, or the client calling a fuction in the server .
you write a function on one side and other side can call it.
!4 "invoke event" is equal to call fucntion
7:36 socket.IO and python
!1 server side :python-socketio
client side :socketio-client
9:17 webSocket and async
!1 flask is not support async
!2 WSGI apps must run on evenlet or gevent to get an async wrapper
!3 9:42 HOW webservers work?
11:20 examples on https://github.com/miguelgrinberg/socketio-examples
12:18 example #1 chat
!1 in server side, create the functions that the client will invoke (with emit function)
16:31 example #2 Audio streaming(client streaming to the server)
21:54 example #3 file uploading
! we have functions on the server, functions on the client
26:41 example #4 live polls
32:36 example #5 where do you live
magnifique
Fantastic