Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 292a756

Browse files
committed
改进 websocket
1 parent ea58d15 commit 292a756

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

websites/code2/studygolang/src/http/controller/websocket.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ type WebsocketController struct {
2424
mutex sync.Mutex
2525
}
2626

27-
func (this *WebsocketController) RegisterRoute(e *echo.Group) {
28-
e.Get("/ws", standard.WrapHandler(websocket.Handler(this.Ws)))
27+
func (this *WebsocketController) RegisterRoute(g *echo.Group) {
28+
g.Get("/ws", standard.WrapHandler(websocket.Handler(this.Ws)))
2929
}
3030

3131
// websocket,统计在线用户数

websites/code2/studygolang/src/vendor/manifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@
203203
{
204204
"importpath": "github.com/polaris1119/goutils",
205205
"repository": "https://github.com/polaris1119/goutils",
206-
"revision": "15c2eed5ef7632c6807c5b46eaf4cfc3c201d629",
206+
"revision": "582c98b3184b83e1600833fb042b3ecc3070dcda",
207207
"branch": "master"
208208
},
209209
{

websites/code2/studygolang/static/js/common.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -403,12 +403,14 @@ window.WebSocket = window.WebSocket || window.MozWebSocket;
403403
if (window.WebSocket) {
404404
var websocket = new WebSocket(wsUrl);
405405

406-
websocket.onopen = function(){
406+
websocket.onopen = function(evt){
407407
// console.log("open");
408+
// console.log(evt);
408409
}
409410

410-
websocket.onclose = function(){
411+
websocket.onclose = function(evt){
411412
// console.log("close");
413+
// console.log(evt);
412414
}
413415

414416
websocket.onmessage = function(msgEvent){
@@ -433,7 +435,9 @@ if (window.WebSocket) {
433435
}
434436
}
435437

436-
// websocket.onerror = onError;
438+
websocket.onerror = function(evt) {
439+
// console.log(evt);
440+
}
437441
}
438442

439443
$(function(){

0 commit comments

Comments
 (0)