Compare commits
No commits in common. "5b63b517c83830042e3758d79d4d45ea5d4a2366" and "bcaf9030aa9e7a246d0786b5f2e95fe6cbfef115" have entirely different histories.
5b63b517c8
...
bcaf9030aa
21
CHANGELOG.md
21
CHANGELOG.md
|
@ -1,26 +1,5 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
## [0.5.8](https://github.com/kercylan98/minotaur/compare/v0.5.7...v0.5.8) (2024-05-01)
|
|
||||||
|
|
||||||
|
|
||||||
### Features | 新特性
|
|
||||||
|
|
||||||
* server 新增 NewOfflineConn 函数,兼容部分特殊操作 ([147f0a3](https://github.com/kercylan98/minotaur/commit/147f0a31a0859502cc32775751cadb48fd31181f))
|
|
||||||
|
|
||||||
## [0.5.7](https://github.com/kercylan98/minotaur/compare/v0.5.6...v0.5.7) (2024-04-23)
|
|
||||||
|
|
||||||
|
|
||||||
### Bug Fixes | 修复
|
|
||||||
|
|
||||||
* 修复 timer.Pool 在获取到池中 Ticker 时,可选项不生效的问题 ([be6af14](https://github.com/kercylan98/minotaur/commit/be6af14261a200ac3911ebdef1edf2cae2e35f3d))
|
|
||||||
|
|
||||||
## [0.5.6](https://github.com/kercylan98/minotaur/compare/v0.5.5...v0.5.6) (2024-04-19)
|
|
||||||
|
|
||||||
|
|
||||||
### Bug Fixes | 修复
|
|
||||||
|
|
||||||
* 修复 timer.Ticker 死锁 ([45024f3](https://github.com/kercylan98/minotaur/commit/45024f3b9fe41131dab65ba0ead4361ad0a0d23b))
|
|
||||||
|
|
||||||
## [0.5.5](https://github.com/kercylan98/minotaur/compare/v0.5.4...v0.5.5) (2024-04-10)
|
## [0.5.5](https://github.com/kercylan98/minotaur/compare/v0.5.4...v0.5.5) (2024-04-10)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,6 @@ import (
|
||||||
"github.com/panjf2000/gnet"
|
"github.com/panjf2000/gnet"
|
||||||
"github.com/xtaci/kcp-go/v5"
|
"github.com/xtaci/kcp-go/v5"
|
||||||
"io"
|
"io"
|
||||||
"math"
|
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
@ -84,26 +83,6 @@ func newWebsocketConn(server *Server, ws *websocket.Conn, ip string) *Conn {
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewOfflineConn 创建一个离线连接
|
|
||||||
func NewOfflineConn(server *Server) *Conn {
|
|
||||||
addr := &net.TCPAddr{
|
|
||||||
IP: net.ParseIP(random.IPv4()),
|
|
||||||
Port: random.Int(65536, math.MaxInt),
|
|
||||||
}
|
|
||||||
c := &Conn{
|
|
||||||
ctx: server.ctx,
|
|
||||||
connection: &connection{
|
|
||||||
server: server,
|
|
||||||
remoteAddr: addr,
|
|
||||||
ip: addr.String(),
|
|
||||||
data: map[any]any{},
|
|
||||||
openTime: time.Now(),
|
|
||||||
offline: true,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
return c
|
|
||||||
}
|
|
||||||
|
|
||||||
// newBotConn 创建一个适用于测试等情况的机器人连接
|
// newBotConn 创建一个适用于测试等情况的机器人连接
|
||||||
func newBotConn(server *Server) *Conn {
|
func newBotConn(server *Server) *Conn {
|
||||||
ip, port := random.NetIP(), random.Port()
|
ip, port := random.NetIP(), random.Port()
|
||||||
|
@ -153,7 +132,6 @@ type connection struct {
|
||||||
delay time.Duration
|
delay time.Duration
|
||||||
fluctuation time.Duration
|
fluctuation time.Duration
|
||||||
botWriter atomic.Pointer[io.Writer]
|
botWriter atomic.Pointer[io.Writer]
|
||||||
offline bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ticker 获取定时器
|
// Ticker 获取定时器
|
||||||
|
@ -279,9 +257,6 @@ func (slf *Conn) PushUniqueAsyncMessage(name string, caller func() error, callba
|
||||||
|
|
||||||
// Write 向连接中写入数据
|
// Write 向连接中写入数据
|
||||||
func (slf *Conn) Write(packet []byte, callback ...func(err error)) {
|
func (slf *Conn) Write(packet []byte, callback ...func(err error)) {
|
||||||
if slf.offline {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if slf.gw != nil {
|
if slf.gw != nil {
|
||||||
slf.gw(packet)
|
slf.gw(packet)
|
||||||
return
|
return
|
||||||
|
@ -358,10 +333,6 @@ func (slf *Conn) init() {
|
||||||
|
|
||||||
// Close 关闭连接
|
// Close 关闭连接
|
||||||
func (slf *Conn) Close(err ...error) {
|
func (slf *Conn) Close(err ...error) {
|
||||||
if slf.offline {
|
|
||||||
slf.server.dispatcherMgr.UnBindProducer(slf.GetID())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
slf.mu.Lock()
|
slf.mu.Lock()
|
||||||
if slf.closed {
|
if slf.closed {
|
||||||
if slf.ticker != nil {
|
if slf.ticker != nil {
|
||||||
|
|
|
@ -46,9 +46,6 @@ func (slf *Pool) GetTicker(size int, options ...Option) *Ticker {
|
||||||
if len(slf.tickers) > 0 {
|
if len(slf.tickers) > 0 {
|
||||||
ticker = slf.tickers[0]
|
ticker = slf.tickers[0]
|
||||||
slf.tickers = slf.tickers[1:]
|
slf.tickers = slf.tickers[1:]
|
||||||
for _, option := range options {
|
|
||||||
option(ticker)
|
|
||||||
}
|
|
||||||
return ticker
|
return ticker
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue