Commit 346879e5 by zhangjiec

统计socket连接数量的变量改为原子操作

parent ab1316b4
......@@ -4,9 +4,8 @@ ServerMode = release
ServerPort = :50000
[http_client]
#BaseUrl = http://handandev.swaylink.cn/phone/2/server/
#BaseUrl = http://dev.lezhixy.com/phone/2/server/
BaseUrl = http://127.0.0.1:1234/phone/2/server/
BaseUrl = http://handandev.swaylink.cn/phone/2/server/
#BaseUrl = http://dev.lezhixy.com:5000/phone/2/server/
TimeOut = 5
[tcp_long_server]
......@@ -44,5 +43,5 @@ WarnWithMaxAge = 90
#Error级别日志最多保存多少份
ErrorMaxFileNum = 10
#Error日志最长保留天数
#Error日志最长保留天数s
ErrorWithMaxAge = 180
......@@ -289,11 +289,11 @@ func (dev *DCPhone10) setDevPara(c *gin.Context) {
sTcpData.Data[0] = data.Value
sTcpData.Length = 1
sDevId = data.DevID
case "key_password", "online_dial", "update_firmware", "restart_device": //
case "key_password", "update_firmware", "restart_device": //
var data paraOneString
if err := c.ShouldBindJSON(&data); err != nil {
logger.Log.Error("c.ShouldBindJSON(&data)",
zap.String("Src", "case \"key_password\",\"online_dial\",\"update_firmware\",\"restart_device\""),
zap.String("Src", "case \"key_password\",\"update_firmware\",\"restart_device\""),
zap.Error(err))
sTcpData.CtrlCode = 0
returnState = 2002
......@@ -303,6 +303,23 @@ func (dev *DCPhone10) setDevPara(c *gin.Context) {
sTcpData.Data = []byte(data.Value)
sTcpData.Length = byte(len(data.Value))
sDevId = data.DevID
case "online_dial":
var data structOnlineDial
if err := c.ShouldBindJSON(&data); err != nil {
logger.Log.Error("c.ShouldBindJSON(&data)",
zap.String("Src", "case \"online_dial\""),
zap.Error(err))
sTcpData.CtrlCode = 0
returnState = 2002
returnMsg = "参数内容错误"
break
}
sTcpData.Data[0] = data.Value.Time
sTcpData.Length = uint8(copy(sTcpData.Data[1:], data.Value.Number) + 1)
//sTcpData.Data = []byte(data.Value.Number)
//sTcpData.Length = byte(len(data.Value))
sDevId = data.DevID
break
case "work_time": // 工作时段
var data paraWorkTime
if err := c.ShouldBindJSON(&data); err != nil {
......
......@@ -143,3 +143,13 @@ type paraWorkTime struct {
WeekDay []bool `json:"week_day"`
} `json:"value"`
}
type structOnlineDial struct {
DevTime uint32 `json:"dev_send_time"`
DevID []uint32 `json:"devId"`
Value struct {
Result uint8 `json:"result"`
Time uint8 `json:"time"`
Number string `json:"number"`
} `json:"value"`
}
......@@ -20,6 +20,7 @@ require (
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.7.0 // indirect
go.uber.org/zap v1.18.1 // indirect
golang.org/dl v0.0.0-20210816190658-eea66df5a73d // indirect
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97 // indirect
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c // indirect
golang.org/x/text v0.3.6 // indirect
......
......@@ -77,6 +77,8 @@ go.uber.org/multierr v1.7.0 h1:zaiO/rmgFjbmCXdSYJWQcdvOCsthmdaHfr3Gm2Kx4Ec=
go.uber.org/multierr v1.7.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak=
go.uber.org/zap v1.18.1 h1:CSUJ2mjFszzEWt4CdKISEuChVIXGBn3lAPwkRGyVrc4=
go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI=
golang.org/dl v0.0.0-20210816190658-eea66df5a73d h1:fY+sw1TVAhVSrszhxX7Ew04Y6V9Znfa8s5O1HTzTsOQ=
golang.org/dl v0.0.0-20210816190658-eea66df5a73d/go.mod h1:IUMfjQLJQd4UTqG1Z90tenwKoCX93Gn3MAQJMOSBsDQ=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97 h1:/UOmuWzQfxxo9UtlXMwuQU8CMgg1eZXqTRwkSQJWKOI=
......
......@@ -24,8 +24,11 @@ func TestHex2Cipher(t *testing.T) {
// }
// fmt.Println()
//}
a := []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
str := string(a)
fmt.Println(str)
fmt.Println(len(str))
var b [3]byte
for i := 10002; i <= 11001; i++ {
b[0] = byte(i)
b[1] = byte(i >> 8)
b[2] = byte(i >> 16)
fmt.Printf("3D%02X%02X%02X,", b[0], b[1], b[2])
}
}
package tcplongserver
import (
"fmt"
"go.uber.org/zap"
"jeff_workstation_1/jeffutil"
"jeff_workstation_1/logger"
......@@ -137,7 +136,7 @@ func (s *TCPLongServer) connectionHandle(conn *net.TCPConn, callBack receiveCall
}
_ = conn.SetReadDeadline(time.Time{}) // 设置回去,但是不知道需不需要这句话
_ = conn.Close()
fmt.Println("-----------------------------------Out ConnSocketCount:", s.ConnSocketCount)
// fmt.Println("-----------------------------------Out ConnSocketCount:", s.ConnSocketCount)
}()
//myDevId := -1
//waitTimeOut := 0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment