Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/flxxyz/blue
基于gorilla/websocket构建的微型websocket框架
https://github.com/flxxyz/blue
go golang golang-library websocket
Last synced: 4 days ago
JSON representation
基于gorilla/websocket构建的微型websocket框架
- Host: GitHub
- URL: https://github.com/flxxyz/blue
- Owner: flxxyz
- License: mit
- Created: 2019-07-15T11:25:26.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-07-18T06:14:50.000Z (over 5 years ago)
- Last Synced: 2024-06-20T06:24:30.995Z (5 months ago)
- Topics: go, golang, golang-library, websocket
- Language: Go
- Homepage:
- Size: 12.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# blue
基于[gorilla/websocket](https://github.com/gorilla/websocket)构建的微型websocket框架ps: 为什么叫这个名字呢,因为最近在听[the blue hearts](https://zh.wikipedia.org/zh/THE_BLUE_HEARTS)这个乐队
## 依赖要求
没有## 安装
使用`go`命令获取类库```bash
go get github.com/flxxyz/blue
```## 例子
### net/http
```go
package mainimport (
"bytes"
"github.com/flxxyz/blue"
"log"
"net/http"
)func main() {
heart := blue.NewHeart()
heart.HandlerMessage(func(c *blue.Client, data *bytes.Buffer) {
heart.Broadcast(data)
log.Printf("[%s] body: %s", c.ID.String(), data.String())
})
http.HandleFunc("/", heart.ServeHTTP)
if err := http.ListenAndServe(":7777", nil); err == nil {
log.Fatal("GG")
}
}
```### gin
```go
package mainimport (
"bytes"
"github.com/flxxyz/blue"
"github.com/gin-gonic/gin"
"log"
)func main() {
heart := blue.NewHeart()
heart.HandlerMessage(func(c *blue.Client, data *bytes.Buffer) {
heart.Broadcast(data)
log.Printf("[%s] body: %s", c.ID.String(), data.String())
})
gin.SetMode(gin.ReleaseMode)
r := gin.Default()
r.GET("/", func(c *gin.Context) {
heart.ServeHTTP(c.Writer, c.Request)
})
r.Run(":7777")
}
```## 文档
[文档点这里](http://godoc.org/github.com/flxxyz/blue)## 版权
blue包在MIT License下发布。有关详细信息,请参阅LICENSE。