Skip to content

Commit e970d5e

Browse files
committed
format
1 parent 8c09718 commit e970d5e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+939
-96
lines changed

bootstrap.bat

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
@echo off
2+
SETLOCAL
3+
4+
mage -version >nul 2>&1
5+
IF %ERRORLEVEL% EQU 0 (
6+
echo Mage is already installed.
7+
GOTO DOWNLOAD
8+
)
9+
10+
go version >nul 2>&1
11+
IF NOT %ERRORLEVEL% EQU 0 (
12+
echo Go is not installed. Please install Go and try again.
13+
exit /b 1
14+
)
15+
16+
echo Installing Mage...
17+
go install github.com/magefile/mage@latest
18+
19+
mage -version >nul 2>&1
20+
IF NOT %ERRORLEVEL% EQU 0 (
21+
echo Mage installation failed.
22+
echo Please ensure that %GOPATH%/bin is in your PATH.
23+
exit /b 1
24+
)
25+
26+
echo Mage installed successfully.
27+
28+
:DOWNLOAD
29+
go mod download
30+
31+
ENDLOCAL

bootstrap.sh

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
3+
if [[ ":$PATH:" == *":$HOME/.local/bin:"* ]]; then
4+
TARGET_DIR="$HOME/.local/bin"
5+
else
6+
TARGET_DIR="/usr/local/bin"
7+
echo "Using /usr/local/bin as the installation directory. Might require sudo permissions."
8+
fi
9+
10+
if ! command -v mage &> /dev/null; then
11+
echo "Installing Mage to $TARGET_DIR ..."
12+
GOBIN=$TARGET_DIR go install github.com/magefile/mage@latest
13+
fi
14+
15+
if ! command -v mage &> /dev/null; then
16+
echo "Mage installation failed."
17+
echo "Please ensure that $TARGET_DIR is in your \$PATH."
18+
exit 1
19+
fi
20+
21+
echo "Mage installed successfully."
22+
23+
go mod download

cmd/main.go cmd/openim-sdk/main.go

+9-9
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@ package main
33
import (
44
"flag"
55
"fmt"
6+
"github.com/openim-sigs/oimws/pkg/core_func"
7+
gate2 "github.com/openim-sigs/oimws/pkg/gate"
8+
module2 "github.com/openim-sigs/oimws/pkg/module"
9+
"github.com/openim-sigs/oimws/pkg/network/tjson"
610
"os"
711
"os/signal"
812
"sync"
913
"syscall"
1014
"time"
1115

12-
"github.com/openim-sigs/oimws/core_func"
13-
"github.com/openim-sigs/oimws/gate"
14-
"github.com/openim-sigs/oimws/module"
15-
"github.com/openim-sigs/oimws/network/tjson"
1616
log "github.com/xuexihuang/new_log15"
1717
)
1818

@@ -26,22 +26,22 @@ const (
2626
var Processor = tjson.NewProcessor()
2727

2828
type GateNet struct {
29-
*gate.Gate
29+
*gate2.Gate
3030
CloseSig chan bool
3131
Wg sync.WaitGroup
3232
}
3333

3434
// Initsever initializes a new GateNet instance with the given WebSocket port and default configurations.
3535
func Initsever(wsPort int) *GateNet {
3636
gatenet := new(GateNet)
37-
gatenet.Gate = gate.NewGate(MaxConnNum, MaxMsgLen,
37+
gatenet.Gate = gate2.NewGate(MaxConnNum, MaxMsgLen,
3838
Processor, ":"+fmt.Sprintf("%d", wsPort), HTTPTimeout, WriterChanLen)
3939
gatenet.CloseSig = make(chan bool, 1)
4040
return gatenet
4141
}
4242

4343
// SetMsgFun sets the functions that will be called on new connection, disconnection, and data reception events.
44-
func (gt *GateNet) SetMsgFun(Fun1 func(gate.Agent), Fun2 func(gate.Agent), Fun3 func(interface{}, gate.Agent)) {
44+
func (gt *GateNet) SetMsgFun(Fun1 func(gate2.Agent), Fun2 func(gate2.Agent), Fun3 func(interface{}, gate2.Agent)) {
4545
gt.Gate.SetFun(Fun1, Fun2, Fun3)
4646
}
4747

@@ -80,13 +80,13 @@ func main() {
8080
fmt.Println("Client starting....")
8181
log.Info("Client starting....")
8282
gatenet := Initsever(*sdkWsPort)
83-
gatenet.SetMsgFun(module.NewAgent, module.CloseAgent, module.DataRecv)
83+
gatenet.SetMsgFun(module2.NewAgent, module2.CloseAgent, module2.DataRecv)
8484
go gatenet.Runloop()
8585
/////////////////////////////////////
8686
//statusGate := Initsever(90)
8787
//gatenet.SetMsgFun(module.NewStatusAgent, module.CloseStatusAgent, module.DataRecvStatus)
8888
//go gatenet.Runloop()
89-
module.ProgressStartTime = time.Now().Unix()
89+
module2.ProgressStartTime = time.Now().Unix()
9090
///////////////////////////////////////////
9191
c := make(chan os.Signal, 1)
9292
signal.Notify(c, os.Interrupt, os.Kill, syscall.SIGQUIT, syscall.SIGTERM)

config/config.yml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
openimApi: "http://127.0.0.1:10002"
2+
openimWs: "ws://127.0.0.1:10001"
3+
sdkWsPort: [ 10003 ]
4+
dbDir: "./db"

config/log.yml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
# Log storage path, default is acceptable, change to a full path if modification is needed
3+
storageLocation: ../../../../logs/
4+
# Log rotation period (in hours), default is acceptable
5+
rotationTime: 24
6+
# Number of log files to retain, default is acceptable
7+
remainRotationCount: 2
8+
# Log level settings: 3 for production environment; 6 for more verbose logging in debugging environments
9+
remainLogLevel: 6
10+
# Whether to output to standard output, default is acceptable
11+
isStdout: false
12+
# Whether to log in JSON format, default is acceptable
13+
isJson: false
14+

go.mod

+45-17
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,81 @@
11
module github.com/openim-sigs/oimws
22

3-
go 1.19
3+
go 1.21.2
4+
5+
toolchain go1.21.9
46

57
require (
68
github.com/OpenIMSDK/tools v0.0.24
79
github.com/bwmarrin/snowflake v0.3.0
8-
github.com/gorilla/websocket v1.5.0
10+
github.com/gorilla/websocket v1.5.1
11+
github.com/mitchellh/mapstructure v1.5.0
12+
github.com/openimsdk/gomake v0.0.11
913
github.com/openimsdk/openim-sdk-core/v3 v3.5.1-beta.1
10-
github.com/stretchr/testify v1.8.3
14+
github.com/openimsdk/tools v0.0.49-alpha.2
15+
github.com/spf13/cobra v1.8.0
16+
github.com/spf13/viper v1.18.2
17+
github.com/stretchr/testify v1.9.0
1118
github.com/xuexihuang/new_log15 v1.0.0
19+
gopkg.in/yaml.v3 v3.0.1
1220
)
1321

1422
require (
15-
github.com/google/go-cmp v0.5.9 // indirect
16-
github.com/jinzhu/copier v0.3.5 // indirect
23+
github.com/google/go-cmp v0.6.0 // indirect
24+
github.com/jinzhu/copier v0.4.0 // indirect
1725
github.com/mattn/go-sqlite3 v1.14.12 // indirect
1826
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 // indirect
19-
golang.org/x/image v0.14.0 // indirect
20-
golang.org/x/net v0.19.0 // indirect
27+
golang.org/x/image v0.15.0 // indirect
28+
golang.org/x/net v0.22.0 // indirect
2129
golang.org/x/text v0.14.0 // indirect
22-
google.golang.org/grpc v1.56.2 // indirect
30+
google.golang.org/grpc v1.62.1 // indirect
2331
gorm.io/driver/sqlite v1.3.6 // indirect
2432
nhooyr.io/websocket v1.8.10 // indirect
2533
)
2634

2735
require (
2836
github.com/OpenIMSDK/protocol v0.0.40 // indirect
29-
github.com/davecgh/go-spew v1.1.1 // indirect
37+
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
38+
github.com/fsnotify/fsnotify v1.7.0 // indirect
39+
github.com/go-ole/go-ole v1.2.6 // indirect
3040
github.com/golang/protobuf v1.5.3 // indirect
41+
github.com/hashicorp/hcl v1.0.0 // indirect
42+
github.com/inconshreveable/mousetrap v1.1.0 // indirect
3143
github.com/jinzhu/inflection v1.0.0 // indirect
3244
github.com/jinzhu/now v1.1.5 // indirect
3345
github.com/json-iterator/go v1.1.12 // indirect
3446
github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible // indirect
3547
github.com/lestrrat-go/strftime v1.0.6 // indirect
48+
github.com/magefile/mage v1.15.0 // indirect
49+
github.com/magiconair/properties v1.8.7 // indirect
3650
github.com/mattn/go-colorable v0.1.13 // indirect
3751
github.com/mattn/go-isatty v0.0.19 // indirect
3852
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
3953
github.com/modern-go/reflect2 v1.0.2 // indirect
54+
github.com/openimsdk/protocol v0.0.63 // indirect
4055
github.com/patrickmn/go-cache v2.1.0+incompatible // indirect
56+
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
4157
github.com/petermattis/goid v0.0.0-20230904192822-1876fd5063bc // indirect
4258
github.com/pkg/errors v0.9.1 // indirect
43-
github.com/pmezard/go-difflib v1.0.0 // indirect
44-
go.uber.org/atomic v1.7.0 // indirect
45-
go.uber.org/multierr v1.6.0 // indirect
59+
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
60+
github.com/sagikazarmark/locafero v0.4.0 // indirect
61+
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
62+
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
63+
github.com/sourcegraph/conc v0.3.0 // indirect
64+
github.com/spf13/afero v1.11.0 // indirect
65+
github.com/spf13/cast v1.6.0 // indirect
66+
github.com/spf13/pflag v1.0.5 // indirect
67+
github.com/subosito/gotenv v1.6.0 // indirect
68+
github.com/tklauser/go-sysconf v0.3.13 // indirect
69+
github.com/tklauser/numcpus v0.7.0 // indirect
70+
github.com/yusufpapurcu/wmi v1.2.4 // indirect
71+
go.uber.org/atomic v1.9.0 // indirect
72+
go.uber.org/multierr v1.11.0 // indirect
4673
go.uber.org/zap v1.24.0 // indirect
47-
golang.org/x/sys v0.15.0 // indirect
48-
google.golang.org/genproto/googleapis/rpc v0.0.0-20231030173426-d783a09b4405 // indirect
49-
google.golang.org/protobuf v1.31.0 // indirect
74+
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
75+
golang.org/x/sys v0.19.0 // indirect
76+
google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 // indirect
77+
google.golang.org/protobuf v1.33.0 // indirect
78+
gopkg.in/ini.v1 v1.67.0 // indirect
5079
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
51-
gopkg.in/yaml.v3 v3.0.1 // indirect
52-
gorm.io/gorm v1.23.8 // indirect
80+
gorm.io/gorm v1.25.8 // indirect
5381
)

0 commit comments

Comments
 (0)