Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/xiaodaigh/wsumm
A set of Write-functions to make gorilla/websocket's write to connection be blocking if another Write-function was using the connection
https://github.com/xiaodaigh/wsumm
go gorilla websocket
Last synced: about 1 month ago
JSON representation
A set of Write-functions to make gorilla/websocket's write to connection be blocking if another Write-function was using the connection
- Host: GitHub
- URL: https://github.com/xiaodaigh/wsumm
- Owner: xiaodaigh
- Created: 2017-08-13T06:17:24.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-08-14T03:15:33.000Z (over 7 years ago)
- Last Synced: 2024-10-13T19:38:57.366Z (3 months ago)
- Topics: go, gorilla, websocket
- Language: Go
- Homepage:
- Size: 3.91 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# wsumm
Wrapper functions to make gorilla/websocket's Write*Functions* i.e. WriteMessage and WriteJSON be blocking if another Write*function* of the same channel is being run.# Installation
In command line```
go get github.com/xiaodaigh/wsumm
```# Example Usage
```go
package test_wsummimport (
"github.com/gorilla/websocket"
"github.com/xiaodaigh/wsumm"
"net/http"
)var upgrader = wsumm.Upgrader{
Upgrader: &websocket.Upgrader{
ReadBufferSize: 1024,
WriteBufferSize: 1024,
}}func someHandler(w http.ResponseWriter, r *http.Request) {
conn, _ := upgrader.Upgrade(w, r, nil)
go func() {
for i := 0; i < 1000; i++ {
conn.WriteMessage(websocket.TextMessage, []byte("testing"))
}
}()
go func() {
for i := 0; i < 1000; i++ {
conn.WriteJSON(struct{}{})
}
}()
}
```