This commit is contained in:
2024-04-05 14:07:52 +03:00
parent b1236e724a
commit 58d0141d43
12 changed files with 129 additions and 146 deletions
+14 -14
View File
@@ -11,21 +11,21 @@ Melody is websocket framework based on [github.com/gorilla/websocket](https://gi
that abstracts away the tedious parts of handling websockets. It gets out of
your way so you can write real-time apps. Features include:
* [x] Clear and easy interface similar to `net/http` or Gin.
* [x] A simple way to broadcast to all or selected connected sessions.
* [x] Message buffers making concurrent writing safe.
* [x] Automatic handling of sending ping/pong heartbeats that timeout broken sessions.
* [x] Store data on sessions.
- [x] Clear and easy interface similar to `net/http` or Gin.
- [x] A simple way to broadcast to all or selected connected sessions.
- [x] Message buffers making concurrent writing safe.
- [x] Automatic handling of sending ping/pong heartbeats that timeout broken sessions.
- [x] Store data on sessions.
## Install
```bash
go get github.com/olahol/melody
go get git.company.lan/gopkg/melody
```
## [Example: chat](https://github.com/olahol/melody/tree/master/examples/chat)
## [Example: chat](https://git.company.lan/gopkg/melody/tree/master/examples/chat)
[![Chat](https://cdn.rawgit.com/olahol/melody/master/examples/chat/demo.gif "Demo")](https://github.com/olahol/melody/tree/master/examples/chat)
[![Chat](https://git.company.lan/gopkg/nested/raw/branch/master/examples/chat/demo.gif "Demo")](https://git.company.lan/gopkg/melody/tree/master/examples/chat)
```go
package main
@@ -33,7 +33,7 @@ package main
import (
"net/http"
"github.com/olahol/melody"
"git.company.lan/gopkg/melody"
)
func main() {
@@ -55,9 +55,9 @@ func main() {
}
```
## [Example: gophers](https://github.com/olahol/melody/tree/master/examples/gophers)
## [Example: gophers](https://git.company.lan/gopkg/melody/tree/master/examples/gophers)
[![Gophers](https://cdn.rawgit.com/olahol/melody/master/examples/gophers/demo.gif "Demo")](https://github.com/olahol/melody/tree/master/examples/gophers)
[![Gophers](https://git.company.lan/gopkg/nested/raw/branch/master/examples/gophers/demo.gif "Demo")](https://git.company.lan/gopkg/melody/tree/master/examples/gophers)
```go
package main
@@ -66,8 +66,8 @@ import (
"net/http"
"strings"
"git.company.lan/gopkg/melody"
"github.com/google/uuid"
"github.com/olahol/melody"
)
type GopherInfo struct {
@@ -137,7 +137,7 @@ func main() {
}
```
### [More examples](https://github.com/olahol/melody/tree/master/examples)
### [More examples](https://git.company.lan/gopkg/melody/tree/master/examples)
## [Documentation](https://godoc.org/github.com/olahol/melody)
@@ -149,7 +149,7 @@ func main() {
## FAQ
If you are getting a `403` when trying to connect to your websocket you can [change allow all origin hosts](http://godoc.org/github.com/gorilla/websocket#hdr-Origin_Considerations):
If you are getting a `403` when trying to connect to your websocket you can [change allow all origin hosts](http://godoc.org/github.com/gorilla/websocket#hdr-Origin_Considerations):
```go
m := melody.New()