Merge branches 'develop' and 'develop' of gitee.com:fusenpack/fusenapi into develop

This commit is contained in:
momo 2023-10-07 16:12:35 +08:00
commit 342d1f99ec
6 changed files with 26 additions and 30 deletions

View File

@ -81,12 +81,12 @@ var (
// 用户标识的连接增删操作队列传输的值的结构
type userConnPoolCtlChanItem struct {
userId int64 //必须两个用户id任意一个不为0
guestId int64 //必须两个用户id任意一个不为0
uniqueId string //主连接池唯一标识(添加/删除时候必须)
message []byte //消息(发送消息传的,格式是经过标准输出序列化后的数据)
messageType constants.Websocket //消息类型(发送消息传的)
option int64 //操作 2发消息 1增加 0删除
userId int64 //必须两个用户id任意一个不为0
guestId int64 //必须两个用户id任意一个不为0
uniqueId string //主连接池唯一标识(添加/删除时候必须)
message []byte //消息(发送消息传的,格式是经过标准输出序列化后的数据)
//messageType constants.Websocket //消息类型(发送消息传的)
option int64 //操作 2发消息 1增加 0删除
}
// 每个连接的连接基本属性

View File

@ -40,7 +40,7 @@ func ConsumeWebsocketConnectCountCtlChanData(ctx context.Context) {
select {
case num = <-websocketConnectCountCtlChan:
currentWebsocketConnectCount += num
logx.Info("当前websocket连接总数:", currentWebsocketConnectCount)
//logx.Info("当前websocket连接总数:", currentWebsocketConnectCount)
}
}
}

View File

@ -86,10 +86,12 @@ func (w *wsConnectItem) consumeRenderImageData() {
case data := <-w.extendRenderProperty.renderChan: //消费数据
//标签不一样
if data.RenderData.TemplateTag != w.extendRenderProperty.templateTag {
//logx.Info("标签不一致,丢弃消息")
continue
}
//颜色不一致
if data.RenderData.TemplateTagColor.SelectedColorIndex != w.extendRenderProperty.selectColorIndex {
//logx.Info("颜色不一致,丢弃消息")
continue
}
limitChan <- struct{}{}

View File

@ -70,7 +70,7 @@ func (r *reuseConnProcessor) allocationMessage(w *wsConnectItem, data []byte) {
createUserConnPoolElement(w.userId, w.guestId, wid)
rsp := w.respondDataFormat(constants.WEBSOCKET_CONNECT_SUCCESS, wid)
w.sendToOutChan(rsp)
logx.Info("重新绑定websocket连接标识成功")
//logx.Info("重新绑定websocket连接标识成功")
}
// 获取用户拼接部分(复用标识用到)

View File

@ -19,12 +19,11 @@ func createUserConnPoolElement(userId, guestId int64, uniqueId string) {
return
}
data := userConnPoolCtlChanItem{
userId: userId,
guestId: guestId,
uniqueId: uniqueId,
message: nil,
messageType: "",
option: 1,
userId: userId,
guestId: guestId,
uniqueId: uniqueId,
message: nil,
option: 1,
}
select {
case userConnPoolCtlChan <- data:
@ -38,17 +37,13 @@ func deleteUserConnPoolElement(userId, guestId int64, uniqueId string) {
return
}
data := userConnPoolCtlChanItem{
userId: userId,
guestId: guestId,
uniqueId: uniqueId,
message: nil,
messageType: "",
option: 0,
}
select {
case userConnPoolCtlChan <- data:
return
userId: userId,
guestId: guestId,
uniqueId: uniqueId,
message: nil,
option: 0,
}
userConnPoolCtlChan <- data
}
// 根据用户索引发现链接并发送(广播)消息到出口队列
@ -89,7 +84,7 @@ func ConsumeUserConnPoolCtlChanData(ctx context.Context) {
userKey = getmapUserConnPoolUniqueId(data.userId, data.guestId)
switch data.option {
case 2: //发送消息
logx.Info("通过用户id索引发送消息")
//logx.Info("通过用户id索引发送消息")
mapUserUniqueId, ok := mapUserConnPool[userKey]
if !ok {
logx.Info("通过用户id索引发送消息,连接不存在用户索引key:", userKey)
@ -110,7 +105,7 @@ func ConsumeUserConnPoolCtlChanData(ctx context.Context) {
originConn.sendToOutChan(data.message)
}
case 1: //添加
logx.Info("添加用户id索引标识", data.uniqueId)
//logx.Info("添加用户id索引标识", data.uniqueId)
//存在这个用户的map池子
if mapUserUniqueId, ok := mapUserConnPool[userKey]; ok {
mapUserUniqueId[data.uniqueId] = struct{}{}
@ -119,7 +114,7 @@ func ConsumeUserConnPoolCtlChanData(ctx context.Context) {
mapUserConnPool[userKey][data.uniqueId] = struct{}{}
}
case 0: //删除
logx.Info("删除用户id索引标识", data.uniqueId)
//logx.Info("删除用户id索引标识", data.uniqueId)
if mapUserUniqueId, ok := mapUserConnPool[userKey]; ok {
delete(mapUserUniqueId, data.uniqueId)
}

View File

@ -3,7 +3,6 @@ package curl
import (
"bytes"
"context"
"encoding/json"
"fmt"
"time"
@ -87,8 +86,8 @@ type (
// PostJson请求
func (c *defaultClient) PostJson(jsonData interface{}, res interface{}) error {
jsonDataB, _ := json.Marshal(jsonData)
logc.Infof(c.ctx, "客户端名称 Client PostJson jsonData:%+v", string(jsonDataB))
//jsonDataB, _ := json.Marshal(jsonData)
//logc.Infof(c.ctx, "客户端名称 Client PostJson jsonData:%+v", string(jsonDataB))
logc.Infof(c.ctx, "客户端名称 请求开始时间:%+v", time.Now().UTC())
resp, err := c.client.