You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
881 B
36 lines
881 B
package gate
|
|
|
|
import (
|
|
"Open_IM/pkg/common/config"
|
|
"Open_IM/pkg/common/log"
|
|
"Open_IM/pkg/statistics"
|
|
"fmt"
|
|
"github.com/go-playground/validator/v10"
|
|
"sync"
|
|
)
|
|
|
|
var (
|
|
rwLock *sync.RWMutex
|
|
validate *validator.Validate
|
|
ws WServer
|
|
rpcSvr RPCServer
|
|
sendMsgCount uint64
|
|
userCount uint64
|
|
)
|
|
|
|
func Init(rpcPort, wsPort int) {
|
|
//log initialization
|
|
log.NewPrivateLog(config.Config.ModuleName.LongConnSvrName)
|
|
rwLock = new(sync.RWMutex)
|
|
validate = validator.New()
|
|
statistics.NewStatistics(&sendMsgCount, config.Config.ModuleName.LongConnSvrName, fmt.Sprintf("%d second recv to msg_gateway sendMsgCount", sendMsgCount), 10)
|
|
statistics.NewStatistics(&userCount, config.Config.ModuleName.LongConnSvrName, fmt.Sprintf("%d second add user conn", userCount), 10)
|
|
ws.onInit(wsPort)
|
|
rpcSvr.onInit(rpcPort)
|
|
}
|
|
|
|
func Run() {
|
|
go ws.run()
|
|
go rpcSvr.run()
|
|
}
|