Skip to content

ansionfor/websocket-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

websocket-demo

基于beego的websocket点对点私聊demo

1、下载

git clone https://github.com/ansionfor/websocket-demo.git

2、导入sql,修改配置文件

3、运行

go run main.go

2021/02/04 19:57:10.407 [I] [main.go:9]  demoIM 1.0 
2021/02/04 19:57:10.428 [I] [asm_amd64.s:1374]  http server Running on http://:8080

4、连接

var ws = new WebSocket("ws://ip:8080/ws?sessionId=1");

ws.onopen = function(evt) { 
  console.log("Connection open ..."); 
  ws.send("ping");
};

ws.onmessage = function(evt) {
  console.log( "Received Message: " + evt.data);
  ws.close();
};

ws.onclose = function(evt) {
  console.log("Connection closed.");
}; 

About

基于beego的websocket点对点私聊demo

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages