added explicit encode/decode to example, added type=module to package.json
This commit is contained in:
parent
7ccfaa2f90
commit
2047803276
2 changed files with 5 additions and 4 deletions
|
@ -10,11 +10,11 @@ import { async_run } from 'framerock'
|
||||||
const jsbuild_app_frontend = async function () {
|
const jsbuild_app_frontend = async function () {
|
||||||
return `
|
return `
|
||||||
const on_open = function () {
|
const on_open = function () {
|
||||||
FRAMEROCK_UTILS.transport_send_bytes('Hello from client!')
|
FRAMEROCK_UTILS.transport_send_bytes(new TextEncoder().encode('Hello from client!'))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const on_message = function (data) {
|
const on_message = function (data) {
|
||||||
console.log(['Client received message:', data])
|
console.log(['Client received message:', new TextDecoder().decode(data)])
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
FRAMEROCK_UTILS.setup_transport({ on_open, on_message })
|
FRAMEROCK_UTILS.setup_transport({ on_open, on_message })
|
||||||
|
@ -22,8 +22,8 @@ FRAMEROCK_UTILS.setup_transport({ on_open, on_message })
|
||||||
}
|
}
|
||||||
|
|
||||||
const handle_transport_bytes = function (utils, message) {
|
const handle_transport_bytes = function (utils, message) {
|
||||||
console.log(['Server received message:', message])
|
console.log(['Server received message:', new TextDecoder().decode(message)])
|
||||||
utils.transport_send_bytes('Hello from server!')
|
utils.transport_send_bytes(new TextEncoder().encode('Hello from server!'))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
{
|
{
|
||||||
"name": "framerock",
|
"name": "framerock",
|
||||||
|
"type": "module",
|
||||||
"main": "backend/index.js"
|
"main": "backend/index.js"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue