mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-08-31 22:34:02 +03:00
Correct multiplexing
This commit is contained in:
+5
-14
@@ -4,30 +4,21 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"sync"
|
||||
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
var (
|
||||
Registry *registry
|
||||
Hub *hub
|
||||
|
||||
ErrTimeout = errors.New("timeout")
|
||||
ErrClosed = errors.New("channel was closed")
|
||||
ErrCannotCreateConnection = errors.New("cannot create connection")
|
||||
ErrTimeout = errors.New("timeout")
|
||||
ErrClosed = errors.New("context is closed")
|
||||
|
||||
Hub Interface
|
||||
initOnce sync.Once
|
||||
)
|
||||
|
||||
func Init(ctx context.Context) {
|
||||
initOnce.Do(func() {
|
||||
Registry = ®istry{
|
||||
conns: map[string]*ctxChannel{},
|
||||
ctx: ctx,
|
||||
}
|
||||
Hub = &hub{
|
||||
subs: map[string]*connectionHub{},
|
||||
logger: zap.S().Named("hub"),
|
||||
muxes: make(map[int32]*mux),
|
||||
ctx: ctx,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user