Merge branches 'develop' and 'develop' of gitee.com:fusenpack/fusenapi into develop
This commit is contained in:
commit
342d1f99ec
@ -81,12 +81,12 @@ var (
|
|||||||
|
|
||||||
// 用户标识的连接增删操作队列传输的值的结构
|
// 用户标识的连接增删操作队列传输的值的结构
|
||||||
type userConnPoolCtlChanItem struct {
|
type userConnPoolCtlChanItem struct {
|
||||||
userId int64 //必须(两个用户id任意一个不为0)
|
userId int64 //必须(两个用户id任意一个不为0)
|
||||||
guestId int64 //必须(两个用户id任意一个不为0)
|
guestId int64 //必须(两个用户id任意一个不为0)
|
||||||
uniqueId string //主连接池唯一标识(添加/删除时候必须)
|
uniqueId string //主连接池唯一标识(添加/删除时候必须)
|
||||||
message []byte //消息(发送消息传的,格式是经过标准输出序列化后的数据)
|
message []byte //消息(发送消息传的,格式是经过标准输出序列化后的数据)
|
||||||
messageType constants.Websocket //消息类型(发送消息传的)
|
//messageType constants.Websocket //消息类型(发送消息传的)
|
||||||
option int64 //操作 2发消息 1增加 0删除
|
option int64 //操作 2发消息 1增加 0删除
|
||||||
}
|
}
|
||||||
|
|
||||||
// 每个连接的连接基本属性
|
// 每个连接的连接基本属性
|
||||||
|
@ -40,7 +40,7 @@ func ConsumeWebsocketConnectCountCtlChanData(ctx context.Context) {
|
|||||||
select {
|
select {
|
||||||
case num = <-websocketConnectCountCtlChan:
|
case num = <-websocketConnectCountCtlChan:
|
||||||
currentWebsocketConnectCount += num
|
currentWebsocketConnectCount += num
|
||||||
logx.Info("当前websocket连接总数:", currentWebsocketConnectCount)
|
//logx.Info("当前websocket连接总数:", currentWebsocketConnectCount)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -86,10 +86,12 @@ func (w *wsConnectItem) consumeRenderImageData() {
|
|||||||
case data := <-w.extendRenderProperty.renderChan: //消费数据
|
case data := <-w.extendRenderProperty.renderChan: //消费数据
|
||||||
//标签不一样
|
//标签不一样
|
||||||
if data.RenderData.TemplateTag != w.extendRenderProperty.templateTag {
|
if data.RenderData.TemplateTag != w.extendRenderProperty.templateTag {
|
||||||
|
//logx.Info("标签不一致,丢弃消息")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
//颜色不一致
|
//颜色不一致
|
||||||
if data.RenderData.TemplateTagColor.SelectedColorIndex != w.extendRenderProperty.selectColorIndex {
|
if data.RenderData.TemplateTagColor.SelectedColorIndex != w.extendRenderProperty.selectColorIndex {
|
||||||
|
//logx.Info("颜色不一致,丢弃消息")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
limitChan <- struct{}{}
|
limitChan <- struct{}{}
|
||||||
|
@ -70,7 +70,7 @@ func (r *reuseConnProcessor) allocationMessage(w *wsConnectItem, data []byte) {
|
|||||||
createUserConnPoolElement(w.userId, w.guestId, wid)
|
createUserConnPoolElement(w.userId, w.guestId, wid)
|
||||||
rsp := w.respondDataFormat(constants.WEBSOCKET_CONNECT_SUCCESS, wid)
|
rsp := w.respondDataFormat(constants.WEBSOCKET_CONNECT_SUCCESS, wid)
|
||||||
w.sendToOutChan(rsp)
|
w.sendToOutChan(rsp)
|
||||||
logx.Info("重新绑定websocket连接标识成功")
|
//logx.Info("重新绑定websocket连接标识成功")
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取用户拼接部分(复用标识用到)
|
// 获取用户拼接部分(复用标识用到)
|
||||||
|
@ -19,12 +19,11 @@ func createUserConnPoolElement(userId, guestId int64, uniqueId string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
data := userConnPoolCtlChanItem{
|
data := userConnPoolCtlChanItem{
|
||||||
userId: userId,
|
userId: userId,
|
||||||
guestId: guestId,
|
guestId: guestId,
|
||||||
uniqueId: uniqueId,
|
uniqueId: uniqueId,
|
||||||
message: nil,
|
message: nil,
|
||||||
messageType: "",
|
option: 1,
|
||||||
option: 1,
|
|
||||||
}
|
}
|
||||||
select {
|
select {
|
||||||
case userConnPoolCtlChan <- data:
|
case userConnPoolCtlChan <- data:
|
||||||
@ -38,17 +37,13 @@ func deleteUserConnPoolElement(userId, guestId int64, uniqueId string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
data := userConnPoolCtlChanItem{
|
data := userConnPoolCtlChanItem{
|
||||||
userId: userId,
|
userId: userId,
|
||||||
guestId: guestId,
|
guestId: guestId,
|
||||||
uniqueId: uniqueId,
|
uniqueId: uniqueId,
|
||||||
message: nil,
|
message: nil,
|
||||||
messageType: "",
|
option: 0,
|
||||||
option: 0,
|
|
||||||
}
|
|
||||||
select {
|
|
||||||
case userConnPoolCtlChan <- data:
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
userConnPoolCtlChan <- data
|
||||||
}
|
}
|
||||||
|
|
||||||
// 根据用户索引发现链接并发送(广播)消息到出口队列
|
// 根据用户索引发现链接并发送(广播)消息到出口队列
|
||||||
@ -89,7 +84,7 @@ func ConsumeUserConnPoolCtlChanData(ctx context.Context) {
|
|||||||
userKey = getmapUserConnPoolUniqueId(data.userId, data.guestId)
|
userKey = getmapUserConnPoolUniqueId(data.userId, data.guestId)
|
||||||
switch data.option {
|
switch data.option {
|
||||||
case 2: //发送消息
|
case 2: //发送消息
|
||||||
logx.Info("通过用户id索引发送消息")
|
//logx.Info("通过用户id索引发送消息")
|
||||||
mapUserUniqueId, ok := mapUserConnPool[userKey]
|
mapUserUniqueId, ok := mapUserConnPool[userKey]
|
||||||
if !ok {
|
if !ok {
|
||||||
logx.Info("通过用户id索引发送消息,连接不存在,用户索引key:", userKey)
|
logx.Info("通过用户id索引发送消息,连接不存在,用户索引key:", userKey)
|
||||||
@ -110,7 +105,7 @@ func ConsumeUserConnPoolCtlChanData(ctx context.Context) {
|
|||||||
originConn.sendToOutChan(data.message)
|
originConn.sendToOutChan(data.message)
|
||||||
}
|
}
|
||||||
case 1: //添加
|
case 1: //添加
|
||||||
logx.Info("添加用户id索引标识:", data.uniqueId)
|
//logx.Info("添加用户id索引标识:", data.uniqueId)
|
||||||
//存在这个用户的map池子
|
//存在这个用户的map池子
|
||||||
if mapUserUniqueId, ok := mapUserConnPool[userKey]; ok {
|
if mapUserUniqueId, ok := mapUserConnPool[userKey]; ok {
|
||||||
mapUserUniqueId[data.uniqueId] = struct{}{}
|
mapUserUniqueId[data.uniqueId] = struct{}{}
|
||||||
@ -119,7 +114,7 @@ func ConsumeUserConnPoolCtlChanData(ctx context.Context) {
|
|||||||
mapUserConnPool[userKey][data.uniqueId] = struct{}{}
|
mapUserConnPool[userKey][data.uniqueId] = struct{}{}
|
||||||
}
|
}
|
||||||
case 0: //删除
|
case 0: //删除
|
||||||
logx.Info("删除用户id索引标识:", data.uniqueId)
|
//logx.Info("删除用户id索引标识:", data.uniqueId)
|
||||||
if mapUserUniqueId, ok := mapUserConnPool[userKey]; ok {
|
if mapUserUniqueId, ok := mapUserConnPool[userKey]; ok {
|
||||||
delete(mapUserUniqueId, data.uniqueId)
|
delete(mapUserUniqueId, data.uniqueId)
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package curl
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -87,8 +86,8 @@ type (
|
|||||||
|
|
||||||
// PostJson请求
|
// PostJson请求
|
||||||
func (c *defaultClient) PostJson(jsonData interface{}, res interface{}) error {
|
func (c *defaultClient) PostJson(jsonData interface{}, res interface{}) error {
|
||||||
jsonDataB, _ := json.Marshal(jsonData)
|
//jsonDataB, _ := json.Marshal(jsonData)
|
||||||
logc.Infof(c.ctx, "客户端名称 Client PostJson jsonData:%+v", string(jsonDataB))
|
//logc.Infof(c.ctx, "客户端名称 Client PostJson jsonData:%+v", string(jsonDataB))
|
||||||
|
|
||||||
logc.Infof(c.ctx, "客户端名称 请求开始时间:%+v", time.Now().UTC())
|
logc.Infof(c.ctx, "客户端名称 请求开始时间:%+v", time.Now().UTC())
|
||||||
resp, err := c.client.
|
resp, err := c.client.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user