From 1f6c7620d1be33b084c057d7b38021db7735b4a5 Mon Sep 17 00:00:00 2001 From: Tooooommy Date: Wed, 21 Oct 2020 16:01:09 +0800 Subject: [PATCH] fix:bug --- go.mod | 4 ++-- go.sum | 4 ++++ hdws/ws/node.go | 15 ++++++++++----- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/go.mod b/go.mod index cc6c380..874eb99 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/CloudyKit/jet v2.1.2+incompatible // indirect github.com/agrison/go-tablib v0.0.0-20160310143025-4930582c22ee // indirect github.com/agrison/mxj v0.0.0-20160310142625-1269f8afb3b4 // indirect - github.com/aws/aws-sdk-go v1.35.10 // indirect + github.com/aws/aws-sdk-go v1.35.11 // indirect github.com/bndr/gotabulate v1.1.2 // indirect github.com/chanxuehong/wechat v0.0.0-20200409104612-0a1fd76d7a3a github.com/clbanning/mxj v1.8.4 // indirect @@ -46,7 +46,7 @@ require ( go.uber.org/atomic v1.7.0 go.uber.org/multierr v1.6.0 // indirect go.uber.org/zap v1.16.0 - golang.org/x/sys v0.0.0-20201018230417-eeed37f84f13 // indirect + golang.org/x/sys v0.0.0-20201020230747-6e5568b54d1a // indirect gopkg.in/flosch/pongo2.v3 v3.0.0-20141028000813-5e81b817a0c4 // indirect gopkg.in/natefinch/lumberjack.v2 v2.0.0 gopkg.in/olahol/melody.v1 v1.0.0-20170518105555-d52139073376 diff --git a/go.sum b/go.sum index 9d87da0..509574f 100644 --- a/go.sum +++ b/go.sum @@ -19,6 +19,8 @@ github.com/agrison/mxj v0.0.0-20160310142625-1269f8afb3b4/go.mod h1:n7qJAqL9BKqG github.com/andybalholm/cascadia v1.1.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y= github.com/aws/aws-sdk-go v1.35.10 h1:FsJtrOS7P+Qmq1rPTGgS/+qC1Y9eGuAJHvAZpZlhmb4= github.com/aws/aws-sdk-go v1.35.10/go.mod h1:tlPOdRjfxPBpNIwqDj61rmsnA85v9jc0Ps9+muhnW+k= +github.com/aws/aws-sdk-go v1.35.11 h1:LICFl2K+3Y5dMTW6PCV6ycK8fzIxs21HvDhI5A3Ee3Y= +github.com/aws/aws-sdk-go v1.35.11/go.mod h1:tlPOdRjfxPBpNIwqDj61rmsnA85v9jc0Ps9+muhnW+k= github.com/bndr/gotabulate v1.1.2 h1:yC9izuZEphojb9r+KYL4W9IJKO/ceIO8HDwxMA24U4c= github.com/bndr/gotabulate v1.1.2/go.mod h1:0+8yUgaPTtLRTjf49E8oju7ojpU11YmXyvq1LbPAb3U= github.com/chanxuehong/rand v0.0.0-20180830053958-4b3aff17f488/go.mod h1:h13adSJmQ5tsaV9bR72eTp7ePXJ2WIWyK6heLeietxA= @@ -184,6 +186,8 @@ golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd h1:xhmwyvizuTgC2qz7ZlMluP20u golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201018230417-eeed37f84f13 h1:5jaG59Zhd+8ZXe8C+lgiAGqkOaZBruqrWclLkgAww34= golang.org/x/sys v0.0.0-20201018230417-eeed37f84f13/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201020230747-6e5568b54d1a h1:e3IU37lwO4aq3uoRKINC7JikojFmE5gO7xhfxs8VC34= +golang.org/x/sys v0.0.0-20201020230747-6e5568b54d1a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= diff --git a/hdws/ws/node.go b/hdws/ws/node.go index 00affda..2fac40b 100644 --- a/hdws/ws/node.go +++ b/hdws/ws/node.go @@ -3,9 +3,10 @@ package ws import ( "errors" "fmt" + "sync" + "github.com/rs/zerolog/log" "gopkg.in/olahol/melody.v1" - "sync" ) // 根据主活动划分房间 ==> 适配现有的可以 @@ -160,8 +161,10 @@ func (t *Node) BroadcastTag(msg *Message) { m := msg.Encode() if room, ok := t.rooms[msg.RoomId]; ok { for _, client := range room.clients { - if client.AccountType == msg.Tag && client.Id != msg.From { - _ = client.Write(m) + if client != nil { + if client.AccountType == msg.Tag && client.Id != msg.From { + _ = client.Write(m) + } } } } @@ -171,8 +174,10 @@ func (t *Node) BroadcastDest(msg *Message) { m := msg.Encode() if room, ok := t.rooms[msg.RoomId]; ok { client := room.clients[fmt.Sprintf("%s:%d", msg.Tag, msg.Dest)] - if client.Id != msg.From { - _ = client.Write(m) + if client != nil { + if client.Id != msg.From { + _ = client.Write(m) + } } } }