优化聊天消息广播异常问题
This commit is contained in:
parent
dc30119e55
commit
5eb2783750
@ -228,6 +228,7 @@ func (this *Client) ClusterBroadcast(ctx context.Context, servicePath string, se
|
|||||||
}
|
}
|
||||||
this.clusterMu.RUnlock()
|
this.clusterMu.RUnlock()
|
||||||
l := len(clients)
|
l := len(clients)
|
||||||
|
if l > 0 {
|
||||||
done := make(chan error, l)
|
done := make(chan error, l)
|
||||||
for _, v := range clients {
|
for _, v := range clients {
|
||||||
go func(c client.XClient) {
|
go func(c client.XClient) {
|
||||||
@ -249,6 +250,9 @@ check:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
timeout.Stop()
|
timeout.Stop()
|
||||||
|
} else {
|
||||||
|
err = errors.New("on found any service")
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,8 +127,7 @@ func (this *RPCX) AcrossClusterGo(ctx context.Context, clusterTag string, servic
|
|||||||
|
|
||||||
//全集群广播
|
//全集群广播
|
||||||
func (this *RPCX) ClusterBroadcast(ctx context.Context, servicePath string, serviceMethod string, args interface{}, reply interface{}) (err error) {
|
func (this *RPCX) ClusterBroadcast(ctx context.Context, servicePath string, serviceMethod string, args interface{}, reply interface{}) (err error) {
|
||||||
|
err = this.service.ClusterBroadcast(ctx, servicePath, serviceMethod, args, reply)
|
||||||
err = this.client.ClusterBroadcast(ctx, servicePath, serviceMethod, args, reply)
|
|
||||||
if err != nil && strings.Contains(err.Error(), "on found") {
|
if err != nil && strings.Contains(err.Error(), "on found") {
|
||||||
return this.client.ClusterBroadcast(ctx, servicePath, serviceMethod, args, reply)
|
return this.client.ClusterBroadcast(ctx, servicePath, serviceMethod, args, reply)
|
||||||
}
|
}
|
||||||
|
@ -496,6 +496,7 @@ func (this *Service) clusterbroadcast(ctx context.Context, servicePath string, s
|
|||||||
}
|
}
|
||||||
|
|
||||||
l := len(addrs)
|
l := len(addrs)
|
||||||
|
if l > 0 {
|
||||||
done := make(chan error, l)
|
done := make(chan error, l)
|
||||||
for v, _ := range addrs {
|
for v, _ := range addrs {
|
||||||
go func(addr string) {
|
go func(addr string) {
|
||||||
@ -555,7 +556,11 @@ check:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
timeout.Stop()
|
timeout.Stop()
|
||||||
return err
|
} else {
|
||||||
|
err = errors.New("on found any service")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//发送远程调用请求
|
//发送远程调用请求
|
||||||
|
@ -82,7 +82,7 @@ func (this *Chat) OnInstallComp() {
|
|||||||
//Event------------------------------------------------------------------------------------------------------------
|
//Event------------------------------------------------------------------------------------------------------------
|
||||||
func (this *Chat) EventUserOffline(session comm.IUserSession) {
|
func (this *Chat) EventUserOffline(session comm.IUserSession) {
|
||||||
if err := this.modelChat.removeCrossChannelMember(session); err != nil {
|
if err := this.modelChat.removeCrossChannelMember(session); err != nil {
|
||||||
this.Debug("EventUserOffline:", log.Field{"uid", session.GetUserId()}, log.Field{"err", err})
|
this.Debug("EventUserOffline:", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "err", Value: err.Error()})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,7 +151,7 @@ func (this *Chat) SendWorldChat(msg *pb.DBChat) (code pb.ErrorCode) {
|
|||||||
} else {
|
} else {
|
||||||
if _, err = this.service.AcrossClusterRpcGo(
|
if _, err = this.service.AcrossClusterRpcGo(
|
||||||
context.Background(),
|
context.Background(),
|
||||||
msg.Stag,
|
this.GetCrossTag(),
|
||||||
comm.Service_Worker,
|
comm.Service_Worker,
|
||||||
string(comm.Rpc_ModuleChatPushChat),
|
string(comm.Rpc_ModuleChatPushChat),
|
||||||
msg,
|
msg,
|
||||||
@ -182,7 +182,7 @@ func (this *Chat) SendUnionChat(msg *pb.DBChat) (code pb.ErrorCode) {
|
|||||||
} else {
|
} else {
|
||||||
if _, err = this.service.AcrossClusterRpcGo(
|
if _, err = this.service.AcrossClusterRpcGo(
|
||||||
context.Background(),
|
context.Background(),
|
||||||
msg.Stag,
|
this.GetCrossTag(),
|
||||||
comm.Service_Worker,
|
comm.Service_Worker,
|
||||||
string(comm.Rpc_ModuleChatPushChat),
|
string(comm.Rpc_ModuleChatPushChat),
|
||||||
msg,
|
msg,
|
||||||
@ -257,7 +257,7 @@ func (this *Chat) SendSysChatToWorld(ctype comm.ChatSystemType, appenddata inter
|
|||||||
} else {
|
} else {
|
||||||
if _, err = this.service.AcrossClusterRpcGo(
|
if _, err = this.service.AcrossClusterRpcGo(
|
||||||
context.Background(),
|
context.Background(),
|
||||||
msg.Stag,
|
this.GetCrossTag(),
|
||||||
comm.Service_Worker,
|
comm.Service_Worker,
|
||||||
string(comm.Rpc_ModuleChatPushChat),
|
string(comm.Rpc_ModuleChatPushChat),
|
||||||
msg,
|
msg,
|
||||||
|
Loading…
Reference in New Issue
Block a user