Skip to content

Commit 69ec65c

Browse files
authored
Merge pull request #79 from FGadvancer/main
fix: limit messages maxMsg length and update sdk-core version to v3.5.0
2 parents 25b272c + 8f91aaf commit 69ec65c

File tree

8 files changed

+60
-59
lines changed

8 files changed

+60
-59
lines changed

Diff for: cmd/main.go

+9-11
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ import (
1616
log "github.com/xuexihuang/new_log15"
1717
)
1818

19+
const (
20+
MaxMsgLen = 1024 * 1024 * 10
21+
MaxConnNum = 100 * 100 * 10
22+
HTTPTimeout = 10 * time.Second
23+
WriterChanLen = 1000
24+
)
25+
1926
var Processor = tjson.NewProcessor()
2027

2128
type GateNet struct {
@@ -27,17 +34,8 @@ type GateNet struct {
2734
// Initsever initializes a new GateNet instance with the given WebSocket port and default configurations.
2835
func Initsever(wsPort int) *GateNet {
2936
gatenet := new(GateNet)
30-
gatenet.Gate = &gate.Gate{
31-
MaxConnNum: 100,
32-
PendingWriteNum: 200,
33-
MaxMsgLen: 20000,
34-
WSAddr: ":" + fmt.Sprintf("%d", wsPort),
35-
HTTPTimeout: 10 * time.Second,
36-
CertFile: "",
37-
KeyFile: "",
38-
LenMsgLen: 2,
39-
Processor: Processor,
40-
}
37+
gatenet.Gate = gate.NewGate(MaxConnNum, MaxMsgLen,
38+
Processor, ":"+fmt.Sprintf("%d", wsPort), HTTPTimeout, WriterChanLen)
4139
gatenet.CloseSig = make(chan bool, 1)
4240
return gatenet
4341
}

Diff for: core_func/ws_conversation_msg.go

+10
Original file line numberDiff line numberDiff line change
@@ -305,3 +305,13 @@ func (f *FuncRouter) SearchLocalMessages(operationID string, args ...any) {
305305
func (f *FuncRouter) SetMessageLocalEx(operationID string, args ...any) {
306306
f.call(operationID, f.userForSDK.Conversation().SetMessageLocalEx, args...)
307307
}
308+
309+
// SearchConversation retrieves a conversation based on search criteria.
310+
func (f *FuncRouter) SearchConversation(operationID string, args ...any) {
311+
f.call(operationID, f.userForSDK.Conversation().SearchConversation, args...)
312+
}
313+
314+
// SetOneConversationEx sets server extension data for a conversation.
315+
func (f *FuncRouter) SetOneConversationEx(operationID string, args ...any) {
316+
f.call(operationID, f.userForSDK.Conversation().SetOneConversationEx, args...)
317+
}

Diff for: core_func/ws_friend.go

+10
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ func (f *FuncRouter) SetFriendRemark(operationID string, args ...any) {
3535
f.call(operationID, f.userForSDK.Friend().SetFriendRemark, args...)
3636
}
3737

38+
// PinFriends pins friends to the top of the friend list.
39+
func (f *FuncRouter) PinFriends(operationID string, args ...any) {
40+
f.call(operationID, f.userForSDK.Friend().PinFriends, args...)
41+
}
42+
3843
// DeleteFriend removes a user from the friend list.
3944
func (f *FuncRouter) DeleteFriend(operationID string, args ...any) {
4045
f.call(operationID, f.userForSDK.Friend().DeleteFriend, args...)
@@ -74,3 +79,8 @@ func (f *FuncRouter) GetBlackList(operationID string) {
7479
func (f *FuncRouter) RemoveBlack(operationID string, args ...any) {
7580
f.call(operationID, f.userForSDK.Friend().RemoveBlack, args...)
7681
}
82+
83+
// SetFriendsEx sets the friend ex info.
84+
func (f *FuncRouter) SetFriendsEx(operationID string, args ...any) {
85+
f.call(operationID, f.userForSDK.Friend().SetFriendsEx, args...)
86+
}

Diff for: core_func/ws_user.go

+5
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ func (f *FuncRouter) SetSelfInfo(operationID string, args ...any) {
2020
f.call(operationID, f.userForSDK.User().SetSelfInfo, args...)
2121
}
2222

23+
// SetSelfInfoEx updates the current user's information.
24+
func (f *FuncRouter) SetSelfInfoEx(operationID string, args ...any) {
25+
f.call(operationID, f.userForSDK.User().SetSelfInfoEx, args...)
26+
}
27+
2328
// SetGlobalRecvMessageOpt sets the global option for receiving messages for the user.
2429
func (f *FuncRouter) SetGlobalRecvMessageOpt(operationID string, args ...any) {
2530
f.call(operationID, f.userForSDK.User().SetGlobalRecvMessageOpt, args...)

Diff for: gate/gate.go

+6
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ type Gate struct {
3333
FuncMsgRecv func(interface{}, Agent)
3434
}
3535

36+
func NewGate(maxConnNum int, maxMsgLen uint32, processor network.Processor, WSAddr string,
37+
HTTPTimeout time.Duration, writerChanLen int) *Gate {
38+
return &Gate{MaxConnNum: maxConnNum, MaxMsgLen: maxMsgLen, Processor: processor, WSAddr: WSAddr,
39+
HTTPTimeout: HTTPTimeout, PendingWriteNum: writerChanLen}
40+
}
41+
3642
// SetFun sets the functions for handling new agents, closing agents, and receiving messages.
3743
func (gate *Gate) SetFun(Fun1 func(Agent), Fun2 func(Agent), Fun3 func(interface{}, Agent)) {
3844
gate.FunNewAgent = Fun1

Diff for: go.mod

+6-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ require (
66
github.com/OpenIMSDK/tools v0.0.16
77
github.com/bwmarrin/snowflake v0.3.0
88
github.com/gorilla/websocket v1.5.0
9-
github.com/openimsdk/openim-sdk-core/v3 v3.3.1-rc.7
9+
github.com/openimsdk/openim-sdk-core/v3 v3.5.0
1010
github.com/stretchr/testify v1.8.3
1111
github.com/xuexihuang/new_log15 v1.0.0
1212
)
@@ -19,16 +19,16 @@ require (
1919
github.com/mitchellh/mapstructure v1.5.0 // indirect
2020
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 // indirect
2121
github.com/tencentyun/qcloud-cos-sts-sdk v0.0.0-20220106031843-2efeb10ca2f6 // indirect
22-
golang.org/x/image v0.9.0 // indirect
23-
golang.org/x/net v0.11.0 // indirect
24-
golang.org/x/text v0.11.0 // indirect
22+
golang.org/x/image v0.14.0 // indirect
23+
golang.org/x/net v0.19.0 // indirect
24+
golang.org/x/text v0.14.0 // indirect
2525
google.golang.org/grpc v1.56.2 // indirect
2626
gorm.io/driver/sqlite v1.3.6 // indirect
2727
nhooyr.io/websocket v1.8.7 // indirect
2828
)
2929

3030
require (
31-
github.com/OpenIMSDK/protocol v0.0.23 // indirect
31+
github.com/OpenIMSDK/protocol v0.0.40 // indirect
3232
github.com/davecgh/go-spew v1.1.1 // indirect
3333
github.com/golang/protobuf v1.5.3 // indirect
3434
github.com/jinzhu/inflection v1.0.0 // indirect
@@ -46,7 +46,7 @@ require (
4646
go.uber.org/atomic v1.7.0 // indirect
4747
go.uber.org/multierr v1.6.0 // indirect
4848
go.uber.org/zap v1.24.0 // indirect
49-
golang.org/x/sys v0.13.0 // indirect
49+
golang.org/x/sys v0.15.0 // indirect
5050
google.golang.org/genproto/googleapis/rpc v0.0.0-20231030173426-d783a09b4405 // indirect
5151
google.golang.org/protobuf v1.31.0 // indirect
5252
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect

Diff for: go.sum

+13-42
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
github.com/OpenIMSDK/protocol v0.0.23 h1:L545aRQez6Ro+AaJB1Z6Mz7ojnDtp41WqASxYveCkcE=
2-
github.com/OpenIMSDK/protocol v0.0.23/go.mod h1:F25dFrwrIx3lkNoiuf6FkCfxuwf8L4Z8UIsdTHP/r0Y=
1+
github.com/OpenIMSDK/protocol v0.0.40 h1:1/Oij6RSAaePCPrWGwp9Cyz976/8Uxr94hM5M5FXzlg=
2+
github.com/OpenIMSDK/protocol v0.0.40/go.mod h1:F25dFrwrIx3lkNoiuf6FkCfxuwf8L4Z8UIsdTHP/r0Y=
33
github.com/OpenIMSDK/tools v0.0.16 h1:te/GIq2imCMsrRPgU9OObYKbzZ3rT08Lih/o+3QFIz0=
44
github.com/OpenIMSDK/tools v0.0.16/go.mod h1:eg+q4A34Qmu73xkY0mt37FHGMCMfC6CtmOnm0kFEGFI=
55
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
@@ -83,8 +83,8 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G
8383
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
8484
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 h1:zYyBkD/k9seD2A7fsi6Oo2LfFZAehjjQMERAvZLEDnQ=
8585
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8=
86-
github.com/openimsdk/openim-sdk-core/v3 v3.3.1-rc.7 h1:P1CG3011qeUKKMKUtFZtG1B64VbNV6shhW3hOqvjN84=
87-
github.com/openimsdk/openim-sdk-core/v3 v3.3.1-rc.7/go.mod h1:8cQJEanYxUxMdPuiPxHPrw1RkiDtIny5eGNyYfNFdWM=
86+
github.com/openimsdk/openim-sdk-core/v3 v3.5.0 h1:wsmQ0a50GyWtooUJzCW/g7I1eMkoxcHRuq0owO740aU=
87+
github.com/openimsdk/openim-sdk-core/v3 v3.5.0/go.mod h1:5zQe7SU7tlw2/A6ODSPlCG4mEMOnD2VottVRKzTSQ4I=
8888
github.com/pelletier/go-toml/v2 v2.0.8 h1:0ctb6s9mE31h0/lhu+J6OPmVeDxJn+kYnJc2jZR9tGQ=
8989
github.com/petermattis/goid v0.0.0-20230904192822-1876fd5063bc h1:8bQZVK1X6BJR/6nYUPxQEP+ReTsceJTKizeuwjWOPUA=
9090
github.com/petermattis/goid v0.0.0-20230904192822-1876fd5063bc/go.mod h1:pxMtw7cyUw6B2bRH0ZBANSPg+AoSud1I1iyJHI69jH4=
@@ -106,7 +106,6 @@ github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLY
106106
github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU=
107107
github.com/xuexihuang/new_log15 v1.0.0 h1:rIfjUeC4dgkjDYvbb6zv3q4Jk/aSvBo03UJ1mJCyJvg=
108108
github.com/xuexihuang/new_log15 v1.0.0/go.mod h1:psqerkM8mBbXXWN8DG3NUo33C3Hyr9RsaRjq8VfyA2c=
109-
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
110109
go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw=
111110
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
112111
go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI=
@@ -115,49 +114,21 @@ go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9i
115114
go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60=
116115
go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg=
117116
golang.org/x/arch v0.3.0 h1:02VY4/ZcO/gBOH6PUaoiptASxtXU10jazRCP865E97k=
118-
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
119-
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
120-
golang.org/x/crypto v0.10.0 h1:LKqV2xt9+kDzSTfOhx4FrkEBcMrAgHSYgzywV9zcGmM=
121-
golang.org/x/image v0.9.0 h1:QrzfX26snvCM20hIhBwuHI/ThTg18b/+kcKdXHvnR+g=
122-
golang.org/x/image v0.9.0/go.mod h1:jtrku+n79PfroUbvDdeUWMAI+heR786BofxrbiSF+J0=
123-
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
124-
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
125-
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
126-
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
127-
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
128-
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
129-
golang.org/x/net v0.11.0 h1:Gi2tvZIJyBtO9SDr1q9h5hEQCp/4L2RQ+ar0qjx2oNU=
130-
golang.org/x/net v0.11.0/go.mod h1:2L/ixqYpgIVXmeoSA/4Lu7BzTG4KIyPIryS4IsOd1oQ=
131-
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
132-
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
133-
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
134-
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
117+
golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY=
118+
golang.org/x/image v0.14.0 h1:tNgSxAFe3jC4uYqvZdTr84SZoM1KfwdC9SKIFrLjFn4=
119+
golang.org/x/image v0.14.0/go.mod h1:HUYqC05R2ZcZ3ejNQsIHQDQiwWM4JBqmm6MKANTp4LE=
120+
golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c=
121+
golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U=
135122
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
136-
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
137-
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
138-
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
139-
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
140123
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
141-
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
142124
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
143-
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
144-
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
145-
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
146-
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
147-
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
148-
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
125+
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
126+
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
149127
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
150-
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
151-
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
152-
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
153-
golang.org/x/text v0.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4=
154-
golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
128+
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
129+
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
155130
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
156131
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
157-
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
158-
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
159-
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
160-
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
161132
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
162133
google.golang.org/genproto/googleapis/rpc v0.0.0-20231030173426-d783a09b4405 h1:AB/lmRny7e2pLhFEYIbl5qkDAUt2h0ZRO4wGPhZf+ik=
163134
google.golang.org/genproto/googleapis/rpc v0.0.0-20231030173426-d783a09b4405/go.mod h1:67X1fPuzjcrkymZzZV1vvkFeTn2Rvc6lYF9MYFGCcwE=

Diff for: network/ws_client.go

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const (
1313
MaxMsgLen = 1024 * 1024 * 10
1414
)
1515

16+
// WSClient just for client dial to websocket server
1617
type WSClient struct {
1718
sync.Mutex
1819
Addr string

0 commit comments

Comments
 (0)