Merge remote-tracking branch 'refs/remotes/origin/main'

This commit is contained in:
王性驊 2025-08-08 18:52:01 +08:00
commit 0e6799bd52
4 changed files with 54 additions and 1 deletions

View File

@ -3,7 +3,7 @@ ListenOn: 0.0.0.0:8888
Timeout: 10000
Etcd:
Hosts:
- 10.0.0.19:2379
- localhost:2379
Key: blockchain.rpc
Binance:
Key: ""

View File

@ -0,0 +1,27 @@
package websocket
import (
"crypto/tls"
"github.com/lxzan/gws"
"net/http"
"time"
)
type ClientOption struct {
WriteBufferSize int
PermessageDeflate gws.PermessageDeflate
ParallelEnabled bool
ParallelGoLimit int
ReadMaxPayloadSize int
ReadBufferSize int
WriteMaxPayloadSize int
CheckUtf8Enabled bool
Logger gws.Logger
Recovery func(logger gws.Logger)
Addr string
RequestHeader http.Header
HandshakeTimeout time.Duration
TlsConfig *tls.Config
NewDialer func() (gws.Dialer, error)
NewSession func() gws.SessionStorage
}

View File

@ -0,0 +1,25 @@
package websocket
import (
"github.com/lxzan/gws"
"net/url"
)
type Connection struct {
*gws.Conn
}
func NewWebSocketConnect(url url.URL, handler gws.Event) (*Connection, error) {
socket, _, err := gws.NewClient(handler, &gws.ClientOption{
Addr: url.String(),
})
if err != nil {
return nil, err
}
// 取得消息
go socket.ReadLoop()
return &Connection{
socket,
}, nil
}

View File

@ -0,0 +1 @@
package websocket