phecda-client-ws
v2.0.0
Published
client for phecda-server-ws
Downloads
6
Maintainers
Readme
phecda-client-ws
client to request phecda-server-ws
install
npm i phecda-client-ws
quick start
in vite.config.ts
import { defineConfig } from 'vite'
import plugin from 'phecda-client/vite'
export default defineConfig({
plugins: [plugin()],
})
create client and request to server
import { createClient } from 'phecda-client-ws'
import { TestWs } from '../server/test.ws'// it will redirect to .ps/ws.js
const ws = new WebSocket('ws://localhost:3001')
const client = createClient(ws, {
test: TestWs,
}, {
test(data) {
console.log(data)
},
})
ws.onopen = () => {
console.log('open!')
client.test.add({ name: 'ws' })
}