mirror of
https://github.com/logos-messaging/docs.waku.org.git
synced 2026-01-07 15:23:07 +00:00
1 line
12 KiB
JavaScript
1 line
12 KiB
JavaScript
|
|
"use strict";(self.webpackChunkwaku_guide=self.webpackChunkwaku_guide||[]).push([[448],{17388:(e,n,s)=>{s.r(n),s.d(n,{assets:()=>l,contentTitle:()=>o,default:()=>h,frontMatter:()=>i,metadata:()=>a,toc:()=>d});const a=JSON.parse('{"id":"build/javascript/reliable-channels","title":"Send and Receive Messages in a Reliable Channel","description":"Learn how to send and receive messages with a convenient SDK that provide various reliable functionalities out-of-the-box.","source":"@site/docs/build/javascript/reliable-channels.md","sourceDirName":"build/javascript","slug":"/build/javascript/reliable-channels","permalink":"/build/javascript/reliable-channels","draft":false,"unlisted":false,"editUrl":"https://github.com/waku-org/docs.waku.org/tree/develop/docs/build/javascript/reliable-channels.md","tags":[],"version":"current","lastUpdatedAt":null,"frontMatter":{"title":"Send and Receive Messages in a Reliable Channel","hide_table_of_contents":true,"displayed_sidebar":"build"},"sidebar":"build","previous":{"title":"JavaScript Waku SDK","permalink":"/build/javascript/"},"next":{"title":"Send and Receive Messages Using Light Push and Filter","permalink":"/build/javascript/light-send-receive"}}');var t=s(74848),r=s(28453);const i={title:"Send and Receive Messages in a Reliable Channel",hide_table_of_contents:!0,displayed_sidebar:"build"},o=void 0,l={},d=[{value:"Import Waku SDK",id:"import-waku-sdk",level:2},{value:"Create a Waku node",id:"create-a-waku-node",level:2},{value:"Create encoders and decoders",id:"create-encoders-and-decoders",level:2},{value:"Listen for connection status",id:"listen-for-connection-status",level:2},{value:"Create a reliable channel",id:"create-a-reliable-channel",level:2},{value:"Create a message structure",id:"create-a-message-structure",level:2},{value:"Listen to incoming messages",id:"listen-to-incoming-messages",level:2},{value:"Send messages",id:"send-messages",level:2}];function c(e){const n={a:"a",admonition:"admonition",code:"code",em:"em",h2:"h2",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,r.R)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.p,{children:"Learn how to send and receive messages with a convenient SDK that provide various reliable functionalities out-of-the-box."}),"\n",(0,t.jsx)(n.admonition,{type:"warning",children:(0,t.jsxs)(n.p,{children:["This is an experimental feature and has a number of ",(0,t.jsx)(n.a,{href:"https://github.com/waku-org/js-waku/pull/2526",children:"limitations"}),"."]})}),"\n",(0,t.jsx)(n.h2,{id:"import-waku-sdk",children:"Import Waku SDK"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-shell",children:"npm install @waku/sdk@latest\n"})}),"\n",(0,t.jsxs)(n.p,{children:["Or using a CDN, note this is an ESM package so ",(0,t.jsx)(n.code,{children:'type="module"'})," is needed."]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-html",children:"<script type=\"module\">\n import {\n createLightNode,\n ReliableChannel\n } from 'https://unpkg.com/@waku/sdk@latest/bundle/index.js';\n\n // Your code here\n \n<\/script>\n"})}),"\n",(0,t.jsx)(n.h2,{id:"create-a-waku-node",children:"Create a Waku node"}),"\n",(0,t.jsxs)(n.p,{children:["Use the ",(0,t.jsx)(n.code,{children:"createLightNode()"})," function to create a ",(0,t.jsx)(n.a,{href:"/learn/glossary#light-node",children:"Light Node"})," and interact with the Waku Network:"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-js",children:'import { createLightNode } from "@waku/sdk";\n\n// Create a Light Node\nconst node = await createLightNode({ defaultBootstrap: true });\n'})}),"\n",(0,t.jsx)(n.admonition,{type:"info",children:(0,t.jsxs)(n.p,{children:["When the ",(0,t.jsx)(n.code,{children:"defaultBootstrap"})," parameter is set to ",(0,t.jsx)(n.code,{children:"true"}),", your node will be bootstrapped using the ",(0,t.jsx)(n.a,{href:"/build/javascript/configure-discovery#default-bootstrap-method",children:"default bootstrap method"}),". Have a look at the ",(0,t.jsx)(n.a,{href:"/build/javascript/configure-d
|