1.0.4 • Published 7 years ago

lc-websocket v1.0.4

Weekly downloads
6
License
ISC
Repository
github
Last release
7 years ago

简介

  • 简易websocket封装

后端

  • 使用net或者http模块进行通信
    var http = require('http').createServer()
    var Server = require('node-websocket')(http)
    Server.on('connection', function(socket) {
        socket.on('data', function(msg) {
            socket.sendOthers('hello and there is a message from ' + socket.id + ': ' + msg.PayloadData)
        })
    })
    http.listen(8080)

前端

  • 使用html5 WebSocket原生对象进行连接
    var ws = new WebSocket('ws:localhost:8080')
    ws.onmessage = function(msg) {
        console.log(msg)
    }
1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago