Upgrade to Pro — share decks privately, control downloads, hide ads and more …

WebTransport mini handson

WebTransport mini handson

2024.06.28 に某所で実施予定の「WebTransport ミニミニハンズオン」の資料です。

D.F.Mac. @TripArts Music

June 27, 2024
Tweet

More Decks by D.F.Mac. @TripArts Music

Other Decks in Technology

Transcript

  1. ͳΜͰ5$1ϕʔε͕௥Ճ͞Εͨͷ 8FC5SBOTQPSUͱ͸ ˠ6%1΍26*$࢖͑ͳ͍γʔϯଟ͍͔Βɻ 
 ྫɿ 
 ɹɾ6%1ϙʔτۭ͍ͯͳ͍ ɹɾ1SPYZαʔόʔ͘Μ͕अຐ͢Δ 
 ϦΞϧλΠϜੑೳ͸

    ˠ౰વԼ͕Δͱ༧૝ɻʢ࣮૷͕ແ͍ͷͰɺͲͷ͘Β͍Լ͕Δ͔͸Θ͔ΒΜ͚Ͳʣ PWFS)551ʹμ΢ϯάϨʔυͯ͠خ͍͠Ϣʔεέʔε͸ ˠ8FC4PDLFUͷ୅ΘΓʹϕετΤϑΥʔτͰੑೳ্͛ͯ8FC5SBOTQPSUΛ࢖͍͍ͨ ɹˠૣ͞ΑΓ΋ܨ͍͛ͨɺͱ͍͏ํ޲ 
 ɹɹˠͰ΋ɺ8FC4PDLFUͷ··Ͱ΋͍͍ͷͰ͸ʁͱ͍͏ٙ໰΋ɻ PWFS)551ʹμ΢ϯάϨʔυ͞ΕͯࠔΓͦ͏ͳϢʔεέʔε͸ ˠEBUBHSBN࢖͍͍͔ͨΒ8FC5SBOTQPSUΛ࢖͏Α͏ͳγʔϯɻ 
 ɹྫ͑͹ɺ.FEJBPWFS2VJDͷϕʔεͱͯ͠8FC5SBOTQPSU࢖ͬͯΔͱ͔ͷ࣌͸ɺ ɹεϧʔϓοτͰͳ͍Μ͡Όͳ͍͔ʁͱࢥ͏ɻ
  2. 8FC5SBOTQPSUͱ͸ ·ͱΊɻ 8FC5SBOTQPSUͱ͸ 8$8% ˠ·ͩ࢓༷ࡦఆத͕ͩɺ৽͍͠௿Ϩϕϧτϥϯεϙʔτ"1*ɻΒ͍͠ɻ 
 ˠ೥݄ݱࡏී௨ʹར༻Ͱ͖Δͷ͸8FC5SBOTQPSUPWFS)551ͷΈɻ ɹ!GBJMTDPNQPSOFOUXFCUSBOTQPSU͕PWFS)551༻ͷQPMZ fi MM

    TFSWFS࣮૷Λެ։͍ͯ͠Δɻ͍͢͝ɻ 6%1 5$1 )551 )551 8FC5SBOTQPSU 
 PWFS)551 8FC5SBOTQPSU 
 PWFS)551 8FC5SBOTQPSU 
 GPS11 4BGBSJҎ֎ͷϒϥ΢βରԠ ·ͩͲͷϒϥ΢β΋ະରԠ ·ͩͲͷϒϥ΢β΋ະରԠ 5-4 26*$ 5-4
  3. 8FC5SBOTQPSUͱ͸ ·ͱΊɻ 8FC5SBOTQPSUͱ͸ ࡶ͗ͯ͢ɺϚαΧϦͱΜͰ͖ͦ͏͚ͩͲɺ͍͍ͩͨ͜Μͳײͩ͡ͱࢥ͏ɻ )551GFUDI 
 9)3 8FC4PDLFU 8FC35$ 8FC5SBOTQPSU

    
 PWFS)551 ৴པੑ ˓ ˓ ºNFEJBTUSFBN 
 ˚ʙ˓EBUBDI ˚4USFBN 
 º%BUBHSBN ϦΞϧλΠϜੑೳ º º ˓ ˚4USFBN 
 ˓%BUBHSBN ηΩϡϦςΟ ˓44-ͷ৔߹ 
 ºඇ44-ͷ৔߹ ˓44-ͷ৔߹ 
 ºඇ44-ͷ৔߹ ˓ ˓ ࠓ࢖͑Δ͔ʁ ˓ ˓ ˓ º4BGBSJ଴ͪ ௨৴ํ޲ $ˠ4ͷΈ $⁶4૒ํ޲ جຊతʹ$ˠ$ 
 ͷٕज़ $⁶4૒ํ޲ ࢖͍ॴ σʔλ"1*ɺ 
 ίϯςϯπऔಘ νϟοτ 
 ૒ํ޲"1* 
 αʔόʔΠϕϯτ ϝσΟΞ௨৴ 
 11ڞ༗ ήʔϜ 
 ϦΞϧλΠϜಉظ 
 .P2
  4. ΍Δ͜ͱ֓ཁ 8FC5SBOTQPSU͸௿Ϩϕϧͳ"1*ઃܭͳͷͰɺΞϓϦέʔγϣϯ͔Β௚઀ѻ͏ͷ͸গʑࠎ͕ંΕ·͢ɻ ɾී௨ʹίʔσΟϯά͕ΊΜͲ͍͘͞ʢԼهࢀরʣ 
 ɾূ໌ॻ͕͍Ζ͍ΖΊΜͲ͍͘͞ʢ)551ͷੑʣ 
 ɾͦ΋ͦ΋OPEFKT·ͩ)551ʹରԠͯ͠ͳ͍͔Β͍Ζ͍Ζ޻෉͕ඞཁ͚ͩͲɺԿΛ͢Ε͹͍͍͔ʁ ɹௐ΂Δ͚ͩͰେมʢݹ͍৘ใʹ࿭Θ͞ΕΔʣ ͜ΕΛղܾ͢ΔͨΊʹɺ4FSWFS$MJFOUͷςετ؀ڥΛ؆୯ʹ্ཱͪ͛ΒΕΔϥούʔϥΠϒϥϦΛ 


    ࢖ͬͨαϯϓϧΛͭ͘Γ·ͨ͠ɻ 
 ͷͰɺ͜ΕΛ࢖ͬͯര଎XFCUSBOTQPSU؀ڥͷߏஙΛࢼ͢ɻͱ͍͏ϋϯζΦϯͰ͢ɻ 8FC4PDLFUड৴ॲཧͷྫ const ws = new WebSocket(url); 
 ws.onmessage = (e)=>{ // onmessageॲཧ; 
 } 8FC5SBOTQPSUड৴ॲཧͷྫʢTUSFBNʣ const wt = new WebTransport(url); 
 const st = wt.incomingUnidirectionalStreams; 
 const reader = st.getReader(); while (true) { const { done, value } = await reader.read(); if (done) { break; } await readData(value); } async function readData(receiveStream) { const reader = receiveStream.getReader(); while (true) { const { done, value } = await reader.read(); if (done) { break; } // ड৴ॲཧ } }
  5. NLDFSUΠϯετʔϧ NBDʮλʔϛφϧʯىಈ brew install mkcert XJO؅ཧऀϞʔυͰQPXFSTIFMMىಈ choco install mkcert cd

    powt-example1/cert 
 mkcert --install 
 mkcert localhost MPDBMIPTUূ໌ॻΠϯετʔϧ cd .. 
 npm i 
 node ./app.mjs OQNJ ΞϓϦىಈ chrome://flags#webtransport-developer-mode ϒϥ΢β fl BHมߋ DISPNFΛىಈ͠ɺΞυϨεόʔʹԼهೖྗ <FOBCMFE>ʹมߋ͠ϒϥ΢β࠶ىಈ ΫϥΠΞϯτ΁ΞΫηε https://localhost:4445 DISPNFΛىಈ͠ɺΞυϨεόʔʹԼهೖྗ