Git Product home page Git Product logo

fetch-upload-streaming-chat-sibal's Introduction

Fetch Upload Streaming HTTP/2 Chat (Using Sibal Protocol)

Chat example using HTTP/2 Streaming request and Streaming response.

Server

cd server
npm i -D
npm run watch

Server will serve on https://127.0.0.1:8000, using celf-certificated certs.

Web Client

cd client
npm i -D
npm run serve

http://127.0.0.1:9000

You may need to use chrome canary(> 105). You should go to https://127.0.0.1:8000/ once, and select continue (to ignore security error of self-certificated certificate).

How it works

Because browser does not support full-duplex http/2 connection yet, we use two http connections for download and upload.

  1. Client establishes download stream connection(GET)
  2. Server generates temporary id for the client and sends it to the client.
  3. Client establishes upload stream connection(POST) and sends temporary id that received from server.
  4. Now server knows upload and download stream connection pair for the client.
  5. Full-duplex connection is established using two stream connections(download, upload).

Why use Sibal Protocol?

Upload and download stream is like tcp socket, fetch upload stream does not guarantee each chunk to be sent separately, of course download stream does not guarantee those thing too. So we need messaging protocol to seperate each message. Sibal is simple protocol to separate each message. It is implemented with Web Streams API, which you can use in both browser and node environment so that you can use it easily.

fetch-upload-streaming-chat-sibal's People

Contributors

lunuy avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.