Merge branch 'tuoyun'

This commit is contained in:
Gordon 2022-04-06 11:56:22 +08:00
commit ac70b1d11b
31 changed files with 2762 additions and 444 deletions

@ -1 +1 @@
Subproject commit 7b66c0ab78be494ce2cfe23de37543dd11c2d354 Subproject commit 2257ac8ee528fb1e0038f85e34c8770fbe4758e3

View File

@ -10,20 +10,29 @@ import (
"Open_IM/internal/api/office" "Open_IM/internal/api/office"
apiThird "Open_IM/internal/api/third" apiThird "Open_IM/internal/api/third"
"Open_IM/internal/api/user" "Open_IM/internal/api/user"
"Open_IM/pkg/common/constant" "Open_IM/pkg/common/config"
"Open_IM/pkg/common/log" "Open_IM/pkg/common/log"
"Open_IM/pkg/utils" "Open_IM/pkg/utils"
"flag" "flag"
"io"
"os"
"strconv" "strconv"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
//"syscall" //"syscall"
"Open_IM/pkg/common/constant"
) )
func main() { func main() {
log.NewPrivateLog(constant.LogFileName)
gin.SetMode(gin.ReleaseMode) gin.SetMode(gin.ReleaseMode)
f, _ := os.Create("../logs/api.log")
gin.DefaultWriter = io.MultiWriter(f)
r := gin.Default() r := gin.Default()
r.Use(utils.CorsHandler()) r.Use(utils.CorsHandler())
log.Info("load config: ", config.Config)
// user routing group, which handles user registration and login services // user routing group, which handles user registration and login services
userRouterGroup := r.Group("/user") userRouterGroup := r.Group("/user")
{ {
@ -126,8 +135,7 @@ func main() {
officeGroup.POST("/send_msg_to_tag", office.SendMsg2Tag) officeGroup.POST("/send_msg_to_tag", office.SendMsg2Tag)
officeGroup.POST("/get_send_tag_log", office.GetTagSendLogs) officeGroup.POST("/get_send_tag_log", office.GetTagSendLogs)
} }
apiThird.MinioInit() go apiThird.MinioInit()
log.NewPrivateLog(constant.LogFileName)
ginPort := flag.Int("port", 10000, "get ginServerPort from cmd,default 10000 as port") ginPort := flag.Int("port", 10000, "get ginServerPort from cmd,default 10000 as port")
flag.Parse() flag.Parse()
r.Run(":" + strconv.Itoa(*ginPort)) r.Run(":" + strconv.Itoa(*ginPort))

View File

@ -2,16 +2,22 @@ package main
import ( import (
"Open_IM/internal/demo/register" "Open_IM/internal/demo/register"
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/log"
"Open_IM/pkg/utils" "Open_IM/pkg/utils"
"flag" "flag"
"io"
"os"
"strconv" "strconv"
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/log"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )
func main() { func main() {
log.NewPrivateLog(constant.LogFileName)
gin.SetMode(gin.ReleaseMode)
f, _ := os.Create("../logs/api.log")
gin.DefaultWriter = io.MultiWriter(f)
r := gin.Default() r := gin.Default()
r.Use(utils.CorsHandler()) r.Use(utils.CorsHandler())
@ -24,7 +30,7 @@ func main() {
authRouterGroup.POST("/login", register.Login) authRouterGroup.POST("/login", register.Login)
authRouterGroup.POST("/reset_password", register.ResetPassword) authRouterGroup.POST("/reset_password", register.ResetPassword)
} }
log.NewPrivateLog(constant.LogFileName)
ginPort := flag.Int("port", 42233, "get ginServerPort from cmd,default 42233 as port") ginPort := flag.Int("port", 42233, "get ginServerPort from cmd,default 42233 as port")
flag.Parse() flag.Parse()
r.Run(":" + strconv.Itoa(*ginPort)) r.Run(":" + strconv.Itoa(*ginPort))

View File

@ -2,11 +2,14 @@ package main
import ( import (
"Open_IM/internal/msg_gateway/gate" "Open_IM/internal/msg_gateway/gate"
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/log"
"flag" "flag"
"sync" "sync"
) )
func main() { func main() {
log.NewPrivateLog(constant.LogFileName)
rpcPort := flag.Int("rpc_port", 10400, "rpc listening port") rpcPort := flag.Int("rpc_port", 10400, "rpc listening port")
wsPort := flag.Int("ws_port", 17778, "ws listening port") wsPort := flag.Int("ws_port", 17778, "ws listening port")
flag.Parse() flag.Parse()

View File

@ -2,12 +2,15 @@ package main
import ( import (
"Open_IM/internal/msg_transfer/logic" "Open_IM/internal/msg_transfer/logic"
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/log"
"sync" "sync"
) )
func main() { func main() {
var wg sync.WaitGroup var wg sync.WaitGroup
wg.Add(1) wg.Add(1)
log.NewPrivateLog(constant.LogFileName)
logic.Init() logic.Init()
logic.Run() logic.Run()
wg.Wait() wg.Wait()

View File

@ -2,6 +2,8 @@ package main
import ( import (
"Open_IM/internal/push/logic" "Open_IM/internal/push/logic"
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/log"
"flag" "flag"
"sync" "sync"
) )
@ -11,6 +13,7 @@ func main() {
flag.Parse() flag.Parse()
var wg sync.WaitGroup var wg sync.WaitGroup
wg.Add(1) wg.Add(1)
log.NewPrivateLog(constant.LogFileName)
logic.Init(*rpcPort) logic.Init(*rpcPort)
logic.Run() logic.Run()
wg.Wait() wg.Wait()

View File

@ -2,10 +2,7 @@ package main
import ( import (
"Open_IM/pkg/common/constant" "Open_IM/pkg/common/constant"
commonDB "Open_IM/pkg/common/db"
"Open_IM/pkg/common/db/mysql_model/im_mysql_model"
"Open_IM/pkg/common/log" "Open_IM/pkg/common/log"
"time"
) )
func main() { func main() {
@ -40,27 +37,27 @@ func main() {
// time.Sleep(time.Duration(sleepTime) * time.Second) // time.Sleep(time.Duration(sleepTime) * time.Second)
// } // }
//} //}
for { //for {
uidList, err := im_mysql_model.SelectAllUserID() // uidList, err := im_mysql_model.SelectAllUserID()
if err != nil { // if err != nil {
//log.NewError("999999", err.Error()) // //log.NewError("999999", err.Error())
} else { // } else {
for _, v := range uidList { // for _, v := range uidList {
minSeq, err := commonDB.DB.GetMinSeqFromMongo(v) // minSeq, err := commonDB.DB.GetMinSeqFromMongo(v)
if err != nil { // if err != nil {
//log.NewError("999999", "get user minSeq err", err.Error(), v) // //log.NewError("999999", "get user minSeq err", err.Error(), v)
continue // continue
} else { // } else {
err := commonDB.DB.SetUserMinSeq(v, minSeq) // err := commonDB.DB.SetUserMinSeq(v, minSeq)
if err != nil { // if err != nil {
//log.NewError("999999", "set user minSeq err", err.Error(), v) // //log.NewError("999999", "set user minSeq err", err.Error(), v)
} // }
} // }
time.Sleep(time.Duration(100) * time.Millisecond) // time.Sleep(time.Duration(100) * time.Millisecond)
} // }
//
} // }
//
} //}
} }

View File

@ -588,5 +588,6 @@ demo:
smtpAddr: "smtp.qq.com" smtpAddr: "smtp.qq.com"
smtpPort: 25 #需开放此端口 出口方向 smtpPort: 25 #需开放此端口 出口方向
rtc:
port: 11300
address: 127.0.0.1

View File

@ -35,10 +35,16 @@ func UserRegister(c *gin.Context) {
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAuthName) etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAuthName)
client := rpc.NewAuthClient(etcdConn) client := rpc.NewAuthClient(etcdConn)
reply, err := client.UserRegister(context.Background(), req) reply, err := client.UserRegister(context.Background(), req)
if err != nil || reply.CommonResp.ErrCode != 0 { if err != nil {
log.NewError(req.OperationID, "UserRegister failed ", err, reply.CommonResp.ErrCode) log.NewError(req.OperationID, "call rpc err ", err)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "internal service err"})
return
}
if reply.CommonResp.ErrCode != 0 {
log.NewError(req.OperationID, "UserRegister failed ", err)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": reply.CommonResp.ErrMsg}) c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": reply.CommonResp.ErrMsg})
return return
} }
pbDataToken := &rpc.UserTokenReq{Platform: params.Platform, FromUserID: params.UserID, OperationID: params.OperationID} pbDataToken := &rpc.UserTokenReq{Platform: params.Platform, FromUserID: params.UserID, OperationID: params.OperationID}

View File

@ -15,18 +15,21 @@ var (
) )
func MinioInit() { func MinioInit() {
log.NewInfo("", utils.GetSelfFuncName()) operationID := utils.OperationIDGenerator()
log.NewInfo(operationID, utils.GetSelfFuncName(), "minio config: ", config.Config.Credential.Minio)
minioUrl, err := url2.Parse(config.Config.Credential.Minio.Endpoint) minioUrl, err := url2.Parse(config.Config.Credential.Minio.Endpoint)
if err != nil { if err != nil {
log.NewError("", utils.GetSelfFuncName(), "parse failed, please check config/config.yaml", err.Error()) log.NewError(operationID, utils.GetSelfFuncName(), "parse failed, please check config/config.yaml", err.Error())
return return
} }
log.NewInfo(operationID, utils.GetSelfFuncName(), "Parse ok ", config.Config.Credential.Minio)
minioClient, err = minio.New(minioUrl.Host, &minio.Options{ minioClient, err = minio.New(minioUrl.Host, &minio.Options{
Creds: credentials.NewStaticV4(config.Config.Credential.Minio.AccessKeyID, config.Config.Credential.Minio.SecretAccessKey, ""), Creds: credentials.NewStaticV4(config.Config.Credential.Minio.AccessKeyID, config.Config.Credential.Minio.SecretAccessKey, ""),
Secure: false, Secure: false,
}) })
log.NewInfo(operationID, utils.GetSelfFuncName(), "new ok ", config.Config.Credential.Minio)
if err != nil { if err != nil {
log.NewError("", utils.GetSelfFuncName(), "init minio client failed", err.Error()) log.NewError(operationID, utils.GetSelfFuncName(), "init minio client failed", err.Error())
return return
} }
opt := minio.MakeBucketOptions{ opt := minio.MakeBucketOptions{
@ -35,15 +38,15 @@ func MinioInit() {
} }
err = minioClient.MakeBucket(context.Background(), config.Config.Credential.Minio.Bucket, opt) err = minioClient.MakeBucket(context.Background(), config.Config.Credential.Minio.Bucket, opt)
if err != nil { if err != nil {
log.NewInfo("", utils.GetSelfFuncName(), err.Error()) log.NewError(operationID, utils.GetSelfFuncName(), "MakeBucket failed ", err.Error())
exists, err := minioClient.BucketExists(context.Background(), config.Config.Credential.Minio.Bucket) exists, err := minioClient.BucketExists(context.Background(), config.Config.Credential.Minio.Bucket)
if err == nil && exists { if err == nil && exists {
log.NewInfo("", utils.GetSelfFuncName(), "We already own %s\n", config.Config.Credential.Minio.Bucket) log.NewWarn(operationID, utils.GetSelfFuncName(), "We already own ", config.Config.Credential.Minio.Bucket)
} else { } else {
if err != nil { if err != nil {
log.NewError("", utils.GetSelfFuncName(), err.Error()) log.NewError(operationID, utils.GetSelfFuncName(), err.Error())
} }
log.NewError("", utils.GetSelfFuncName(), "create bucket failed and bucket not exists") log.NewError(operationID, utils.GetSelfFuncName(), "create bucket failed and bucket not exists")
return return
} }
} }
@ -53,5 +56,5 @@ func MinioInit() {
// log.NewError("", utils.GetSelfFuncName(), "SetBucketPolicy failed please set in web", err.Error()) // log.NewError("", utils.GetSelfFuncName(), "SetBucketPolicy failed please set in web", err.Error())
// return // return
//} //}
log.NewInfo("", utils.GetSelfFuncName(), "minio create and set policy success") log.NewInfo(operationID, utils.GetSelfFuncName(), "minio create and set policy success")
} }

View File

@ -2,8 +2,7 @@ package gate
import ( import (
"Open_IM/pkg/common/config" "Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/log"
"Open_IM/pkg/statistics" "Open_IM/pkg/statistics"
"fmt" "fmt"
"github.com/go-playground/validator/v10" "github.com/go-playground/validator/v10"
@ -21,7 +20,7 @@ var (
func Init(rpcPort, wsPort int) { func Init(rpcPort, wsPort int) {
//log initialization //log initialization
log.NewPrivateLog(constant.LogFileName)
rwLock = new(sync.RWMutex) rwLock = new(sync.RWMutex)
validate = validator.New() validate = validator.New()
statistics.NewStatistics(&sendMsgCount, config.Config.ModuleName.LongConnSvrName, fmt.Sprintf("%d second recv to msg_gateway sendMsgCount", sendMsgCount), 300) statistics.NewStatistics(&sendMsgCount, config.Config.ModuleName.LongConnSvrName, fmt.Sprintf("%d second recv to msg_gateway sendMsgCount", sendMsgCount), 300)

View File

@ -6,13 +6,17 @@ import (
"Open_IM/pkg/common/log" "Open_IM/pkg/common/log"
"Open_IM/pkg/grpc-etcdv3/getcdv3" "Open_IM/pkg/grpc-etcdv3/getcdv3"
pbChat "Open_IM/pkg/proto/chat" pbChat "Open_IM/pkg/proto/chat"
pbRtc "Open_IM/pkg/proto/rtc"
sdk_ws "Open_IM/pkg/proto/sdk_ws" sdk_ws "Open_IM/pkg/proto/sdk_ws"
"Open_IM/pkg/utils"
"bytes" "bytes"
"context" "context"
"encoding/gob" "encoding/gob"
"github.com/golang/protobuf/proto" "github.com/golang/protobuf/proto"
"github.com/gorilla/websocket" "github.com/gorilla/websocket"
"google.golang.org/grpc"
"runtime" "runtime"
"strconv"
"strings" "strings"
) )
@ -200,38 +204,61 @@ func (ws *WServer) sendSignalMsgReq(conn *UserConn, m *Req) {
nReply := new(pbChat.SendMsgResp) nReply := new(pbChat.SendMsgResp)
isPass, errCode, errMsg, pData := ws.argsValidate(m, constant.WSSendSignalMsg) isPass, errCode, errMsg, pData := ws.argsValidate(m, constant.WSSendSignalMsg)
if isPass { if isPass {
isPass2, errCode2, errMsg2, signalResp, msgData := ws.signalMessageAssemble(pData.(*sdk_ws.SignalReq), m.OperationID) signalResp := pbRtc.SignalResp{}
if isPass2 { //isPass2, errCode2, errMsg2, signalResp, msgData := ws.signalMessageAssemble(pData.(*sdk_ws.SignalReq), m.OperationID)
connGrpc, err := grpc.Dial(config.Config.Rtc.Address+":"+strconv.Itoa(config.Config.Rtc.Port), grpc.WithInsecure())
if err != nil {
log.NewError(m.OperationID, utils.GetSelfFuncName(), "grpc.Dial failed", err.Error())
ws.sendSignalMsgResp(conn, 204, "create grpc failed"+err.Error(), m, nil)
return
}
rtcClient := pbRtc.NewRtcServiceClient(connGrpc)
req := &pbRtc.SignalMessageAssembleReq{
SignalReq: pData.(*pbRtc.SignalReq),
OperationID: m.OperationID,
}
respPb, err := rtcClient.SignalMessageAssemble(context.Background(), req)
if err != nil {
log.NewError(m.OperationID, utils.GetSelfFuncName(), "SignalMessageAssemble", err.Error(), config.Config.Rtc.Address+":"+strconv.Itoa(config.Config.Rtc.Port))
ws.sendSignalMsgResp(conn, 204, "grpc SignalMessageAssemble failed: "+err.Error(), m, &signalResp)
return
}
signalResp.Payload = respPb.SignalResp.Payload
msgData := sdk_ws.MsgData{}
utils.CopyStructFields(&msgData, respPb.MsgData)
log.NewInfo(m.OperationID, utils.GetSelfFuncName(), respPb.String())
if respPb.IsPass {
pbData := pbChat.SendMsgReq{ pbData := pbChat.SendMsgReq{
Token: m.Token, Token: m.Token,
OperationID: m.OperationID, OperationID: m.OperationID,
MsgData: msgData, MsgData: &msgData,
} }
log.NewInfo(m.OperationID, utils.GetSelfFuncName(), "pbData: ", pbData)
log.NewInfo(m.OperationID, "Ws call success to sendSignalMsgReq middle", m.ReqIdentifier, m.SendID, m.MsgIncr, msgData) log.NewInfo(m.OperationID, "Ws call success to sendSignalMsgReq middle", m.ReqIdentifier, m.SendID, m.MsgIncr, msgData)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName) etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
client := pbChat.NewChatClient(etcdConn) client := pbChat.NewChatClient(etcdConn)
reply, err := client.SendMsg(context.Background(), &pbData) reply, err := client.SendMsg(context.Background(), &pbData)
if err != nil { if err != nil {
log.NewError(pbData.OperationID, "rpc sendMsg err", err.Error()) log.NewError(pbData.OperationID, utils.GetSelfFuncName(), "rpc sendMsg err", err.Error())
nReply.ErrCode = 200 nReply.ErrCode = 200
nReply.ErrMsg = err.Error() nReply.ErrMsg = err.Error()
ws.sendSignalMsgResp(conn, 200, err.Error(), m, signalResp) ws.sendSignalMsgResp(conn, 200, err.Error(), m, &signalResp)
} else { } else {
log.NewInfo(pbData.OperationID, "rpc call success to sendMsgReq", reply.String()) log.NewInfo(pbData.OperationID, "rpc call success to sendMsgReq", reply.String())
ws.sendSignalMsgResp(conn, 0, "", m, signalResp) ws.sendSignalMsgResp(conn, 0, "", m, &signalResp)
} }
} else { } else {
log.NewError(m.OperationID, isPass2, errCode2, errMsg2) log.NewError(m.OperationID, utils.GetSelfFuncName(), respPb.IsPass, respPb.CommonResp.ErrCode, respPb.CommonResp.ErrMsg)
ws.sendSignalMsgResp(conn, errCode2, errMsg2, m, signalResp) ws.sendSignalMsgResp(conn, respPb.CommonResp.ErrCode, respPb.CommonResp.ErrMsg, m, &signalResp)
} }
} else { } else {
ws.sendSignalMsgResp(conn, errCode, errMsg, m, nil) ws.sendSignalMsgResp(conn, errCode, errMsg, m, nil)
} }
} }
func (ws *WServer) sendSignalMsgResp(conn *UserConn, errCode int32, errMsg string, m *Req, pb *sdk_ws.SignalResp) { func (ws *WServer) sendSignalMsgResp(conn *UserConn, errCode int32, errMsg string, m *Req, pb *pbRtc.SignalResp) {
// := make(map[string]interface{}) // := make(map[string]interface{})
log.Debug(m.OperationID, "SignalMsgResp is", pb.String())
b, _ := proto.Marshal(pb) b, _ := proto.Marshal(pb)
mReply := Resp{ mReply := Resp{
ReqIdentifier: m.ReqIdentifier, ReqIdentifier: m.ReqIdentifier,

View File

@ -1,14 +1,5 @@
package open_im_media package open_im_media
import (
pbRtc "Open_IM/pkg/proto/rtc"
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
"context"
"errors"
"github.com/jinzhu/copier"
"google.golang.org/grpc"
)
const ( const (
// Address gRPC服务地址 // Address gRPC服务地址
Address = "127.0.0.1:11300" Address = "127.0.0.1:11300"
@ -23,35 +14,35 @@ func NewMedia() *Media {
return &Media{} return &Media{}
} }
func (m *Media) GetJoinToken(room, identity string, operationID string, data *open_im_sdk.ParticipantMetaData) (string, string, error) { //func (m *Media) GetJoinToken(room, identity string, operationID string, data *open_im_sdk.ParticipantMetaData) (string, string, error) {
var newData pbRtc.ParticipantMetaData // var newData pbRtc.ParticipantMetaData
copier.Copy(&newData, data) // copier.Copy(&newData, data)
conn, err := grpc.Dial(Address, grpc.WithInsecure()) // conn, err := grpc.Dial(Address, grpc.WithInsecure())
if err != nil { // if err != nil {
return "", "", err // return "", "", err
} // }
defer conn.Close() // defer conn.Close()
c := pbRtc.NewRtcServiceClient(conn) // c := pbRtc.NewRtcServiceClient(conn)
req := &pbRtc.GetJoinTokenReq{Room: room, OperationID: operationID, Identity: identity, MetaData: &newData} // req := &pbRtc.GetJoinTokenReq{Room: room, OperationID: operationID, Identity: identity, MetaData: &newData}
resp, err := c.GetJoinToken(context.Background(), req) // resp, err := c.GetJoinToken(context.Background(), req)
if err != nil { // if err != nil {
return "", "", err // return "", "", err
} // }
if resp.CommonResp.ErrCode != 0 { // if resp.CommonResp.ErrCode != 0 {
return "", "", errors.New(resp.CommonResp.ErrMsg) // return "", "", errors.New(resp.CommonResp.ErrMsg)
} // }
return resp.Jwt, resp.LiveURL, nil // return resp.Jwt, resp.LiveURL, nil
//at := auth.NewAccessToken(m.ApiKey, m.ApiSecret) // //at := auth.NewAccessToken(m.ApiKey, m.ApiSecret)
//grant := &auth.VideoGrant{ // //grant := &auth.VideoGrant{
// RoomJoin: true, // // RoomJoin: true,
// Room: room, // // Room: room,
// //}
// //at.AddGrant(grant).
// // SetIdentity(identity).
// // SetValidFor(time.Hour)
// //
// //return at.ToJWT()
//} //}
//at.AddGrant(grant).
// SetIdentity(identity).
// SetValidFor(time.Hour)
//
//return at.ToJWT()
}
func init() { func init() {
//roomClient = lksdk.NewRoomServiceClient(MediaAddress, ApiKey, ApiSecret) //roomClient = lksdk.NewRoomServiceClient(MediaAddress, ApiKey, ApiSecret)

View File

@ -7,12 +7,10 @@
package gate package gate
import ( import (
"Open_IM/internal/msg_gateway/gate/open_im_media"
"Open_IM/pkg/common/constant" "Open_IM/pkg/common/constant"
"Open_IM/pkg/common/log" "Open_IM/pkg/common/log"
pbRtc "Open_IM/pkg/proto/rtc"
open_im_sdk "Open_IM/pkg/proto/sdk_ws" open_im_sdk "Open_IM/pkg/proto/sdk_ws"
"Open_IM/pkg/utils"
"errors"
"github.com/golang/protobuf/proto" "github.com/golang/protobuf/proto"
) )
@ -74,7 +72,7 @@ func (ws *WServer) argsValidate(m *Req, r int32) (isPass bool, errCode int32, er
} }
return true, 0, "", data return true, 0, "", data
case constant.WSSendSignalMsg: case constant.WSSendSignalMsg:
data := open_im_sdk.SignalReq{} data := pbRtc.SignalReq{}
if err := proto.Unmarshal(m.Data, &data); err != nil { if err := proto.Unmarshal(m.Data, &data); err != nil {
log.ErrorByKv("Decode Data struct err", "", "err", err.Error(), "reqIdentifier", r) log.ErrorByKv("Decode Data struct err", "", "err", err.Error(), "reqIdentifier", r)
return false, 203, err.Error(), nil return false, 203, err.Error(), nil
@ -117,139 +115,139 @@ func (ws *WServer) argsValidate(m *Req, r int32) (isPass bool, errCode int32, er
} }
func (ws *WServer) signalMessageAssemble(s *open_im_sdk.SignalReq, operationID string) (isPass bool, errCode int32, errMsg string, r *open_im_sdk.SignalResp, msgData *open_im_sdk.MsgData) { //func (ws *WServer) signalMessageAssemble(s *open_im_sdk.SignalReq, operationID string) (isPass bool, errCode int32, errMsg string, r *open_im_sdk.SignalResp, msgData *open_im_sdk.MsgData) {
var msg open_im_sdk.MsgData // var msg open_im_sdk.MsgData
var resp open_im_sdk.SignalResp // var resp open_im_sdk.SignalResp
media := open_im_media.NewMedia() // media := open_im_media.NewMedia()
msg.MsgFrom = constant.UserMsgType // msg.MsgFrom = constant.UserMsgType
msg.ContentType = constant.SignalingNotification // msg.ContentType = constant.SignalingNotification
reqData, e := proto.Marshal(s) // reqData, e := proto.Marshal(s)
if e != nil { // if e != nil {
return false, 201, e.Error(), nil, nil // return false, 201, e.Error(), nil, nil
} // }
msg.Content = reqData // msg.Content = reqData
msg.CreateTime = utils.GetCurrentTimestampByMill() // msg.CreateTime = utils.GetCurrentTimestampByMill()
options := make(map[string]bool, 6) // options := make(map[string]bool, 6)
utils.SetSwitchFromOptions(options, constant.IsHistory, false) // utils.SetSwitchFromOptions(options, constant.IsHistory, false)
utils.SetSwitchFromOptions(options, constant.IsPersistent, false) // utils.SetSwitchFromOptions(options, constant.IsPersistent, false)
utils.SetSwitchFromOptions(options, constant.IsSenderSync, true) // utils.SetSwitchFromOptions(options, constant.IsSenderSync, true)
utils.SetSwitchFromOptions(options, constant.IsConversationUpdate, false) // utils.SetSwitchFromOptions(options, constant.IsConversationUpdate, false)
utils.SetSwitchFromOptions(options, constant.IsSenderConversationUpdate, false) // utils.SetSwitchFromOptions(options, constant.IsSenderConversationUpdate, false)
utils.SetSwitchFromOptions(options, constant.IsUnreadCount, false) // utils.SetSwitchFromOptions(options, constant.IsUnreadCount, false)
utils.SetSwitchFromOptions(options, constant.IsOfflinePush, true) // utils.SetSwitchFromOptions(options, constant.IsOfflinePush, true)
msg.Options = options // msg.Options = options
switch payload := s.Payload.(type) { // switch payload := s.Payload.(type) {
case *open_im_sdk.SignalReq_Invite: // case *open_im_sdk.SignalReq_Invite:
token, liveURL, err2 := media.GetJoinToken(payload.Invite.Invitation.RoomID, payload.Invite.Invitation.InviterUserID, operationID, payload.Invite.Participant) // token, liveURL, err2 := media.GetJoinToken(payload.Invite.Invitation.RoomID, payload.Invite.Invitation.InviterUserID, operationID, payload.Invite.Participant)
if err2 != nil { // if err2 != nil {
return false, 202, err2.Error(), nil, nil // return false, 202, err2.Error(), nil, nil
} // }
invite := open_im_sdk.SignalResp_Invite{&open_im_sdk.SignalInviteReply{ // invite := open_im_sdk.SignalResp_Invite{&open_im_sdk.SignalInviteReply{
Token: token, // Token: token,
RoomID: payload.Invite.Invitation.RoomID, // RoomID: payload.Invite.Invitation.RoomID,
LiveURL: liveURL, // LiveURL: liveURL,
}} // }}
resp.Payload = &invite // resp.Payload = &invite
msg.SenderPlatformID = payload.Invite.Invitation.PlatformID // msg.SenderPlatformID = payload.Invite.Invitation.PlatformID
msg.SessionType = payload.Invite.Invitation.SessionType // msg.SessionType = payload.Invite.Invitation.SessionType
msg.OfflinePushInfo = payload.Invite.OfflinePushInfo // msg.OfflinePushInfo = payload.Invite.OfflinePushInfo
msg.SendID = payload.Invite.Invitation.InviterUserID // msg.SendID = payload.Invite.Invitation.InviterUserID
if len(payload.Invite.Invitation.InviteeUserIDList) > 0 { // if len(payload.Invite.Invitation.InviteeUserIDList) > 0 {
msg.RecvID = payload.Invite.Invitation.InviteeUserIDList[0] // msg.RecvID = payload.Invite.Invitation.InviteeUserIDList[0]
} else { // } else {
return false, 203, errors.New("InviteeUserIDList is null").Error(), nil, nil // return false, 203, errors.New("InviteeUserIDList is null").Error(), nil, nil
} // }
msg.ClientMsgID = utils.GetMsgID(payload.Invite.Invitation.InviterUserID) // msg.ClientMsgID = utils.GetMsgID(payload.Invite.Invitation.InviterUserID)
return true, 0, "", &resp, &msg // return true, 0, "", &resp, &msg
case *open_im_sdk.SignalReq_InviteInGroup: // case *open_im_sdk.SignalReq_InviteInGroup:
token, liveURL, err2 := media.GetJoinToken(payload.InviteInGroup.Invitation.RoomID, payload.InviteInGroup.Invitation.InviterUserID, operationID, payload.InviteInGroup.Participant) // token, liveURL, err2 := media.GetJoinToken(payload.InviteInGroup.Invitation.RoomID, payload.InviteInGroup.Invitation.InviterUserID, operationID, payload.InviteInGroup.Participant)
if err2 != nil { // if err2 != nil {
return false, 204, err2.Error(), nil, nil // return false, 204, err2.Error(), nil, nil
} // }
inviteGroup := open_im_sdk.SignalResp_InviteInGroup{&open_im_sdk.SignalInviteInGroupReply{ // inviteGroup := open_im_sdk.SignalResp_InviteInGroup{&open_im_sdk.SignalInviteInGroupReply{
RoomID: payload.InviteInGroup.Invitation.RoomID, // RoomID: payload.InviteInGroup.Invitation.RoomID,
Token: token, // Token: token,
LiveURL: liveURL, // LiveURL: liveURL,
}} // }}
resp.Payload = &inviteGroup // resp.Payload = &inviteGroup
msg.SenderPlatformID = payload.InviteInGroup.Invitation.PlatformID // msg.SenderPlatformID = payload.InviteInGroup.Invitation.PlatformID
msg.SessionType = payload.InviteInGroup.Invitation.SessionType // msg.SessionType = payload.InviteInGroup.Invitation.SessionType
msg.OfflinePushInfo = payload.InviteInGroup.OfflinePushInfo // msg.OfflinePushInfo = payload.InviteInGroup.OfflinePushInfo
msg.SendID = payload.InviteInGroup.Invitation.InviterUserID // msg.SendID = payload.InviteInGroup.Invitation.InviterUserID
if len(payload.InviteInGroup.Invitation.InviteeUserIDList) > 0 { // if len(payload.InviteInGroup.Invitation.InviteeUserIDList) > 0 {
msg.GroupID = payload.InviteInGroup.Invitation.GroupID // msg.GroupID = payload.InviteInGroup.Invitation.GroupID
} else { // } else {
return false, 205, errors.New("InviteeUserIDList is null").Error(), nil, nil // return false, 205, errors.New("InviteeUserIDList is null").Error(), nil, nil
} // }
msg.ClientMsgID = utils.GetMsgID(payload.InviteInGroup.Invitation.InviterUserID) // msg.ClientMsgID = utils.GetMsgID(payload.InviteInGroup.Invitation.InviterUserID)
//
return true, 0, "", &resp, &msg // return true, 0, "", &resp, &msg
case *open_im_sdk.SignalReq_Cancel: // case *open_im_sdk.SignalReq_Cancel:
cancel := open_im_sdk.SignalResp_Cancel{&open_im_sdk.SignalCancelReply{}} // cancel := open_im_sdk.SignalResp_Cancel{&open_im_sdk.SignalCancelReply{}}
resp.Payload = &cancel // resp.Payload = &cancel
msg.OfflinePushInfo = payload.Cancel.OfflinePushInfo // msg.OfflinePushInfo = payload.Cancel.OfflinePushInfo
msg.SendID = payload.Cancel.Invitation.InviterUserID // msg.SendID = payload.Cancel.Invitation.InviterUserID
msg.SenderPlatformID = payload.Cancel.Invitation.PlatformID // msg.SenderPlatformID = payload.Cancel.Invitation.PlatformID
msg.SessionType = payload.Cancel.Invitation.SessionType // msg.SessionType = payload.Cancel.Invitation.SessionType
if len(payload.Cancel.Invitation.InviteeUserIDList) > 0 { // if len(payload.Cancel.Invitation.InviteeUserIDList) > 0 {
switch payload.Cancel.Invitation.SessionType { // switch payload.Cancel.Invitation.SessionType {
case constant.SingleChatType: // case constant.SingleChatType:
msg.RecvID = payload.Cancel.Invitation.InviteeUserIDList[0] // msg.RecvID = payload.Cancel.Invitation.InviteeUserIDList[0]
case constant.GroupChatType: // case constant.GroupChatType:
msg.GroupID = payload.Cancel.Invitation.GroupID // msg.GroupID = payload.Cancel.Invitation.GroupID
} // }
} else { // } else {
return false, 206, errors.New("InviteeUserIDList is null").Error(), nil, nil // return false, 206, errors.New("InviteeUserIDList is null").Error(), nil, nil
} // }
msg.ClientMsgID = utils.GetMsgID(payload.Cancel.OpUserID) // msg.ClientMsgID = utils.GetMsgID(payload.Cancel.OpUserID)
return true, 0, "", &resp, &msg // return true, 0, "", &resp, &msg
case *open_im_sdk.SignalReq_Accept: // case *open_im_sdk.SignalReq_Accept:
token, liveURL, err2 := media.GetJoinToken(payload.Accept.Invitation.RoomID, payload.Accept.OpUserID, operationID, payload.Accept.Participant) // token, liveURL, err2 := media.GetJoinToken(payload.Accept.Invitation.RoomID, payload.Accept.OpUserID, operationID, payload.Accept.Participant)
if err2 != nil { // if err2 != nil {
return false, 207, err2.Error(), nil, nil // return false, 207, err2.Error(), nil, nil
} // }
accept := open_im_sdk.SignalResp_Accept{&open_im_sdk.SignalAcceptReply{ // accept := open_im_sdk.SignalResp_Accept{&open_im_sdk.SignalAcceptReply{
Token: token, // Token: token,
LiveURL: liveURL, // LiveURL: liveURL,
RoomID: payload.Accept.Invitation.RoomID, // RoomID: payload.Accept.Invitation.RoomID,
}} // }}
resp.Payload = &accept // resp.Payload = &accept
msg.OfflinePushInfo = payload.Accept.OfflinePushInfo // msg.OfflinePushInfo = payload.Accept.OfflinePushInfo
msg.SendID = payload.Accept.OpUserID // msg.SendID = payload.Accept.OpUserID
msg.SenderPlatformID = payload.Accept.Invitation.PlatformID // msg.SenderPlatformID = payload.Accept.Invitation.PlatformID
msg.SessionType = payload.Accept.Invitation.SessionType // msg.SessionType = payload.Accept.Invitation.SessionType
if len(payload.Accept.Invitation.InviteeUserIDList) > 0 { // if len(payload.Accept.Invitation.InviteeUserIDList) > 0 {
switch payload.Accept.Invitation.SessionType { // switch payload.Accept.Invitation.SessionType {
case constant.SingleChatType: // case constant.SingleChatType:
msg.RecvID = payload.Accept.Invitation.InviterUserID // msg.RecvID = payload.Accept.Invitation.InviterUserID
case constant.GroupChatType: // case constant.GroupChatType:
msg.GroupID = payload.Accept.Invitation.GroupID // msg.GroupID = payload.Accept.Invitation.GroupID
} // }
} else { // } else {
return false, 208, errors.New("InviteeUserIDList is null").Error(), nil, nil // return false, 208, errors.New("InviteeUserIDList is null").Error(), nil, nil
} // }
msg.ClientMsgID = utils.GetMsgID(payload.Accept.OpUserID) // msg.ClientMsgID = utils.GetMsgID(payload.Accept.OpUserID)
return true, 0, "", &resp, &msg // return true, 0, "", &resp, &msg
case *open_im_sdk.SignalReq_HungUp: // case *open_im_sdk.SignalReq_HungUp:
case *open_im_sdk.SignalReq_Reject: // case *open_im_sdk.SignalReq_Reject:
reject := open_im_sdk.SignalResp_Reject{&open_im_sdk.SignalRejectReply{}} // reject := open_im_sdk.SignalResp_Reject{&open_im_sdk.SignalRejectReply{}}
resp.Payload = &reject // resp.Payload = &reject
msg.OfflinePushInfo = payload.Reject.OfflinePushInfo // msg.OfflinePushInfo = payload.Reject.OfflinePushInfo
msg.SendID = payload.Reject.OpUserID // msg.SendID = payload.Reject.OpUserID
msg.SenderPlatformID = payload.Reject.Invitation.PlatformID // msg.SenderPlatformID = payload.Reject.Invitation.PlatformID
msg.SessionType = payload.Reject.Invitation.SessionType // msg.SessionType = payload.Reject.Invitation.SessionType
if len(payload.Reject.Invitation.InviteeUserIDList) > 0 { // if len(payload.Reject.Invitation.InviteeUserIDList) > 0 {
switch payload.Reject.Invitation.SessionType { // switch payload.Reject.Invitation.SessionType {
case constant.SingleChatType: // case constant.SingleChatType:
msg.RecvID = payload.Reject.Invitation.InviterUserID // msg.RecvID = payload.Reject.Invitation.InviterUserID
case constant.GroupChatType: // case constant.GroupChatType:
msg.GroupID = payload.Reject.Invitation.GroupID // msg.GroupID = payload.Reject.Invitation.GroupID
} // }
} else { // } else {
return false, 209, errors.New("InviteeUserIDList is null").Error(), nil, nil // return false, 209, errors.New("InviteeUserIDList is null").Error(), nil, nil
} // }
msg.ClientMsgID = utils.GetMsgID(payload.Reject.OpUserID) // msg.ClientMsgID = utils.GetMsgID(payload.Reject.OpUserID)
return true, 0, "", &resp, &msg // return true, 0, "", &resp, &msg
} // }
return false, 210, errors.New("InviteeUserIDList is null").Error(), nil, nil // return false, 210, errors.New("InviteeUserIDList is null").Error(), nil, nil
} //}

View File

@ -2,9 +2,8 @@ package logic
import ( import (
"Open_IM/pkg/common/config" "Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/kafka" "Open_IM/pkg/common/kafka"
"Open_IM/pkg/common/log"
) )
var ( var (
@ -14,7 +13,7 @@ var (
) )
func Init() { func Init() {
log.NewPrivateLog(constant.LogFileName)
persistentCH.Init() persistentCH.Init()
historyCH.Init() historyCH.Init()
producer = kafka.NewKafkaProducer(config.Config.Kafka.Ms2pschat.Addr, config.Config.Kafka.Ms2pschat.Topic) producer = kafka.NewKafkaProducer(config.Config.Kafka.Ms2pschat.Addr, config.Config.Kafka.Ms2pschat.Topic)

View File

@ -0,0 +1,12 @@
package getui
type Getui struct {
}
func (g *Getui) Push(userIDList []string, alert, detailContent, platform string) (resp string, err error) {
return "", nil
}
func (g *Getui) Auth(apiKey, secretKey string, timeStamp int64) (token string, err error) {
return "", nil
}

View File

@ -13,6 +13,9 @@ import (
type JPushResp struct { type JPushResp struct {
} }
type JPush struct {
}
func JGAccountListPush(accounts []string, alert, detailContent, platform string) ([]byte, error) { func JGAccountListPush(accounts []string, alert, detailContent, platform string) ([]byte, error) {
var pf requestBody.Platform var pf requestBody.Platform

View File

@ -10,7 +10,6 @@ import (
"Open_IM/pkg/common/config" "Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant" "Open_IM/pkg/common/constant"
"Open_IM/pkg/common/kafka" "Open_IM/pkg/common/kafka"
"Open_IM/pkg/common/log"
"Open_IM/pkg/statistics" "Open_IM/pkg/statistics"
"fmt" "fmt"
) )
@ -24,7 +23,7 @@ var (
) )
func Init(rpcPort int) { func Init(rpcPort int) {
log.NewPrivateLog(constant.LogFileName)
rpcServer.Init(rpcPort) rpcServer.Init(rpcPort)
pushCh.Init() pushCh.Init()
pushTerminal = []int32{constant.IOSPlatformID, constant.AndroidPlatformID} pushTerminal = []int32{constant.IOSPlatformID, constant.AndroidPlatformID}

View File

@ -0,0 +1,6 @@
package push
type offlinePusher interface {
auth(apiKey, secretKey string, timeStamp int64) (token string, err error)
push(userIDList []string, alert, detailContent, platform string) (resp string, err error)
}

View File

@ -43,7 +43,7 @@ func (rpc *rpcChat) Run() {
log.Error("", "", "listen network failed, err = %s, address = %s", err.Error(), address) log.Error("", "", "listen network failed, err = %s, address = %s", err.Error(), address)
return return
} }
log.Info("", "", "listen network success, address = %s", address) log.Info("", "", "listen network success, address = ", address)
//grpc server //grpc server
srv := grpc.NewServer() srv := grpc.NewServer()

View File

@ -1,7 +1,6 @@
package config package config
import ( import (
"fmt"
"io/ioutil" "io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
@ -377,6 +376,10 @@ type config struct {
SmtpPort int `yaml:"smtpPort"` SmtpPort int `yaml:"smtpPort"`
} }
} }
Rtc struct {
Port int `yaml:"port"`
Address string `yaml:"address"`
} `yaml:"rtc"`
} }
type PConversation struct { type PConversation struct {
ReliabilityLevel int `yaml:"reliabilityLevel"` ReliabilityLevel int `yaml:"reliabilityLevel"`
@ -416,5 +419,4 @@ func init() {
if err = yaml.Unmarshal(bytes, &Config); err != nil { if err = yaml.Unmarshal(bytes, &Config); err != nil {
panic(err.Error()) panic(err.Error())
} }
fmt.Println("load config: ", Config)
} }

View File

@ -2,8 +2,7 @@ package db
import ( import (
"Open_IM/pkg/common/config" "Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant" //"Open_IM/pkg/common/log"
"Open_IM/pkg/common/log"
"Open_IM/pkg/utils" "Open_IM/pkg/utils"
"fmt" "fmt"
"go.mongodb.org/mongo-driver/mongo/options" "go.mongodb.org/mongo-driver/mongo/options"
@ -34,7 +33,7 @@ func key(dbAddress, dbName string) string {
} }
func init() { func init() {
log.NewPrivateLog(constant.LogFileName) //log.NewPrivateLog(constant.LogFileName)
//var mgoSession *mgo.Session //var mgoSession *mgo.Session
var mongoClient *mongo.Client var mongoClient *mongo.Client
var err1 error var err1 error
@ -54,15 +53,16 @@ func init() {
mongoClient, err := mongo.Connect(context.TODO(), options.Client().ApplyURI(uri)) mongoClient, err := mongo.Connect(context.TODO(), options.Client().ApplyURI(uri))
if err != nil { if err != nil {
log.NewError(" mongo.Connect failed, try ", utils.GetSelfFuncName(), err.Error(), uri) fmt.Println(" mongo.Connect failed, try ", utils.GetSelfFuncName(), err.Error(), uri)
time.Sleep(time.Duration(30) * time.Second) time.Sleep(time.Duration(30) * time.Second)
mongoClient, err1 = mongo.Connect(context.TODO(), options.Client().ApplyURI(uri)) mongoClient, err1 = mongo.Connect(context.TODO(), options.Client().ApplyURI(uri))
if err1 != nil { if err1 != nil {
log.NewError(" mongo.Connect retry failed, panic", err.Error(), uri) fmt.Println(" mongo.Connect retry failed, panic", err.Error(), uri)
panic(err1.Error()) panic(err1.Error())
} }
} }
log.NewInfo("0", utils.GetSelfFuncName(), "mongo driver client init success") fmt.Println("0", utils.GetSelfFuncName(), "mongo driver client init success")
DB.mongoClient = mongoClient DB.mongoClient = mongoClient
//mgoDailInfo := &mgo.DialInfo{ //mgoDailInfo := &mgo.DialInfo{

File diff suppressed because it is too large Load Diff

View File

@ -1,12 +1,34 @@
syntax = "proto3"; syntax = "proto3";
option go_package = "./rtc;rtc"; option go_package = "./rtc;rtc";
package rtc; package proto;
message CommonResp{ message CommonResp{
int32 errCode = 1; int32 errCode = 1;
string errMsg = 2; string errMsg = 2;
} }
message MsgData {
string sendID = 1;
string recvID = 2;
string groupID = 3;
string clientMsgID = 4;
string serverMsgID = 5;
int32 senderPlatformID = 6;
string senderNickname = 7;
string senderFaceURL = 8;
int32 sessionType = 9;
int32 msgFrom = 10;
int32 contentType = 11;
bytes content = 12;
uint32 seq = 14;
int64 sendTime = 15;
int64 createTime = 16;
int32 status = 17;
map<string, bool> options = 18;
OfflinePushInfo offlinePushInfo = 19;
}
message GroupInfo{ message GroupInfo{
string groupID = 1; string groupID = 1;
string groupName = 2; string groupName = 2;
@ -62,8 +84,136 @@ message GetJoinTokenResp{
string liveURL = 3; string liveURL = 3;
} }
service RtcService { message OfflinePushInfo{
rpc GetJoinToken(GetJoinTokenReq) returns(GetJoinTokenResp); string title = 1;
string desc = 2;
string ex = 3;
string iOSPushSound = 4;
bool iOSBadgeCount = 5;
}
message SignalReq {
oneof payload {
SignalInviteReq invite = 1;
SignalInviteInGroupReq inviteInGroup= 2;
SignalCancelReq cancel = 3;
SignalAcceptReq accept = 4;
SignalHungUpReq hungUp = 5;
SignalRejectReq reject = 6;
}
}
message SignalResp {
oneof payload {
SignalInviteReply invite = 1;
SignalInviteInGroupReply inviteInGroup= 2;
SignalCancelReply cancel = 3;
SignalAcceptReply accept = 4;
SignalHungUpReply hungUp = 5;
SignalRejectReply reject = 6;
}
}
message InvitationInfo {
string inviterUserID = 1;
repeated string inviteeUserIDList = 2;
string customData = 3;
string groupID = 4;
string roomID = 5;
int32 timeout = 6;
string mediaType = 7;
int32 platformID = 8;
int32 sessionType = 9;
} }
message SignalInviteReq {
string opUserID = 1;
InvitationInfo invitation = 2;
OfflinePushInfo offlinePushInfo = 3;
ParticipantMetaData participant = 4;
}
message SignalInviteReply {
string token = 1;
string roomID = 2;
string liveURL = 3;
}
message SignalInviteInGroupReq {
string opUserID = 1;
InvitationInfo invitation = 2;
OfflinePushInfo offlinePushInfo = 3;
ParticipantMetaData participant = 4;
}
message SignalInviteInGroupReply {
string token = 1;
string roomID = 2;
string liveURL = 3;
}
message SignalCancelReq {
string opUserID = 1;
InvitationInfo invitation = 2;
OfflinePushInfo offlinePushInfo = 3;
ParticipantMetaData participant = 4;
}
message SignalCancelReply {
}
message SignalAcceptReq {
string opUserID = 1;
InvitationInfo invitation = 2;
OfflinePushInfo offlinePushInfo = 3;
ParticipantMetaData participant = 4;
int32 opUserPlatformID = 5;
}
message SignalAcceptReply {
string token = 1;
string roomID = 2;
string liveURL = 3;
}
message SignalHungUpReq {
string opUserID = 1;
InvitationInfo invitation = 2;
OfflinePushInfo offlinePushInfo = 3;
}
message SignalHungUpReply {
}
message SignalRejectReq {
string opUserID = 1;
InvitationInfo invitation = 2;
OfflinePushInfo offlinePushInfo = 3;
ParticipantMetaData participant = 4;
int32 opUserPlatformID = 5;
}
message SignalRejectReply {
}
message SignalMessageAssembleReq {
SignalReq signalReq = 1;
string operationID = 2;
}
message SignalMessageAssembleResp {
CommonResp commonResp = 1;
bool isPass = 2;
SignalResp signalResp = 3;
MsgData msgData = 4;
}
service RtcService {
rpc SignalMessageAssemble(SignalMessageAssembleReq) returns(SignalMessageAssembleResp);
}

View File

@ -24,8 +24,15 @@ begin_path=$PWD
for ((i = 0; i < ${#service_source_root[*]}; i++)); do for ((i = 0; i < ${#service_source_root[*]}; i++)); do
cd $begin_path cd $begin_path
service_path=${service_source_root[$i]} service_path=${service_source_root[$i]}
cd $service_path && echo -e "${SKY_BLUE_PREFIX}Current directory: $PWD $COLOR_SUFFIX" cd $service_path
make install && echo -e "${SKY_BLUE_PREFIX}build ${service_names[$i]} success,moving binary file to the bin directory${COLOR_SUFFIX}" && make install
echo -e "${SKY_BLUE_PREFIX}Successful moved ${service_names[$i]} to the bin directory${COLOR_SUFFIX}\n" if [ $? -ne 0 ]; then
echo -e "${RED_PREFIX}${service_names[$i]} build failed ${COLOR_SUFFIX}\n"
exit -1
else
echo -e "${GREEN_PREFIX}${service_names[$i]} successfully be built ${COLOR_SUFFIX}\n"
fi
done done
echo -e ${YELLOW_PREFIX}"all services build success"${COLOR_SUFFIX} echo -e ${YELLOW_PREFIX}"all services build success"${COLOR_SUFFIX}

View File

@ -9,14 +9,20 @@ need_to_start_server_shell=(
push_start.sh push_start.sh
msg_transfer_start.sh msg_transfer_start.sh
sdk_svr_start.sh sdk_svr_start.sh
timer_start.sh
demo_svr_start.sh demo_svr_start.sh
) )
#fixme The 10 second delay to start the project is for the docker-compose one-click to start openIM when the infrastructure dependencies are not started #fixme The 10 second delay to start the project is for the docker-compose one-click to start openIM when the infrastructure dependencies are not started
sleep 10 sleep 10
time=`date +"%Y-%m-%d %H:%M:%S"`
echo "==========================================================">>../logs/openIM.log 2>&1 &
echo "==========================================================">>../logs/openIM.log 2>&1 &
echo "==========================================================">>../logs/openIM.log 2>&1 &
echo "==========server start time:${time}===========">>../logs/openIM.log 2>&1 &
echo "==========================================================">>../logs/openIM.log 2>&1 &
echo "==========================================================">>../logs/openIM.log 2>&1 &
echo "==========================================================">>../logs/openIM.log 2>&1 &
for i in ${need_to_start_server_shell[*]}; do for i in ${need_to_start_server_shell[*]}; do
chmod +x $i chmod +x $i
./$i ./$i

View File

@ -1,12 +1,36 @@
#!/usr/bin/env bash #!/usr/bin/env bash
source ./style_info.cfg source ./style_info.cfg
echo -e "check environment......................................."
echo -e "check login user........................................"
user=`whoami`
if [ $user == "root" ] ; then
echo -e ${GREEN_PREFIX} "ok: login user is root" ${COLOR_SUFFIX}
else
echo -e ${RED_PREFIX}"Warning: The current user is not root "${COLOR_SUFFIX}
fi
echo -e "check docker............................................"
docker_running=`systemctl status docker | grep running | grep active | wc -l`
docker_version=`docker-compose -v; docker -v`
if [ $docker_running -gt 0 ]; then
echo -e ${GREEN_PREFIX} "ok: docker is running" ${COLOR_SUFFIX}
echo -e ${GREEN_PREFIX} $docker_version ${COLOR_SUFFIX}
else
echo -e ${RED_PREFIX}"docker not running"${COLOR_SUFFIX}
fi
echo -e "check environment......................................."
SYSTEM=`uname -s` SYSTEM=`uname -s`
if [ $SYSTEM != "Linux" ] ; then if [ $SYSTEM != "Linux" ] ; then
echo -e ${RED_PREFIX}"Warning: Currently only Linux is supported"${COLOR_SUFFIX} echo -e ${RED_PREFIX}"Warning: Currently only Linux is supported"${COLOR_SUFFIX}
else else
echo -e ${GREEN_PREFIX} "Linux system is ok"${COLOR_SUFFIX} echo -e ${GREEN_PREFIX} "ok: system is linux"${COLOR_SUFFIX}
fi fi
echo -e "check memory............................................" echo -e "check memory............................................"
@ -15,5 +39,5 @@ if [ $available -lt 2000 ] ; then
echo -e ${RED_PREFIX}"Warning: Your memory not enough, available is: " "$available"m${COLOR_SUFFIX}"\c" echo -e ${RED_PREFIX}"Warning: Your memory not enough, available is: " "$available"m${COLOR_SUFFIX}"\c"
echo -e ${RED_PREFIX}", must be greater than 2000m"${COLOR_SUFFIX} echo -e ${RED_PREFIX}", must be greater than 2000m"${COLOR_SUFFIX}
else else
echo -e ${GREEN_PREFIX} "Memory is ok, available is: "$available"m${COLOR_SUFFIX}" echo -e ${GREEN_PREFIX} "ok: available memory is: "$available"m${COLOR_SUFFIX}"
fi fi

View File

@ -14,7 +14,7 @@ ws_ports=($ports_array)
if [ ${#rpc_ports[@]} -ne ${#ws_ports[@]} ]; then if [ ${#rpc_ports[@]} -ne ${#ws_ports[@]} ]; then
echo -e ${RED_PREFIX}"ws_ports does not match push_rpc_ports in quantity!!!"${COLOR_SUFFIX} echo -e ${RED_PREFIX}"ws_ports does not match push_rpc_ports in quantity!!!"${COLOR_SUFFIX}
exit 0 exit -1
fi fi
#Check if the service exists #Check if the service exists

View File

@ -11,8 +11,19 @@ need_to_start_server_shell=(
sdk_svr_start.sh sdk_svr_start.sh
demo_svr_start.sh demo_svr_start.sh
) )
time=`date +"%Y-%m-%d %H:%M:%S"`
echo "==========================================================">>../logs/openIM.log 2>&1 &
echo "==========================================================">>../logs/openIM.log 2>&1 &
echo "==========================================================">>../logs/openIM.log 2>&1 &
echo "==========server start time:${time}===========">>../logs/openIM.log 2>&1 &
echo "==========================================================">>../logs/openIM.log 2>&1 &
echo "==========================================================">>../logs/openIM.log 2>&1 &
echo "==========================================================">>../logs/openIM.log 2>&1 &
for i in ${need_to_start_server_shell[*]}; do for i in ${need_to_start_server_shell[*]}; do
chmod +x $i chmod +x $i
./$i ./$i
if [ $? -ne 0 ]; then
exit -1
fi
done done

View File

@ -45,24 +45,23 @@ for ((i = 0; i < ${#service_filename[*]}; i++)); do
if [ $(eval ${count}) -gt 0 ]; then if [ $(eval ${count}) -gt 0 ]; then
pid="${service_name}| awk '{print \$2}'" pid="${service_name}| awk '{print \$2}'"
echo -e "${SKY_BLUE_PREFIX}${service_filename[$i]} service has been started,pid:$(eval $pid)$COLOR_SUFFIX" echo "${service_filename[$i]} service has been started,pid:$(eval $pid)"
echo -e "${SKY_BLUE_PREFIX}Killing the service ${service_filename[$i]} pid:$(eval $pid)${COLOR_SUFFIX}" echo "killing the service ${service_filename[$i]} pid:$(eval $pid)"
#kill the service that existed #kill the service that existed
kill -9 $(eval $pid) kill -9 $(eval $pid)
sleep 0.5 sleep 0.5
fi fi
cd ../bin && echo -e "${SKY_BLUE_PREFIX}${service_filename[$i]} service is starting${COLOR_SUFFIX}" cd ../bin
#Get the rpc port in the configuration file #Get the rpc port in the configuration file
portList=$(cat $config_path | grep ${service_port_name[$i]} | awk -F '[:]' '{print $NF}') portList=$(cat $config_path | grep ${service_port_name[$i]} | awk -F '[:]' '{print $NF}')
list_to_string ${portList} list_to_string ${portList}
#Start related rpc services based on the number of ports #Start related rpc services based on the number of ports
for j in ${ports_array}; do for j in ${ports_array}; do
echo -e "${SKY_BLUE_PREFIX}${service_filename[$i]} Service is starting,port number:$j $COLOR_SUFFIX"
#Start the service in the background #Start the service in the background
# ./${service_filename[$i]} -port $j & # ./${service_filename[$i]} -port $j &
nohup ./${service_filename[$i]} -port $j >>../logs/openIM.log 2>&1 & nohup ./${service_filename[$i]} -port $j >>../logs/openIM.log 2>&1 &
sleep 1 sleep 1
pid="netstat -ntlp|grep $j |awk '{printf \$7}'|cut -d/ -f1" pid="netstat -ntlp|grep $j |awk '{printf \$7}'|cut -d/ -f1"
echo -e "${RED_PREFIX}${service_filename[$i]} Service is started,port number:$j pid:$(eval $pid)$COLOR_SUFFIX" echo -e "${GREEN_PREFIX}${service_filename[$i]} start success,port number:$j pid:$(eval $pid)$COLOR_SUFFIX"
done done
done done