1.0.3 • Published 2 years ago

@haiyaotec/window-channel v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Install

npm install @haiyaotec/window-channel

Usage/Examples

Client

    import {WindowChannel} from '@haiyaotec/window-channel'
    let client = WindowChannel.newChannelClient(window,iFrame.contentWindow,"*")
    function f() {
        client.request('/hello', '客户端发送的消息', 1000)
            .then((value) => {
                console.log(value)
            })
            .catch((err) => {
                console.log(err)
            })
    }
    setInterval(f,3000)

Server

import {WindowChannel} from '@haiyaotec/window-channel'
let service=WindowChannel.newChannelService(window)

service.listen('/hello',(value)=>{
    console.log(value)
    return '服务端发送的消息'
})

service.observe('/dingyue',()=>{
    console.log('订阅成功')
})

setTimeout(()=>{
    service.broadcast('/dingyue','聊天室广播内容')
},20000)

License

MIT License © 2021-Present YuDong Su

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago