test: Go/JS SDK 接入清单集成测与 README 示例

This commit is contained in:
Nixevol
2026-09-30 08:35:09 +08:00
parent 77d2dbddb1
commit 2f750bcb0f
12 changed files with 1881 additions and 6 deletions
+14
View File
@@ -44,6 +44,8 @@ func (c *Client) Connect(ctx context.Context, rawURL, endpointID string, credent
c.setStateLocked(StateConnecting, "")
c.mu.Unlock()
go c.downLoop(inner)
tr.SetCredential(pass)
cfg := transportConfig{
URL: rawURL,
@@ -98,11 +100,17 @@ func (c *Client) failAuth(reason AuthReason) {
c.handshook = false
c.setStateLocked(StateAuthFailed, string(reason))
c.failQueuedLocked(apiErr(string(reason), "认证失败,停止重连"))
tr := c.transport
cancel := c.cancel
c.mu.Unlock()
if cancel != nil {
cancel()
}
if tr != nil {
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
defer cancel()
_ = tr.Stop(ctx)
}
}
func (c *Client) failKicked() {
@@ -111,11 +119,17 @@ func (c *Client) failKicked() {
c.handshook = false
c.setStateLocked(StateKicked, "0x8E")
c.failQueuedLocked(apiErr(CodeKicked, "被顶号,停止重连"))
tr := c.transport
cancel := c.cancel
c.mu.Unlock()
if cancel != nil {
cancel()
}
if tr != nil {
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
defer cancel()
_ = tr.Stop(ctx)
}
}
func (c *Client) setStateLocked(st ConnectionState, reason string) {