Compare commits
No commits in common. "d3513ae4fad57176cc417ec0570270c5f9e14c29" and "3c70ad2377167d41b4bbc7b2b82b47c04b83b699" have entirely different histories.
d3513ae4fa
...
3c70ad2377
@ -1,15 +1,12 @@
|
||||
package sse
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"gitea.bvbej.com/bvbej/base-golang/pkg/mux"
|
||||
"gitea.bvbej.com/bvbej/base-golang/pkg/ticker"
|
||||
"github.com/gin-gonic/gin"
|
||||
"io"
|
||||
"net/http"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
)
|
||||
|
||||
var _ Server = (*event)(nil)
|
||||
@ -34,9 +31,9 @@ type msgChan struct {
|
||||
type event struct {
|
||||
SessionList sync.Map
|
||||
Count atomic.Int32
|
||||
|
||||
Register chan clientChan
|
||||
Unregister chan any
|
||||
Ticker ticker.Ticker
|
||||
}
|
||||
|
||||
func NewServer() Server {
|
||||
@ -45,12 +42,8 @@ func NewServer() Server {
|
||||
Count: atomic.Int32{},
|
||||
Register: make(chan clientChan),
|
||||
Unregister: make(chan any),
|
||||
Ticker: ticker.New(time.Second * 3),
|
||||
}
|
||||
|
||||
go e.Ticker.Process(func() {
|
||||
e.Broadcast("ping", fmt.Sprintf("%d", time.Now().Unix()))
|
||||
})
|
||||
go e.listen()
|
||||
|
||||
return e
|
||||
|
Loading…
Reference in New Issue
Block a user