commit
d626d6b42f
@ -1,2 +1,9 @@
|
||||
bin
|
||||
logs
|
||||
.devcontainer
|
||||
components
|
||||
logs
|
||||
out-test
|
||||
.github
|
||||
|
||||
tmp
|
||||
|
@ -0,0 +1,41 @@
|
||||
|
||||
apps:
|
||||
- name: open_im_api
|
||||
script: "go run main.go"
|
||||
cwd: "cmd/open_im_api"
|
||||
|
||||
- name: open_im_auth
|
||||
script: "go run main.go"
|
||||
cwd: "cmd/rpc/open_im_auth"
|
||||
|
||||
- name: open_im_offline_msg
|
||||
script: "go run main.go"
|
||||
cwd: "cmd/rpc/open_im_msg"
|
||||
|
||||
- name: open_im_friend
|
||||
script: "go run main.go"
|
||||
cwd: "cmd/rpc/open_im_friend"
|
||||
|
||||
- name: open_im_group
|
||||
script: "go run main.go"
|
||||
cwd: "cmd/rpc/open_im_group"
|
||||
|
||||
- name: open_im_user
|
||||
script: "go run main.go"
|
||||
cwd: "cmd/rpc/open_im_user"
|
||||
|
||||
- name: open_im_push
|
||||
script: "go run main.go"
|
||||
cwd: "cmd/open_im_push"
|
||||
|
||||
- name: open_im_timed_task
|
||||
script: "go run main.go"
|
||||
cwd: "cmd/open_im_timer_task"
|
||||
|
||||
- name: open_im_msg_transfer
|
||||
script: "go run main.go"
|
||||
cwd: "cmd/open_im_msg_transfer"
|
||||
|
||||
- name: open_im_msg_gateway
|
||||
script: "go run main.go"
|
||||
cwd: "cmd/open_im_msg_gateway"
|
@ -0,0 +1 @@
|
||||
Subproject commit a85c10dbffbb797b5b2091e209ff67a5534b9bfc
|
@ -1,42 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/db"
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
func main() {
|
||||
for {
|
||||
fmt.Println("start delete mongodb expired record")
|
||||
timeUnixBegin := time.Now().Unix()
|
||||
count, _ := db.DB.MgoUserCount()
|
||||
fmt.Println("mongodb record count: ", count)
|
||||
for i := 0; i < count; i++ {
|
||||
time.Sleep(1 * time.Millisecond)
|
||||
uid, _ := db.DB.MgoSkipUID(i)
|
||||
fmt.Println("operate uid: ", uid)
|
||||
err := db.DB.DelUserChat(uid)
|
||||
if err != nil {
|
||||
fmt.Println("operate uid failed: ", uid, err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
timeUnixEnd := time.Now().Unix()
|
||||
costTime := timeUnixEnd - timeUnixBegin
|
||||
if costTime > int64(config.Config.Mongo.DBRetainChatRecords*24*3600) {
|
||||
continue
|
||||
} else {
|
||||
sleepTime := 0
|
||||
if int64(config.Config.Mongo.DBRetainChatRecords*24*3600)-costTime > 24*3600 {
|
||||
sleepTime = 24 * 3600
|
||||
} else {
|
||||
sleepTime = config.Config.Mongo.DBRetainChatRecords*24*3600 - int(costTime)
|
||||
}
|
||||
fmt.Println("sleep: ", sleepTime)
|
||||
time.Sleep(time.Duration(sleepTime) * time.Second)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
.PHONY: all build run gotool install clean help
|
||||
|
||||
BINARY_NAME=open_im_timer_task
|
||||
BIN_DIR=../../bin/
|
||||
|
||||
all: gotool build
|
||||
|
||||
build:
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s"
|
||||
|
||||
run:
|
||||
@go run ./
|
||||
|
||||
gotool:
|
||||
go fmt ./
|
||||
go vet ./
|
||||
|
||||
install:
|
||||
make build
|
||||
mv ${BINARY_NAME} ${BIN_DIR}
|
||||
|
||||
clean:
|
||||
@if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
|
||||
|
||||
|
@ -0,0 +1,65 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
commonDB "Open_IM/pkg/common/db"
|
||||
"Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||
"Open_IM/pkg/common/log"
|
||||
"time"
|
||||
)
|
||||
|
||||
func main() {
|
||||
log.NewPrivateLog("timer")
|
||||
//for {
|
||||
// fmt.Println("start delete mongodb expired record")
|
||||
// timeUnixBegin := time.Now().Unix()
|
||||
// count, _ := db.DB.MgoUserCount()
|
||||
// fmt.Println("mongodb record count: ", count)
|
||||
// for i := 0; i < count; i++ {
|
||||
// time.Sleep(1 * time.Millisecond)
|
||||
// uid, _ := db.DB.MgoSkipUID(i)
|
||||
// fmt.Println("operate uid: ", uid)
|
||||
// err := db.DB.DelUserChat(uid)
|
||||
// if err != nil {
|
||||
// fmt.Println("operate uid failed: ", uid, err.Error())
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// timeUnixEnd := time.Now().Unix()
|
||||
// costTime := timeUnixEnd - timeUnixBegin
|
||||
// if costTime > int64(config.Config.Mongo.DBRetainChatRecords*24*3600) {
|
||||
// continue
|
||||
// } else {
|
||||
// sleepTime := 0
|
||||
// if int64(config.Config.Mongo.DBRetainChatRecords*24*3600)-costTime > 24*3600 {
|
||||
// sleepTime = 24 * 3600
|
||||
// } else {
|
||||
// sleepTime = config.Config.Mongo.DBRetainChatRecords*24*3600 - int(costTime)
|
||||
// }
|
||||
// fmt.Println("sleep: ", sleepTime)
|
||||
// time.Sleep(time.Duration(sleepTime) * time.Second)
|
||||
// }
|
||||
//}
|
||||
for {
|
||||
uidList, err := im_mysql_model.SelectAllUID()
|
||||
if err != nil {
|
||||
log.NewError("999999", err.Error())
|
||||
} else {
|
||||
for _, v := range uidList {
|
||||
minSeq, err := commonDB.DB.GetMinSeqFromMongo(v)
|
||||
if err != nil {
|
||||
log.NewError("999999", "get user minSeq err", err.Error(), v)
|
||||
continue
|
||||
} else {
|
||||
err := commonDB.DB.SetUserMinSeq(v, minSeq)
|
||||
if err != nil {
|
||||
log.NewError("999999", "set user minSeq err", err.Error(), v)
|
||||
}
|
||||
}
|
||||
time.Sleep(time.Duration(100) * time.Millisecond)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,147 @@
|
||||
|
||||
# The class cannot be named by Pascal or camel case.
|
||||
# If it is not used, the corresponding structure will not be set,
|
||||
# and it will not be read naturally.
|
||||
serverversion: 1.0.0
|
||||
#---------------Infrastructure configuration---------------------#
|
||||
etcd:
|
||||
etcdSchema: openIM
|
||||
etcdAddr: [ etcd:2379 ]
|
||||
|
||||
mysql:
|
||||
dbMysqlAddress: [ mysql:3306 ]
|
||||
dbMysqlUserName: root
|
||||
dbMysqlPassword: openIM
|
||||
dbMysqlDatabaseName: openIM
|
||||
dbTableName: eMsg
|
||||
dbMsgTableNum: 1
|
||||
dbMaxOpenConns: 20
|
||||
dbMaxIdleConns: 10
|
||||
dbMaxLifeTime: 120
|
||||
|
||||
mongo:
|
||||
dbAddress: [ mongodb:27017 ]
|
||||
dbDirect: false
|
||||
dbTimeout: 10
|
||||
dbDatabase: openIM
|
||||
dbSource: admin
|
||||
dbUserName:
|
||||
dbPassword:
|
||||
dbMaxPoolSize: 20
|
||||
dbRetainChatRecords: 7
|
||||
|
||||
redis:
|
||||
dbAddress: redis:6379
|
||||
dbMaxIdle: 128
|
||||
dbMaxActive: 0
|
||||
dbIdleTimeout: 120
|
||||
dbPassWord: openIM
|
||||
|
||||
kafka:
|
||||
ws2mschat:
|
||||
addr: [ kafka:9092 ]
|
||||
topic: "ws2ms_chat"
|
||||
ms2pschat:
|
||||
addr: [ kafka:9092 ]
|
||||
topic: "ms2ps_chat"
|
||||
consumergroupid:
|
||||
msgToMongo: mongo
|
||||
msgToMySql: mysql
|
||||
msgToPush: push
|
||||
|
||||
|
||||
|
||||
#---------------Internal service configuration---------------------#
|
||||
|
||||
# The service ip default is empty,
|
||||
# automatically obtain the machine's valid network card ip as the service ip,
|
||||
# otherwise the configuration ip is preferred
|
||||
serverip:
|
||||
|
||||
api:
|
||||
openImApiPort: [ 10000 ]
|
||||
sdk:
|
||||
openImSdkWsPort: [ 30000 ]
|
||||
|
||||
credential:
|
||||
tencent:
|
||||
appID: 1302656840
|
||||
region: ap-chengdu
|
||||
bucket: echat-1302656840
|
||||
secretID: AKIDGNYVChzIQinu7QEgtNp0hnNgqcV8vZTC
|
||||
secretKey: kz15vW83qM6dBUWIq681eBZA0c0vlIbe
|
||||
|
||||
|
||||
rpcport:
|
||||
openImUserPort: [ 10100 ]
|
||||
openImFriendPort: [ 10200 ]
|
||||
openImOfflineMessagePort: [ 10300 ]
|
||||
openImOnlineRelayPort: [ 10400 ]
|
||||
openImGroupPort: [ 10500 ]
|
||||
openImAuthPort: [ 10600 ]
|
||||
openImPushPort: [ 10700 ]
|
||||
|
||||
|
||||
rpcregistername:
|
||||
openImUserName: User
|
||||
openImFriendName: Friend
|
||||
openImOfflineMessageName: OfflineMessage
|
||||
openImPushName: Push
|
||||
openImOnlineMessageRelayName: OnlineMessageRelay
|
||||
openImGroupName: Group
|
||||
openImAuthName: Auth
|
||||
|
||||
log:
|
||||
storageLocation: ../logs/
|
||||
rotationTime: 24
|
||||
remainRotationCount: 5
|
||||
remainLogLevel: 6
|
||||
elasticSearchSwitch: false
|
||||
elasticSearchAddr: [ 127.0.0.1:9201 ]
|
||||
elasticSearchUser: ""
|
||||
elasticSearchPassword: ""
|
||||
|
||||
modulename:
|
||||
longConnSvrName: msg_gateway
|
||||
msgTransferName: msg_transfer
|
||||
pushName: push
|
||||
|
||||
longconnsvr:
|
||||
openImWsPort: [ 17778 ]
|
||||
websocketMaxConnNum: 10000
|
||||
websocketMaxMsgLen: 4096
|
||||
websocketTimeOut: 10
|
||||
|
||||
push:
|
||||
tpns:
|
||||
ios:
|
||||
accessID: 1600018281
|
||||
secretKey: 3cd68a77a95b89e5089a1aca523f318f
|
||||
android:
|
||||
accessID: 111
|
||||
secretKey: 111
|
||||
jpns:
|
||||
appKey: 2783339cee4de379cc798fe1
|
||||
masterSecret: 66e5f309e032c68cc668c28a
|
||||
pushUrl: "https://api.jpush.cn/v3/push"
|
||||
manager:
|
||||
appManagerUid: ["openIM123456","openIM654321"]
|
||||
secrets: ["openIM1","openIM2"]
|
||||
|
||||
secret: tuoyun
|
||||
|
||||
multiloginpolicy:
|
||||
onlyOneTerminalAccess: false
|
||||
mobileAndPCTerminalAccessButOtherTerminalKickEachOther: true
|
||||
allTerminalAccess: false
|
||||
|
||||
#token config
|
||||
tokenpolicy:
|
||||
accessSecret: "open_im_server"
|
||||
# Token effective time seconds as a unit
|
||||
#Seven days 7*24*60*60
|
||||
accessExpire: 604800
|
||||
|
||||
messagecallback:
|
||||
callbackSwitch: false
|
||||
callbackUrl: "http://www.xxx.com/msg/judge"
|
@ -0,0 +1,11 @@
|
||||
FROM golang:1.16 as base
|
||||
|
||||
FROM base as dev
|
||||
|
||||
ENV GO111MODULE=on
|
||||
ENV GOPROXY=https://goproxy.cn,direct
|
||||
|
||||
|
||||
RUN curl -sSfL https://raw.githubusercontent.com/cosmtrek/air/master/install.sh | sh -s -- -b $(go env GOPATH)/bin
|
||||
|
||||
CMD ["air"]
|
@ -0,0 +1,381 @@
|
||||
version: "3"
|
||||
services:
|
||||
mysql:
|
||||
image: mysql:5.7
|
||||
ports:
|
||||
- 3306:3306
|
||||
container_name: mysql
|
||||
volumes:
|
||||
- ./components/mysql/data:/var/lib/mysql
|
||||
- /etc/localtime:/etc/localtime
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: openIM
|
||||
restart: always
|
||||
|
||||
mongodb:
|
||||
image: mongo:4.0
|
||||
ports:
|
||||
- 27017:27017
|
||||
container_name: mongo
|
||||
volumes:
|
||||
- ./components/mongodb/data:/data/db
|
||||
environment:
|
||||
TZ: Asia/Shanghai
|
||||
restart: always
|
||||
|
||||
redis:
|
||||
image: redis
|
||||
ports:
|
||||
- 6379:6379
|
||||
container_name: redis
|
||||
volumes:
|
||||
- ./components/redis/data:/data
|
||||
#redis config file
|
||||
#- ./components/redis/config/redis.conf:/usr/local/redis/config/redis.conf
|
||||
environment:
|
||||
TZ: Asia/Shanghai
|
||||
restart: always
|
||||
sysctls:
|
||||
net.core.somaxconn: 1024
|
||||
command: redis-server --requirepass openIM --appendonly yes
|
||||
|
||||
|
||||
zookeeper:
|
||||
image: wurstmeister/zookeeper
|
||||
ports:
|
||||
- 2181:2181
|
||||
container_name: zookeeper
|
||||
volumes:
|
||||
- /etc/localtime:/etc/localtime
|
||||
environment:
|
||||
TZ: Asia/Shanghai
|
||||
restart: always
|
||||
|
||||
|
||||
kafka:
|
||||
image: wurstmeister/kafka
|
||||
container_name: kafka
|
||||
restart: always
|
||||
environment:
|
||||
TZ: Asia/Shanghai
|
||||
KAFKA_BROKER_ID: 0
|
||||
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
|
||||
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092
|
||||
KAFKA_LISTENERS: PLAINTEXT://kafka:9092
|
||||
depends_on:
|
||||
- zookeeper
|
||||
links:
|
||||
- zookeeper
|
||||
ports:
|
||||
- 9092:9092
|
||||
|
||||
etcd:
|
||||
image: quay.io/coreos/etcd
|
||||
ports:
|
||||
- 2379:2379
|
||||
- 2380:2380
|
||||
container_name: etcd
|
||||
volumes:
|
||||
- /etc/timezone:/etc/timezone
|
||||
- /etc/localtime:/etc/localtime
|
||||
environment:
|
||||
ETCDCTL_API: 3
|
||||
restart: always
|
||||
command: /usr/local/bin/etcd --name etcd0 --data-dir /etcd-data --listen-client-urls http://0.0.0.0:2379 --advertise-client-urls http://0.0.0.0:2379 --listen-peer-urls http://0.0.0.0:2380 --initial-advertise-peer-urls http://0.0.0.0:2380 --initial-cluster etcd0=http://0.0.0.0:2380 --initial-cluster-token tkn --initial-cluster-state new
|
||||
|
||||
open_im_api:
|
||||
build:
|
||||
dockerfile: dev.Dockerfile
|
||||
context: .
|
||||
target: dev
|
||||
network: host
|
||||
depends_on:
|
||||
- kafka
|
||||
- mysql
|
||||
- mongodb
|
||||
- redis
|
||||
- etcd
|
||||
container_name: open_im_api
|
||||
volumes:
|
||||
- ./cmd:/Open-IM-Server/cmd
|
||||
- ./config/config.dev.yaml:/Open-IM-Server/config/config.yaml
|
||||
- ./internal:/Open-IM-Server/internal
|
||||
- ./pkg:/Open-IM-Server/pkg
|
||||
- ./go.mod:/Open-IM-Server/go.mod
|
||||
- ./go.sum:/Open-IM-Server/go.sum
|
||||
working_dir: /Open-IM-Server/cmd/open_im_api
|
||||
ports:
|
||||
- 10000:10000
|
||||
links:
|
||||
- kafka
|
||||
- mysql
|
||||
- mongodb
|
||||
- redis
|
||||
- etcd
|
||||
|
||||
open_im_auth:
|
||||
build:
|
||||
dockerfile: dev.Dockerfile
|
||||
context: .
|
||||
target: dev
|
||||
network: host
|
||||
depends_on:
|
||||
- kafka
|
||||
- mysql
|
||||
- mongodb
|
||||
- redis
|
||||
- etcd
|
||||
links:
|
||||
- kafka
|
||||
- mysql
|
||||
- mongodb
|
||||
- redis
|
||||
- etcd
|
||||
container_name: open_im_auth
|
||||
volumes:
|
||||
- ./cmd:/Open-IM-Server/cmd
|
||||
- ./config/config.dev.yaml:/Open-IM-Server/config/config.yaml
|
||||
- ./internal:/Open-IM-Server/internal
|
||||
- ./pkg:/Open-IM-Server/pkg
|
||||
- ./go.mod:/Open-IM-Server/go.mod
|
||||
- ./go.sum:/Open-IM-Server/go.sum
|
||||
working_dir: /Open-IM-Server/cmd/rpc/open_im_auth
|
||||
ports:
|
||||
- 10600:10600
|
||||
|
||||
open_im_user:
|
||||
build:
|
||||
dockerfile: dev.Dockerfile
|
||||
context: .
|
||||
target: dev
|
||||
network: host
|
||||
depends_on:
|
||||
- kafka
|
||||
- mysql
|
||||
- mongodb
|
||||
- redis
|
||||
- etcd
|
||||
links:
|
||||
- kafka
|
||||
- mysql
|
||||
- mongodb
|
||||
- redis
|
||||
- etcd
|
||||
container_name: open_im_user
|
||||
volumes:
|
||||
- ./cmd:/Open-IM-Server/cmd
|
||||
- ./config/config.dev.yaml:/Open-IM-Server/config/config.yaml
|
||||
- ./internal:/Open-IM-Server/internal
|
||||
- ./pkg:/Open-IM-Server/pkg
|
||||
- ./go.mod:/Open-IM-Server/go.mod
|
||||
- ./go.sum:/Open-IM-Server/go.sum
|
||||
working_dir: /Open-IM-Server/cmd/rpc/open_im_user
|
||||
ports:
|
||||
- 10100:10100
|
||||
|
||||
open_im_friend:
|
||||
build:
|
||||
dockerfile: dev.Dockerfile
|
||||
context: .
|
||||
target: dev
|
||||
network: host
|
||||
depends_on:
|
||||
- kafka
|
||||
- mysql
|
||||
- mongodb
|
||||
- redis
|
||||
- etcd
|
||||
links:
|
||||
- kafka
|
||||
- mysql
|
||||
- mongodb
|
||||
- redis
|
||||
- etcd
|
||||
container_name: open_im_friend
|
||||
volumes:
|
||||
- ./cmd:/Open-IM-Server/cmd
|
||||
- ./config/config.dev.yaml:/Open-IM-Server/config/config.yaml
|
||||
- ./internal:/Open-IM-Server/internal
|
||||
- ./pkg:/Open-IM-Server/pkg
|
||||
- ./go.mod:/Open-IM-Server/go.mod
|
||||
- ./go.sum:/Open-IM-Server/go.sum
|
||||
working_dir: /Open-IM-Server/cmd/rpc/open_im_friend
|
||||
ports:
|
||||
- 10200:10200
|
||||
|
||||
open_im_group:
|
||||
build:
|
||||
dockerfile: dev.Dockerfile
|
||||
context: .
|
||||
target: dev
|
||||
network: host
|
||||
depends_on:
|
||||
- kafka
|
||||
- mysql
|
||||
- mongodb
|
||||
- redis
|
||||
- etcd
|
||||
links:
|
||||
- kafka
|
||||
- mysql
|
||||
- mongodb
|
||||
- redis
|
||||
- etcd
|
||||
container_name: open_im_group
|
||||
volumes:
|
||||
- ./cmd:/Open-IM-Server/cmd
|
||||
- ./config/config.dev.yaml:/Open-IM-Server/config/config.yaml
|
||||
- ./internal:/Open-IM-Server/internal
|
||||
- ./pkg:/Open-IM-Server/pkg
|
||||
- ./go.mod:/Open-IM-Server/go.mod
|
||||
- ./go.sum:/Open-IM-Server/go.sum
|
||||
working_dir: /Open-IM-Server/cmd/rpc/open_im_group
|
||||
ports:
|
||||
- 10500:10500
|
||||
|
||||
open_im_push:
|
||||
build:
|
||||
dockerfile: dev.Dockerfile
|
||||
context: .
|
||||
target: dev
|
||||
network: host
|
||||
depends_on:
|
||||
- kafka
|
||||
- mysql
|
||||
- mongodb
|
||||
- redis
|
||||
- etcd
|
||||
links:
|
||||
- kafka
|
||||
- mysql
|
||||
- mongodb
|
||||
- redis
|
||||
- etcd
|
||||
container_name: open_im_push
|
||||
volumes:
|
||||
- ./cmd:/Open-IM-Server/cmd
|
||||
- ./config/config.dev.yaml:/Open-IM-Server/config/config.yaml
|
||||
- ./internal:/Open-IM-Server/internal
|
||||
- ./pkg:/Open-IM-Server/pkg
|
||||
- ./go.mod:/Open-IM-Server/go.mod
|
||||
- ./go.sum:/Open-IM-Server/go.sum
|
||||
working_dir: /Open-IM-Server/cmd/open_im_push
|
||||
ports:
|
||||
- 10700:10700
|
||||
|
||||
open_im_timed_task:
|
||||
build:
|
||||
dockerfile: dev.Dockerfile
|
||||
context: .
|
||||
target: dev
|
||||
network: host
|
||||
depends_on:
|
||||
- kafka
|
||||
- mysql
|
||||
- mongodb
|
||||
- redis
|
||||
- etcd
|
||||
links:
|
||||
- kafka
|
||||
- mysql
|
||||
- mongodb
|
||||
- redis
|
||||
- etcd
|
||||
container_name: open_im_timed_task
|
||||
volumes:
|
||||
- ./cmd:/Open-IM-Server/cmd
|
||||
- ./config/config.dev.yaml:/Open-IM-Server/config/config.yaml
|
||||
- ./internal:/Open-IM-Server/internal
|
||||
- ./pkg:/Open-IM-Server/pkg
|
||||
- ./go.mod:/Open-IM-Server/go.mod
|
||||
- ./go.sum:/Open-IM-Server/go.sum
|
||||
working_dir: /Open-IM-Server/cmd/open_im_timer_task
|
||||
|
||||
open_im_offline_msg:
|
||||
build:
|
||||
dockerfile: dev.Dockerfile
|
||||
context: .
|
||||
target: dev
|
||||
network: host
|
||||
depends_on:
|
||||
- kafka
|
||||
- mysql
|
||||
- mongodb
|
||||
- redis
|
||||
- etcd
|
||||
links:
|
||||
- kafka
|
||||
- mysql
|
||||
- mongodb
|
||||
- redis
|
||||
- etcd
|
||||
container_name: open_im_offline_msg
|
||||
volumes:
|
||||
- ./cmd:/Open-IM-Server/cmd
|
||||
- ./config/config.dev.yaml:/Open-IM-Server/config/config.yaml
|
||||
- ./internal:/Open-IM-Server/internal
|
||||
- ./pkg:/Open-IM-Server/pkg
|
||||
- ./go.mod:/Open-IM-Server/go.mod
|
||||
- ./go.sum:/Open-IM-Server/go.sum
|
||||
working_dir: /Open-IM-Server/cmd/rpc/open_im_msg
|
||||
ports:
|
||||
- 10300:10300
|
||||
|
||||
open_im_msg_transfer:
|
||||
build:
|
||||
dockerfile: dev.Dockerfile
|
||||
context: .
|
||||
target: dev
|
||||
network: host
|
||||
depends_on:
|
||||
- kafka
|
||||
- mysql
|
||||
- mongodb
|
||||
- redis
|
||||
- etcd
|
||||
links:
|
||||
- kafka
|
||||
- mysql
|
||||
- mongodb
|
||||
- redis
|
||||
- etcd
|
||||
container_name: open_im_msg_transfer
|
||||
volumes:
|
||||
- ./cmd:/Open-IM-Server/cmd
|
||||
- ./config/config.dev.yaml:/Open-IM-Server/config/config.yaml
|
||||
- ./internal:/Open-IM-Server/internal
|
||||
- ./pkg:/Open-IM-Server/pkg
|
||||
- ./go.mod:/Open-IM-Server/go.mod
|
||||
- ./go.sum:/Open-IM-Server/go.sum
|
||||
working_dir: /Open-IM-Server/cmd/open_im_msg_transfer
|
||||
|
||||
open_im_msg_gateway:
|
||||
build:
|
||||
dockerfile: dev.Dockerfile
|
||||
context: .
|
||||
target: dev
|
||||
network: host
|
||||
depends_on:
|
||||
- kafka
|
||||
- mysql
|
||||
- mongodb
|
||||
- redis
|
||||
- etcd
|
||||
links:
|
||||
- kafka
|
||||
- mysql
|
||||
- mongodb
|
||||
- redis
|
||||
- etcd
|
||||
container_name: open_im_msg_gateway
|
||||
volumes:
|
||||
- ./cmd:/Open-IM-Server/cmd
|
||||
- ./config/config.dev.yaml:/Open-IM-Server/config/config.yaml
|
||||
- ./internal:/Open-IM-Server/internal
|
||||
- ./pkg:/Open-IM-Server/pkg
|
||||
- ./go.mod:/Open-IM-Server/go.mod
|
||||
- ./go.sum:/Open-IM-Server/go.sum
|
||||
working_dir: /Open-IM-Server/cmd/open_im_msg_gateway
|
||||
ports:
|
||||
- 10400:10400
|
||||
- 17778:17778
|
@ -0,0 +1,85 @@
|
||||
version: "3"
|
||||
services:
|
||||
mysql:
|
||||
image: mysql:5.7
|
||||
ports:
|
||||
- 3306:3306
|
||||
container_name: mysql
|
||||
volumes:
|
||||
- ./components/mysql/data:/var/lib/mysql
|
||||
- /etc/localtime:/etc/localtime
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: openIM
|
||||
restart: always
|
||||
|
||||
mongodb:
|
||||
image: mongo:4.0
|
||||
ports:
|
||||
- 27017:27017
|
||||
container_name: mongo
|
||||
volumes:
|
||||
- ./components/mongodb/data:/data/db
|
||||
environment:
|
||||
TZ: Asia/Shanghai
|
||||
restart: always
|
||||
|
||||
redis:
|
||||
image: redis
|
||||
ports:
|
||||
- 6379:6379
|
||||
container_name: redis
|
||||
volumes:
|
||||
- ./components/redis/data:/data
|
||||
#redis config file
|
||||
#- ./components/redis/config/redis.conf:/usr/local/redis/config/redis.conf
|
||||
environment:
|
||||
TZ: Asia/Shanghai
|
||||
restart: always
|
||||
sysctls:
|
||||
net.core.somaxconn: 1024
|
||||
command: redis-server --requirepass openIM --appendonly yes
|
||||
|
||||
|
||||
zookeeper:
|
||||
image: wurstmeister/zookeeper
|
||||
ports:
|
||||
- 2181:2181
|
||||
container_name: zookeeper
|
||||
volumes:
|
||||
- /etc/localtime:/etc/localtime
|
||||
environment:
|
||||
TZ: Asia/Shanghai
|
||||
restart: always
|
||||
|
||||
|
||||
kafka:
|
||||
image: wurstmeister/kafka
|
||||
container_name: kafka
|
||||
restart: always
|
||||
environment:
|
||||
TZ: Asia/Shanghai
|
||||
KAFKA_BROKER_ID: 0
|
||||
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
|
||||
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://127.0.0.1:9092
|
||||
KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9092
|
||||
# network_mode: "host"
|
||||
depends_on:
|
||||
- zookeeper
|
||||
links:
|
||||
- zookeeper
|
||||
ports:
|
||||
- 9092:9092
|
||||
|
||||
etcd:
|
||||
image: quay.io/coreos/etcd
|
||||
ports:
|
||||
- 2379:2379
|
||||
- 2380:2380
|
||||
container_name: etcd
|
||||
volumes:
|
||||
- /etc/timezone:/etc/timezone
|
||||
- /etc/localtime:/etc/localtime
|
||||
environment:
|
||||
ETCDCTL_API: 3
|
||||
restart: always
|
||||
command: /usr/local/bin/etcd --name etcd0 --data-dir /etcd-data --listen-client-urls http://0.0.0.0:2379 --advertise-client-urls http://0.0.0.0:2379 --listen-peer-urls http://0.0.0.0:2380 --initial-advertise-peer-urls http://0.0.0.0:2380 --initial-cluster etcd0=http://0.0.0.0:2380 --initial-cluster-token tkn --initial-cluster-state new
|
@ -0,0 +1,25 @@
|
||||
package apiAuth
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func init() {
|
||||
gin.SetMode(gin.TestMode)
|
||||
}
|
||||
|
||||
func Test_UserRegister(t *testing.T) {
|
||||
res := httptest.NewRecorder()
|
||||
c, _ := gin.CreateTestContext(res)
|
||||
c.Request, _ = http.NewRequest("POST", "/", bytes.NewBufferString(`{"secret": "tuoyun", "platform": 1, "uid": "3", "name": "1"}`))
|
||||
|
||||
UserRegister(c)
|
||||
|
||||
assert.Equal(t, res.Code, 200)
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func GetAuthorization(Appkey string, MasterSecret string) string {
|
||||
str := fmt.Sprintf("%s:%s", Appkey, MasterSecret)
|
||||
buf := []byte(str)
|
||||
Authorization := fmt.Sprintf("Basic %s", base64.StdEncoding.EncodeToString(buf))
|
||||
return Authorization
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
package push
|
||||
|
||||
import (
|
||||
"Open_IM/internal/push/jpush/common"
|
||||
"Open_IM/internal/push/jpush/requestBody"
|
||||
"Open_IM/pkg/common/config"
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type JPushResp struct {
|
||||
}
|
||||
|
||||
func JGAccountListPush(accounts []string, content, detailContent, platform string) ([]byte, error) {
|
||||
|
||||
var pf requestBody.Platform
|
||||
_ = pf.SetPlatform(platform)
|
||||
var au requestBody.Audience
|
||||
au.SetAlias(accounts)
|
||||
var no requestBody.Notification
|
||||
no.SetAlert(content)
|
||||
var me requestBody.Message
|
||||
me.SetMsgContent(detailContent)
|
||||
var po requestBody.PushObj
|
||||
po.SetPlatform(&pf)
|
||||
po.SetAudience(&au)
|
||||
po.SetNotification(&no)
|
||||
po.SetMessage(&me)
|
||||
|
||||
con, err := json.Marshal(po)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
client := &http.Client{}
|
||||
|
||||
req, err := http.NewRequest("POST", config.Config.Push.Jpns.PushUrl, bytes.NewBuffer(con))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req.Header.Set("Authorization", common.GetAuthorization(config.Config.Push.Jpns.AppKey, config.Config.Push.Jpns.MasterSecret))
|
||||
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
result, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
package requestBody
|
||||
|
||||
const (
|
||||
TAG = "tag"
|
||||
TAG_AND = "tag_and"
|
||||
TAG_NOT = "tag_not"
|
||||
ALIAS = "alias"
|
||||
REGISTRATION_ID = "registration_id"
|
||||
SEGMENT = "segment"
|
||||
ABTEST = "abtest"
|
||||
)
|
||||
|
||||
type Audience struct {
|
||||
Object interface{}
|
||||
audience map[string][]string
|
||||
}
|
||||
|
||||
func (a *Audience) set(key string, v []string) {
|
||||
if a.audience == nil {
|
||||
a.audience = make(map[string][]string)
|
||||
a.Object = a.audience
|
||||
}
|
||||
|
||||
//v, ok = this.audience[key]
|
||||
//if ok {
|
||||
// return
|
||||
//}
|
||||
a.audience[key] = v
|
||||
}
|
||||
|
||||
func (a *Audience) SetTag(tags []string) {
|
||||
a.set(TAG, tags)
|
||||
}
|
||||
|
||||
func (a *Audience) SetTagAnd(tags []string) {
|
||||
a.set(TAG_AND, tags)
|
||||
}
|
||||
|
||||
func (a *Audience) SetTagNot(tags []string) {
|
||||
a.set(TAG_NOT, tags)
|
||||
}
|
||||
|
||||
func (a *Audience) SetAlias(alias []string) {
|
||||
a.set(ALIAS, alias)
|
||||
}
|
||||
|
||||
func (a *Audience) SetRegistrationId(ids []string) {
|
||||
a.set(REGISTRATION_ID, ids)
|
||||
}
|
||||
|
||||
func (a *Audience) SetAll() {
|
||||
a.Object = "all"
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package requestBody
|
||||
|
||||
type Message struct {
|
||||
MsgContent string `json:"msg_content"`
|
||||
Title string `json:"title,omitempty"`
|
||||
ContentType string `json:"content_type,omitempty"`
|
||||
Extras map[string]interface{} `json:"extras,omitempty"`
|
||||
}
|
||||
|
||||
func (m *Message) SetMsgContent(c string) {
|
||||
m.MsgContent = c
|
||||
}
|
||||
|
||||
func (m *Message) SetTitle(t string) {
|
||||
m.Title = t
|
||||
}
|
||||
|
||||
func (m *Message) SetContentType(c string) {
|
||||
m.ContentType = c
|
||||
}
|
||||
|
||||
func (m *Message) SetExtras(key string, value interface{}) {
|
||||
if m.Extras == nil {
|
||||
m.Extras = make(map[string]interface{})
|
||||
}
|
||||
m.Extras[key] = value
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package requestBody
|
||||
|
||||
type Notification struct {
|
||||
Alert string `json:"alert,omitempty"`
|
||||
Android *Android `json:"android,omitempty"`
|
||||
IOS *Ios `json:"ios,omitempty"`
|
||||
}
|
||||
|
||||
type Android struct {
|
||||
}
|
||||
|
||||
type Ios struct {
|
||||
}
|
||||
|
||||
func (n *Notification) SetAlert(alert string) {
|
||||
n.Alert = alert
|
||||
}
|
@ -0,0 +1,83 @@
|
||||
package requestBody
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/utils"
|
||||
"errors"
|
||||
)
|
||||
|
||||
const (
|
||||
ANDROID = "android"
|
||||
IOS = "ios"
|
||||
QUICKAPP = "quickapp"
|
||||
WINDOWSPHONE = "winphone"
|
||||
ALL = "all"
|
||||
)
|
||||
|
||||
type Platform struct {
|
||||
Os interface{}
|
||||
osArry []string
|
||||
}
|
||||
|
||||
func (p *Platform) Set(os string) error {
|
||||
if p.Os == nil {
|
||||
p.osArry = make([]string, 0, 4)
|
||||
} else {
|
||||
switch p.Os.(type) {
|
||||
case string:
|
||||
return errors.New("platform is all")
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
for _, value := range p.osArry {
|
||||
if os == value {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
switch os {
|
||||
case IOS:
|
||||
fallthrough
|
||||
case ANDROID:
|
||||
fallthrough
|
||||
case QUICKAPP:
|
||||
fallthrough
|
||||
case WINDOWSPHONE:
|
||||
p.osArry = append(p.osArry, os)
|
||||
p.Os = p.osArry
|
||||
default:
|
||||
return errors.New("unknow platform")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
func (p *Platform) SetPlatform(platform string) error {
|
||||
switch platform {
|
||||
case utils.AndroidPlatformStr:
|
||||
return p.SetAndroid()
|
||||
case utils.IOSPlatformStr:
|
||||
return p.SetIOS()
|
||||
default:
|
||||
return errors.New("platform err")
|
||||
}
|
||||
|
||||
}
|
||||
func (p *Platform) SetIOS() error {
|
||||
return p.Set(IOS)
|
||||
}
|
||||
|
||||
func (p *Platform) SetAndroid() error {
|
||||
return p.Set(ANDROID)
|
||||
}
|
||||
|
||||
func (p *Platform) SetQuickApp() error {
|
||||
return p.Set(QUICKAPP)
|
||||
}
|
||||
|
||||
func (p *Platform) SetWindowsPhone() error {
|
||||
return p.Set(WINDOWSPHONE)
|
||||
}
|
||||
|
||||
func (p *Platform) SetAll() {
|
||||
p.Os = ALL
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package requestBody
|
||||
|
||||
type PushObj struct {
|
||||
Platform interface{} `json:"platform"`
|
||||
Audience interface{} `json:"audience"`
|
||||
Notification interface{} `json:"notification,omitempty"`
|
||||
Message interface{} `json:"message,omitempty"`
|
||||
}
|
||||
|
||||
func (p *PushObj) SetPlatform(pf *Platform) {
|
||||
p.Platform = pf.Os
|
||||
}
|
||||
|
||||
func (p *PushObj) SetAudience(ad *Audience) {
|
||||
p.Audience = ad.Object
|
||||
}
|
||||
|
||||
func (p *PushObj) SetNotification(no *Notification) {
|
||||
p.Notification = no
|
||||
}
|
||||
|
||||
func (p *PushObj) SetMessage(m *Message) {
|
||||
p.Message = m
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/utils"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func init() {
|
||||
gin.SetMode(gin.TestMode)
|
||||
}
|
||||
|
||||
func performRequest(r http.Handler, method, origin string) *httptest.ResponseRecorder {
|
||||
return performRequestWithHeaders(r, method, origin, http.Header{})
|
||||
}
|
||||
|
||||
func performRequestWithHeaders(r http.Handler, method, origin string, header http.Header) *httptest.ResponseRecorder {
|
||||
req, _ := http.NewRequest(method, "/", nil)
|
||||
// From go/net/http/request.go:
|
||||
// For incoming requests, the Host header is promoted to the
|
||||
// Request.Host field and removed from the Header map.
|
||||
req.Host = header.Get("Host")
|
||||
header.Del("Host")
|
||||
if len(origin) > 0 {
|
||||
header.Set("Origin", origin)
|
||||
}
|
||||
req.Header = header
|
||||
w := httptest.NewRecorder()
|
||||
r.ServeHTTP(w, req)
|
||||
return w
|
||||
}
|
||||
|
||||
func newTestRouter() *gin.Engine {
|
||||
router := gin.New()
|
||||
router.Use(utils.CorsHandler())
|
||||
router.GET("/", func(c *gin.Context) {
|
||||
c.String(http.StatusOK, "get")
|
||||
})
|
||||
router.POST("/", func(c *gin.Context) {
|
||||
c.String(http.StatusOK, "post")
|
||||
})
|
||||
router.PATCH("/", func(c *gin.Context) {
|
||||
c.String(http.StatusOK, "patch")
|
||||
})
|
||||
|
||||
return router
|
||||
}
|
||||
|
||||
func Test_CorsHandler(t *testing.T) {
|
||||
router := newTestRouter()
|
||||
// no CORS request, origin == ""
|
||||
w := performRequest(router, "GET", "")
|
||||
assert.Equal(t, "get", w.Body.String())
|
||||
assert.Equal(t, w.Header().Get("Access-Control-Allow-Origin"), "*")
|
||||
assert.Equal(t, w.Header().Get("Access-Control-Allow-Methods"), "*")
|
||||
assert.Equal(t, w.Header().Get("Access-Control-Allow-Headers"), "*")
|
||||
assert.Equal(t, w.Header().Get("Access-Control-Expose-Headers"), "Content-Length, Access-Control-Allow-Origin, Access-Control-Allow-Headers,Cache-Control,Content-Language,Content-Type,Expires,Last-Modified,Pragma,FooBar")
|
||||
assert.Equal(t, w.Header().Get("Access-Control-Max-Age"), "172800")
|
||||
assert.Equal(t, w.Header().Get("Access-Control-Allow-Credentials"), "false")
|
||||
assert.Equal(t, w.Header().Get("content-type"), "application/json")
|
||||
|
||||
w = performRequest(router, "OPTIONS", "")
|
||||
assert.Equal(t, w.Body.String(), "\"Options Request!\"")
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/utils"
|
||||
"net"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestServerIP(t *testing.T) {
|
||||
if net.ParseIP(utils.ServerIP) == nil {
|
||||
t.Fail()
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"github.com/bwmarrin/snowflake"
|
||||
)
|
||||
|
||||
func init() {
|
||||
var err error
|
||||
idGenerator, err = snowflake.NewNode(getNodeNum())
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func getNodeNum() int64 {
|
||||
return 1
|
||||
}
|
||||
|
||||
var idGenerator *snowflake.Node
|
||||
|
||||
func GenID() string {
|
||||
return idGenerator.Generate().String()
|
||||
}
|
||||
|
||||
func GenIDs(count int) []string {
|
||||
//impl
|
||||
return []string{}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package utils
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestGenID(t *testing.T) {
|
||||
m := map[string]struct{}{}
|
||||
for i := 0; i < 2000; i++ {
|
||||
got := GenID()
|
||||
if _, ok := m[got]; !ok {
|
||||
m[got] = struct{}{}
|
||||
} else {
|
||||
t.Error("id generate error", got)
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/utils"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
var (
|
||||
_, b, _, _ = runtime.Caller(0)
|
||||
// Root folder of this project
|
||||
Root = filepath.Join(filepath.Dir(b), "../..")
|
||||
)
|
||||
|
||||
func Test_GenSmallImage(t *testing.T) {
|
||||
println(Root)
|
||||
err := utils.GenSmallImage(Root+"/docs/open-im-logo.png", Root+"/out-test/open-im-logo-test.png")
|
||||
assert.Nil(t, err)
|
||||
|
||||
err = utils.GenSmallImage(Root+"/docs/open-im-logo.png", "out-test/open-im-logo-test.png")
|
||||
assert.Nil(t, err)
|
||||
|
||||
err = utils.GenSmallImage(Root+"/docs/Architecture.jpg", "out-test/Architecture-test.jpg")
|
||||
assert.Nil(t, err)
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/utils"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func Test_BuildClaims(t *testing.T) {
|
||||
uid := "1"
|
||||
platform := "PC"
|
||||
ttl := int64(-1)
|
||||
claim := utils.BuildClaims(uid, platform, ttl)
|
||||
now := time.Now().Unix()
|
||||
|
||||
assert.Equal(t, claim.UID, uid, "uid should equal")
|
||||
assert.Equal(t, claim.Platform, platform, "platform should equal")
|
||||
assert.Equal(t, claim.RegisteredClaims.ExpiresAt, int64(-1), "StandardClaims.ExpiresAt should be equal")
|
||||
// time difference within 1s
|
||||
assert.Equal(t, claim.RegisteredClaims.IssuedAt, now, "StandardClaims.IssuedAt should be equal")
|
||||
assert.Equal(t, claim.RegisteredClaims.NotBefore, now, "StandardClaims.NotBefore should be equal")
|
||||
|
||||
ttl = int64(60)
|
||||
now = time.Now().Unix()
|
||||
claim = utils.BuildClaims(uid, platform, ttl)
|
||||
// time difference within 1s
|
||||
assert.Equal(t, claim.RegisteredClaims.ExpiresAt, int64(60)+now, "StandardClaims.ExpiresAt should be equal")
|
||||
assert.Equal(t, claim.RegisteredClaims.IssuedAt, now, "StandardClaims.IssuedAt should be equal")
|
||||
assert.Equal(t, claim.RegisteredClaims.NotBefore, now, "StandardClaims.NotBefore should be equal")
|
||||
}
|
||||
|
||||
func Test_CreateToken(t *testing.T) {
|
||||
uid := "1"
|
||||
platform := int32(1)
|
||||
now := time.Now().Unix()
|
||||
|
||||
tokenString, expiresAt, err := utils.CreateToken(uid, platform)
|
||||
|
||||
assert.NotEmpty(t, tokenString)
|
||||
assert.Equal(t, expiresAt, 604800+now)
|
||||
assert.Nil(t, err)
|
||||
}
|
||||
|
||||
func Test_VerifyToken(t *testing.T) {
|
||||
uid := "1"
|
||||
platform := int32(1)
|
||||
tokenString, _, _ := utils.CreateToken(uid, platform)
|
||||
result := utils.VerifyToken(tokenString, uid)
|
||||
assert.True(t, result)
|
||||
result = utils.VerifyToken(tokenString, "2")
|
||||
assert.False(t, result)
|
||||
}
|
||||
|
||||
func Test_ParseRedisInterfaceToken(t *testing.T) {
|
||||
uid := "1"
|
||||
platform := int32(1)
|
||||
tokenString, _, _ := utils.CreateToken(uid, platform)
|
||||
|
||||
claims, err := utils.ParseRedisInterfaceToken([]uint8(tokenString))
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, claims.UID, uid)
|
||||
|
||||
// timeout
|
||||
config.Config.TokenPolicy.AccessExpire = -80
|
||||
tokenString, _, _ = utils.CreateToken(uid, platform)
|
||||
claims, err = utils.ParseRedisInterfaceToken([]uint8(tokenString))
|
||||
assert.Equal(t, err, utils.TokenExpired)
|
||||
assert.Nil(t, claims)
|
||||
}
|
||||
|
||||
func Test_ParseToken(t *testing.T) {
|
||||
uid := "1"
|
||||
platform := int32(1)
|
||||
tokenString, _, _ := utils.CreateToken(uid, platform)
|
||||
claims, err := utils.ParseToken(tokenString)
|
||||
if err == nil {
|
||||
assert.Equal(t, claims.UID, uid)
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/utils"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func Test_Md5(t *testing.T) {
|
||||
result := utils.Md5("go")
|
||||
assert.Equal(t, result, "34d1f91fb2e514b8576fab1a75a89a6b")
|
||||
|
||||
result2 := utils.Md5("go")
|
||||
assert.Equal(t, result, result2)
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/utils"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func Test_PlatformIDToName(t *testing.T) {
|
||||
assert.Equal(t, utils.PlatformIDToName(1), "IOS")
|
||||
assert.Equal(t, utils.PlatformIDToName(2), "Android")
|
||||
assert.Equal(t, utils.PlatformIDToName(3), "Windows")
|
||||
assert.Equal(t, utils.PlatformIDToName(4), "OSX")
|
||||
assert.Equal(t, utils.PlatformIDToName(5), "Web")
|
||||
assert.Equal(t, utils.PlatformIDToName(6), "MiniWeb")
|
||||
assert.Equal(t, utils.PlatformIDToName(7), "Linux")
|
||||
|
||||
assert.Equal(t, utils.PlatformIDToName(0), "")
|
||||
}
|
||||
|
||||
func Test_PlatformNameToID(t *testing.T) {
|
||||
assert.Equal(t, utils.PlatformNameToID("IOS"), int32(1))
|
||||
assert.Equal(t, utils.PlatformNameToID("Android"), int32(2))
|
||||
assert.Equal(t, utils.PlatformNameToID("Windows"), int32(3))
|
||||
assert.Equal(t, utils.PlatformNameToID("OSX"), int32(4))
|
||||
assert.Equal(t, utils.PlatformNameToID("Web"), int32(5))
|
||||
assert.Equal(t, utils.PlatformNameToID("MiniWeb"), int32(6))
|
||||
assert.Equal(t, utils.PlatformNameToID("Linux"), int32(7))
|
||||
|
||||
assert.Equal(t, utils.PlatformNameToID("UnknownDevice"), int32(0))
|
||||
assert.Equal(t, utils.PlatformNameToID(""), int32(0))
|
||||
}
|
||||
|
||||
func Test_PlatformNameToClass(t *testing.T) {
|
||||
assert.Equal(t, utils.PlatformNameToClass("IOS"), "Mobile")
|
||||
assert.Equal(t, utils.PlatformNameToClass("Android"), "Mobile")
|
||||
assert.Equal(t, utils.PlatformNameToClass("OSX"), "PC")
|
||||
assert.Equal(t, utils.PlatformNameToClass("Windows"), "PC")
|
||||
assert.Equal(t, utils.PlatformNameToClass("Web"), "PC")
|
||||
assert.Equal(t, utils.PlatformNameToClass("MiniWeb"), "Mobile")
|
||||
assert.Equal(t, utils.PlatformNameToClass("Linux"), "PC")
|
||||
|
||||
assert.Equal(t, utils.PlatformNameToClass("UnknownDevice"), "")
|
||||
assert.Equal(t, utils.PlatformNameToClass(""), "")
|
||||
}
|
@ -0,0 +1,108 @@
|
||||
/*
|
||||
** description("Send logs to elasticsearch hook").
|
||||
** copyright('tuoyun,www.tuoyun.net').
|
||||
** author("fg,Gordon@tuoyun.net").
|
||||
** time(2021/3/26 17:05).
|
||||
*/
|
||||
package log
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"context"
|
||||
"fmt"
|
||||
elasticV7 "github.com/olivere/elastic/v7"
|
||||
"github.com/sirupsen/logrus"
|
||||
"log"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
//esHook CUSTOMIZED ES hook
|
||||
type esHook struct {
|
||||
moduleName string
|
||||
client *elasticV7.Client
|
||||
}
|
||||
|
||||
//newEsHook Initialization
|
||||
func newEsHook(moduleName string) *esHook {
|
||||
//https://github.com/sohlich/elogrus
|
||||
//client, err := elastic.NewClient(elastic.SetURL("http://localhost:9200"))
|
||||
//if err != nil {
|
||||
// log.Panic(err)
|
||||
//}
|
||||
//hook, err := elogrus.NewAsyncElasticHook(client, "localhost", logrus.DebugLevel, "mylog")
|
||||
//if err != nil {
|
||||
// log.Panic(err)
|
||||
//}
|
||||
es, err := elasticV7.NewClient(
|
||||
elasticV7.SetURL(config.Config.Log.ElasticSearchAddr...),
|
||||
elasticV7.SetBasicAuth(config.Config.Log.ElasticSearchUser, config.Config.Log.ElasticSearchPassword),
|
||||
elasticV7.SetSniff(false),
|
||||
elasticV7.SetHealthcheckInterval(60*time.Second),
|
||||
elasticV7.SetErrorLog(log.New(os.Stderr, "ES:", log.LstdFlags)),
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
log.Fatal("failed to create Elastic V7 Client: ", err)
|
||||
}
|
||||
|
||||
//info, code, err := es.Ping(logConfig.ElasticSearch.EsAddr[0]).Do(context.Background())
|
||||
//if err != nil {
|
||||
// panic(err)
|
||||
//}
|
||||
//fmt.Printf("Elasticsearch returned with code %d and version %s\n", code, info.Version.Number)
|
||||
//
|
||||
//esversion, err := es.ElasticsearchVersion(logConfig.ElasticSearch.EsAddr[0])
|
||||
//if err != nil {
|
||||
// panic(err)
|
||||
//}
|
||||
//fmt.Printf("Elasticsearch version %s\n", esversion)
|
||||
return &esHook{client: es, moduleName: moduleName}
|
||||
}
|
||||
|
||||
//Fire log hook interface 方法
|
||||
func (hook *esHook) Fire(entry *logrus.Entry) error {
|
||||
doc := newEsLog(entry)
|
||||
go hook.sendEs(doc)
|
||||
return nil
|
||||
}
|
||||
|
||||
//Levels log hook interface 方法,此hook影响的日志
|
||||
func (hook *esHook) Levels() []logrus.Level {
|
||||
return logrus.AllLevels
|
||||
}
|
||||
|
||||
//sendEs 异步发送日志到es
|
||||
func (hook *esHook) sendEs(doc appLogDocModel) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
fmt.Println("send entry to es failed: ", r)
|
||||
}
|
||||
}()
|
||||
_, err := hook.client.Index().Index(hook.moduleName).Type(doc.indexName()).BodyJson(doc).Do(context.Background())
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//appLogDocModel es model
|
||||
type appLogDocModel map[string]interface{}
|
||||
|
||||
func newEsLog(e *logrus.Entry) appLogDocModel {
|
||||
ins := make(map[string]interface{})
|
||||
ins["level"] = strings.ToUpper(e.Level.String())
|
||||
ins["time"] = e.Time.Format("2006-01-02 15:04:05")
|
||||
for kk, vv := range e.Data {
|
||||
ins[kk] = vv
|
||||
}
|
||||
ins["tipInfo"] = e.Message
|
||||
|
||||
return ins
|
||||
}
|
||||
|
||||
// indexName es index name 时间分割
|
||||
func (m *appLogDocModel) indexName() string {
|
||||
return time.Now().Format("2006-01-02")
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
/*
|
||||
** description("get the name and line number of the calling file hook").
|
||||
** copyright('tuoyun,www.tuoyun.net').
|
||||
** author("fg,Gordon@tuoyun.net").
|
||||
** time(2021/3/16 11:26).
|
||||
*/
|
||||
package log
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/sirupsen/logrus"
|
||||
"runtime"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type fileHook struct{}
|
||||
|
||||
func newFileHook() *fileHook {
|
||||
return &fileHook{}
|
||||
}
|
||||
|
||||
func (f *fileHook) Levels() []logrus.Level {
|
||||
return logrus.AllLevels
|
||||
}
|
||||
|
||||
func (f *fileHook) Fire(entry *logrus.Entry) error {
|
||||
entry.Data["FilePath"] = findCaller(5)
|
||||
return nil
|
||||
}
|
||||
|
||||
func findCaller(skip int) string {
|
||||
file := ""
|
||||
line := 0
|
||||
for i := 0; i < 10; i++ {
|
||||
file, line = getCaller(skip + i)
|
||||
if !strings.HasPrefix(file, "log") {
|
||||
break
|
||||
}
|
||||
}
|
||||
return fmt.Sprintf("%s:%d", file, line)
|
||||
}
|
||||
|
||||
func getCaller(skip int) (string, int) {
|
||||
_, file, line, ok := runtime.Caller(skip)
|
||||
if !ok {
|
||||
return "", 0
|
||||
}
|
||||
|
||||
n := 0
|
||||
for i := len(file) - 1; i > 0; i-- {
|
||||
if file[i] == '/' {
|
||||
n++
|
||||
if n >= 2 {
|
||||
file = file[i+1:]
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
return file, line
|
||||
}
|
@ -0,0 +1,205 @@
|
||||
package log
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"bufio"
|
||||
"fmt"
|
||||
nested "github.com/antonfisher/nested-logrus-formatter"
|
||||
rotatelogs "github.com/lestrrat-go/file-rotatelogs"
|
||||
"github.com/rifflock/lfshook"
|
||||
"github.com/sirupsen/logrus"
|
||||
"os"
|
||||
"time"
|
||||
)
|
||||
|
||||
var logger *Logger
|
||||
|
||||
type Logger struct {
|
||||
*logrus.Logger
|
||||
Pid int
|
||||
}
|
||||
|
||||
func init() {
|
||||
logger = loggerInit("")
|
||||
|
||||
}
|
||||
func NewPrivateLog(moduleName string) {
|
||||
logger = loggerInit(moduleName)
|
||||
}
|
||||
|
||||
func loggerInit(moduleName string) *Logger {
|
||||
var logger = logrus.New()
|
||||
//All logs will be printed
|
||||
logger.SetLevel(logrus.Level(config.Config.Log.RemainLogLevel))
|
||||
//Close std console output
|
||||
src, err := os.OpenFile(os.DevNull, os.O_APPEND|os.O_WRONLY, os.ModeAppend)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
writer := bufio.NewWriter(src)
|
||||
logger.SetOutput(writer)
|
||||
//Log Console Print Style Setting
|
||||
logger.SetFormatter(&nested.Formatter{
|
||||
TimestampFormat: "2006-01-02 15:04:05.000",
|
||||
HideKeys: false,
|
||||
FieldsOrder: []string{"PID", "FilePath", "OperationID"},
|
||||
})
|
||||
//File name and line number display hook
|
||||
logger.AddHook(newFileHook())
|
||||
|
||||
//Send logs to elasticsearch hook
|
||||
if config.Config.Log.ElasticSearchSwitch {
|
||||
logger.AddHook(newEsHook(moduleName))
|
||||
}
|
||||
//Log file segmentation hook
|
||||
hook := NewLfsHook(time.Duration(config.Config.Log.RotationTime)*time.Hour, config.Config.Log.RemainRotationCount, moduleName)
|
||||
logger.AddHook(hook)
|
||||
return &Logger{
|
||||
logger,
|
||||
os.Getpid(),
|
||||
}
|
||||
}
|
||||
func NewLfsHook(rotationTime time.Duration, maxRemainNum uint, moduleName string) logrus.Hook {
|
||||
lfsHook := lfshook.NewHook(lfshook.WriterMap{
|
||||
logrus.DebugLevel: initRotateLogs(rotationTime, maxRemainNum, "debug", moduleName),
|
||||
logrus.InfoLevel: initRotateLogs(rotationTime, maxRemainNum, "info", moduleName),
|
||||
logrus.WarnLevel: initRotateLogs(rotationTime, maxRemainNum, "warn", moduleName),
|
||||
logrus.ErrorLevel: initRotateLogs(rotationTime, maxRemainNum, "error", moduleName),
|
||||
}, &nested.Formatter{
|
||||
TimestampFormat: "2006-01-02 15:04:05.000",
|
||||
HideKeys: false,
|
||||
FieldsOrder: []string{"PID", "FilePath", "OperationID"},
|
||||
})
|
||||
return lfsHook
|
||||
}
|
||||
func initRotateLogs(rotationTime time.Duration, maxRemainNum uint, level string, moduleName string) *rotatelogs.RotateLogs {
|
||||
if moduleName != "" {
|
||||
moduleName = moduleName + "."
|
||||
}
|
||||
writer, err := rotatelogs.New(
|
||||
config.Config.Log.StorageLocation+moduleName+level+"."+"%Y-%m-%d",
|
||||
rotatelogs.WithRotationTime(rotationTime),
|
||||
rotatelogs.WithRotationCount(maxRemainNum),
|
||||
)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
} else {
|
||||
return writer
|
||||
}
|
||||
}
|
||||
|
||||
//Deprecated
|
||||
func Info(token, OperationID, format string, args ...interface{}) {
|
||||
logger.WithFields(logrus.Fields{
|
||||
"PID": logger.Pid,
|
||||
"OperationID": OperationID,
|
||||
}).Infof(format, args...)
|
||||
|
||||
}
|
||||
|
||||
//Deprecated
|
||||
func Error(token, OperationID, format string, args ...interface{}) {
|
||||
|
||||
logger.WithFields(logrus.Fields{
|
||||
"PID": logger.Pid,
|
||||
"OperationID": OperationID,
|
||||
}).Errorf(format, args...)
|
||||
|
||||
}
|
||||
|
||||
//Deprecated
|
||||
func Debug(token, OperationID, format string, args ...interface{}) {
|
||||
|
||||
logger.WithFields(logrus.Fields{
|
||||
"PID": logger.Pid,
|
||||
"OperationID": OperationID,
|
||||
}).Debugf(format, args...)
|
||||
|
||||
}
|
||||
|
||||
//Deprecated
|
||||
func Warning(token, OperationID, format string, args ...interface{}) {
|
||||
logger.WithFields(logrus.Fields{
|
||||
"PID": logger.Pid,
|
||||
"OperationID": OperationID,
|
||||
}).Warningf(format, args...)
|
||||
|
||||
}
|
||||
|
||||
//Deprecated
|
||||
func InfoByArgs(format string, args ...interface{}) {
|
||||
logger.WithFields(logrus.Fields{}).Infof(format, args)
|
||||
}
|
||||
|
||||
//Deprecated
|
||||
func ErrorByArgs(format string, args ...interface{}) {
|
||||
logger.WithFields(logrus.Fields{}).Errorf(format, args...)
|
||||
}
|
||||
|
||||
//Print log information in k, v format,
|
||||
//kv is best to appear in pairs. tipInfo is the log prompt information for printing,
|
||||
//and kv is the key and value for printing.
|
||||
//Deprecated
|
||||
func InfoByKv(tipInfo, OperationID string, args ...interface{}) {
|
||||
fields := make(logrus.Fields)
|
||||
argsHandle(OperationID, fields, args)
|
||||
logger.WithFields(fields).Info(tipInfo)
|
||||
}
|
||||
|
||||
//Deprecated
|
||||
func ErrorByKv(tipInfo, OperationID string, args ...interface{}) {
|
||||
fields := make(logrus.Fields)
|
||||
argsHandle(OperationID, fields, args)
|
||||
logger.WithFields(fields).Error(tipInfo)
|
||||
}
|
||||
|
||||
//Deprecated
|
||||
func DebugByKv(tipInfo, OperationID string, args ...interface{}) {
|
||||
fields := make(logrus.Fields)
|
||||
argsHandle(OperationID, fields, args)
|
||||
logger.WithFields(fields).Debug(tipInfo)
|
||||
}
|
||||
|
||||
//Deprecated
|
||||
func WarnByKv(tipInfo, OperationID string, args ...interface{}) {
|
||||
fields := make(logrus.Fields)
|
||||
argsHandle(OperationID, fields, args)
|
||||
logger.WithFields(fields).Warn(tipInfo)
|
||||
}
|
||||
|
||||
//internal method
|
||||
func argsHandle(OperationID string, fields logrus.Fields, args []interface{}) {
|
||||
for i := 0; i < len(args); i += 2 {
|
||||
if i+1 < len(args) {
|
||||
fields[fmt.Sprintf("%v", args[i])] = args[i+1]
|
||||
} else {
|
||||
fields[fmt.Sprintf("%v", args[i])] = ""
|
||||
}
|
||||
}
|
||||
fields["OperationID"] = OperationID
|
||||
fields["PID"] = logger.Pid
|
||||
}
|
||||
func NewInfo(OperationID string, args ...interface{}) {
|
||||
logger.WithFields(logrus.Fields{
|
||||
"OperationID": OperationID,
|
||||
"PID": logger.Pid,
|
||||
}).Infoln(args)
|
||||
}
|
||||
func NewError(OperationID string, args ...interface{}) {
|
||||
logger.WithFields(logrus.Fields{
|
||||
"OperationID": OperationID,
|
||||
"PID": logger.Pid,
|
||||
}).Errorln(args)
|
||||
}
|
||||
func NewDebug(OperationID string, args ...interface{}) {
|
||||
logger.WithFields(logrus.Fields{
|
||||
"OperationID": OperationID,
|
||||
"PID": logger.Pid,
|
||||
}).Debugln(args)
|
||||
}
|
||||
func NewWarn(OperationID string, args ...interface{}) {
|
||||
logger.WithFields(logrus.Fields{
|
||||
"OperationID": OperationID,
|
||||
"PID": logger.Pid,
|
||||
}).Warnln(args)
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
/*
|
||||
** description("").
|
||||
** copyright('tuoyun,www.tuoyun.net').
|
||||
** author("fg,Gordon@tuoyun.net").
|
||||
** time(2021/2/22 11:52).
|
||||
*/
|
||||
package log
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
TimeOffset = 8 * 3600 //8 hour offset
|
||||
HalfOffset = 12 * 3600 //Half-day hourly offset
|
||||
)
|
||||
|
||||
//Get the current timestamp
|
||||
func GetCurrentTimestamp() int64 {
|
||||
return time.Now().Unix()
|
||||
}
|
||||
|
||||
//Get the current 0 o'clock timestamp
|
||||
func GetCurDayZeroTimestamp() int64 {
|
||||
timeStr := time.Now().Format("2006-01-02")
|
||||
t, _ := time.Parse("2006-01-02", timeStr)
|
||||
return t.Unix() - TimeOffset
|
||||
}
|
||||
|
||||
//Get the timestamp at 12 o'clock on the day
|
||||
func GetCurDayHalfTimestamp() int64 {
|
||||
return GetCurDayZeroTimestamp() + HalfOffset
|
||||
|
||||
}
|
||||
|
||||
//Get the formatted time at 0 o'clock of the day, the format is "2006-01-02_00-00-00"
|
||||
func GetCurDayZeroTimeFormat() string {
|
||||
return time.Unix(GetCurDayZeroTimestamp(), 0).Format("2006-01-02_15-04-05")
|
||||
}
|
||||
|
||||
//Get the formatted time at 12 o'clock of the day, the format is "2006-01-02_12-00-00"
|
||||
func GetCurDayHalfTimeFormat() string {
|
||||
return time.Unix(GetCurDayZeroTimestamp()+HalfOffset, 0).Format("2006-01-02_15-04-05")
|
||||
}
|
||||
func GetTimeStampByFormat(datetime string) string {
|
||||
timeLayout := "2006-01-02 15:04:05" //转化所需模板
|
||||
loc, _ := time.LoadLocation("Local") //获取时区
|
||||
tmp, _ := time.ParseInLocation(timeLayout, datetime, loc)
|
||||
timestamp := tmp.Unix() //转化为时间戳 类型是int64
|
||||
return strconv.FormatInt(timestamp, 10)
|
||||
}
|
||||
|
||||
func TimeStringFormatTimeUnix(timeFormat string, timeSrc string) int64 {
|
||||
tm, _ := time.Parse(timeFormat, timeSrc)
|
||||
return tm.Unix()
|
||||
}
|
@ -0,0 +1,753 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// source: sdk_ws/ws.proto
|
||||
|
||||
package open_im_sdk // import "./sdk_ws"
|
||||
|
||||
import proto "github.com/golang/protobuf/proto"
|
||||
import fmt "fmt"
|
||||
import math "math"
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
// A compilation error at this line likely means your copy of the
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
|
||||
|
||||
type PullMessageBySeqListResp struct {
|
||||
MaxSeq int64 `protobuf:"varint,1,opt,name=MaxSeq" json:"MaxSeq,omitempty"`
|
||||
MinSeq int64 `protobuf:"varint,2,opt,name=MinSeq" json:"MinSeq,omitempty"`
|
||||
SingleUserMsg []*GatherFormat `protobuf:"bytes,3,rep,name=SingleUserMsg" json:"SingleUserMsg,omitempty"`
|
||||
GroupUserMsg []*GatherFormat `protobuf:"bytes,4,rep,name=GroupUserMsg" json:"GroupUserMsg,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *PullMessageBySeqListResp) Reset() { *m = PullMessageBySeqListResp{} }
|
||||
func (m *PullMessageBySeqListResp) String() string { return proto.CompactTextString(m) }
|
||||
func (*PullMessageBySeqListResp) ProtoMessage() {}
|
||||
func (*PullMessageBySeqListResp) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_ws_f143de4f947df40f, []int{0}
|
||||
}
|
||||
func (m *PullMessageBySeqListResp) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_PullMessageBySeqListResp.Unmarshal(m, b)
|
||||
}
|
||||
func (m *PullMessageBySeqListResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_PullMessageBySeqListResp.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (dst *PullMessageBySeqListResp) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_PullMessageBySeqListResp.Merge(dst, src)
|
||||
}
|
||||
func (m *PullMessageBySeqListResp) XXX_Size() int {
|
||||
return xxx_messageInfo_PullMessageBySeqListResp.Size(m)
|
||||
}
|
||||
func (m *PullMessageBySeqListResp) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_PullMessageBySeqListResp.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_PullMessageBySeqListResp proto.InternalMessageInfo
|
||||
|
||||
func (m *PullMessageBySeqListResp) GetMaxSeq() int64 {
|
||||
if m != nil {
|
||||
return m.MaxSeq
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *PullMessageBySeqListResp) GetMinSeq() int64 {
|
||||
if m != nil {
|
||||
return m.MinSeq
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *PullMessageBySeqListResp) GetSingleUserMsg() []*GatherFormat {
|
||||
if m != nil {
|
||||
return m.SingleUserMsg
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *PullMessageBySeqListResp) GetGroupUserMsg() []*GatherFormat {
|
||||
if m != nil {
|
||||
return m.GroupUserMsg
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type PullMessageBySeqListReq struct {
|
||||
SeqList []int64 `protobuf:"varint,1,rep,packed,name=seqList" json:"seqList,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *PullMessageBySeqListReq) Reset() { *m = PullMessageBySeqListReq{} }
|
||||
func (m *PullMessageBySeqListReq) String() string { return proto.CompactTextString(m) }
|
||||
func (*PullMessageBySeqListReq) ProtoMessage() {}
|
||||
func (*PullMessageBySeqListReq) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_ws_f143de4f947df40f, []int{1}
|
||||
}
|
||||
func (m *PullMessageBySeqListReq) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_PullMessageBySeqListReq.Unmarshal(m, b)
|
||||
}
|
||||
func (m *PullMessageBySeqListReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_PullMessageBySeqListReq.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (dst *PullMessageBySeqListReq) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_PullMessageBySeqListReq.Merge(dst, src)
|
||||
}
|
||||
func (m *PullMessageBySeqListReq) XXX_Size() int {
|
||||
return xxx_messageInfo_PullMessageBySeqListReq.Size(m)
|
||||
}
|
||||
func (m *PullMessageBySeqListReq) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_PullMessageBySeqListReq.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_PullMessageBySeqListReq proto.InternalMessageInfo
|
||||
|
||||
func (m *PullMessageBySeqListReq) GetSeqList() []int64 {
|
||||
if m != nil {
|
||||
return m.SeqList
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type GetMaxAndMinSeqReq struct {
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *GetMaxAndMinSeqReq) Reset() { *m = GetMaxAndMinSeqReq{} }
|
||||
func (m *GetMaxAndMinSeqReq) String() string { return proto.CompactTextString(m) }
|
||||
func (*GetMaxAndMinSeqReq) ProtoMessage() {}
|
||||
func (*GetMaxAndMinSeqReq) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_ws_f143de4f947df40f, []int{2}
|
||||
}
|
||||
func (m *GetMaxAndMinSeqReq) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_GetMaxAndMinSeqReq.Unmarshal(m, b)
|
||||
}
|
||||
func (m *GetMaxAndMinSeqReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_GetMaxAndMinSeqReq.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (dst *GetMaxAndMinSeqReq) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_GetMaxAndMinSeqReq.Merge(dst, src)
|
||||
}
|
||||
func (m *GetMaxAndMinSeqReq) XXX_Size() int {
|
||||
return xxx_messageInfo_GetMaxAndMinSeqReq.Size(m)
|
||||
}
|
||||
func (m *GetMaxAndMinSeqReq) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_GetMaxAndMinSeqReq.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_GetMaxAndMinSeqReq proto.InternalMessageInfo
|
||||
|
||||
type GetMaxAndMinSeqResp struct {
|
||||
MaxSeq int64 `protobuf:"varint,1,opt,name=maxSeq" json:"maxSeq,omitempty"`
|
||||
MinSeq int64 `protobuf:"varint,2,opt,name=minSeq" json:"minSeq,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *GetMaxAndMinSeqResp) Reset() { *m = GetMaxAndMinSeqResp{} }
|
||||
func (m *GetMaxAndMinSeqResp) String() string { return proto.CompactTextString(m) }
|
||||
func (*GetMaxAndMinSeqResp) ProtoMessage() {}
|
||||
func (*GetMaxAndMinSeqResp) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_ws_f143de4f947df40f, []int{3}
|
||||
}
|
||||
func (m *GetMaxAndMinSeqResp) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_GetMaxAndMinSeqResp.Unmarshal(m, b)
|
||||
}
|
||||
func (m *GetMaxAndMinSeqResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_GetMaxAndMinSeqResp.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (dst *GetMaxAndMinSeqResp) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_GetMaxAndMinSeqResp.Merge(dst, src)
|
||||
}
|
||||
func (m *GetMaxAndMinSeqResp) XXX_Size() int {
|
||||
return xxx_messageInfo_GetMaxAndMinSeqResp.Size(m)
|
||||
}
|
||||
func (m *GetMaxAndMinSeqResp) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_GetMaxAndMinSeqResp.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_GetMaxAndMinSeqResp proto.InternalMessageInfo
|
||||
|
||||
func (m *GetMaxAndMinSeqResp) GetMaxSeq() int64 {
|
||||
if m != nil {
|
||||
return m.MaxSeq
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *GetMaxAndMinSeqResp) GetMinSeq() int64 {
|
||||
if m != nil {
|
||||
return m.MinSeq
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type GatherFormat struct {
|
||||
// @inject_tag: json:"id"
|
||||
ID string `protobuf:"bytes,1,opt,name=ID" json:"id"`
|
||||
// @inject_tag: json:"list"
|
||||
List []*MsgFormat `protobuf:"bytes,2,rep,name=List" json:"list"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *GatherFormat) Reset() { *m = GatherFormat{} }
|
||||
func (m *GatherFormat) String() string { return proto.CompactTextString(m) }
|
||||
func (*GatherFormat) ProtoMessage() {}
|
||||
func (*GatherFormat) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_ws_f143de4f947df40f, []int{4}
|
||||
}
|
||||
func (m *GatherFormat) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_GatherFormat.Unmarshal(m, b)
|
||||
}
|
||||
func (m *GatherFormat) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_GatherFormat.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (dst *GatherFormat) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_GatherFormat.Merge(dst, src)
|
||||
}
|
||||
func (m *GatherFormat) XXX_Size() int {
|
||||
return xxx_messageInfo_GatherFormat.Size(m)
|
||||
}
|
||||
func (m *GatherFormat) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_GatherFormat.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_GatherFormat proto.InternalMessageInfo
|
||||
|
||||
func (m *GatherFormat) GetID() string {
|
||||
if m != nil {
|
||||
return m.ID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *GatherFormat) GetList() []*MsgFormat {
|
||||
if m != nil {
|
||||
return m.List
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type MsgFormat struct {
|
||||
// @inject_tag: json:"sendID"
|
||||
SendID string `protobuf:"bytes,1,opt,name=SendID" json:"sendID"`
|
||||
// @inject_tag: json:"recvID"
|
||||
RecvID string `protobuf:"bytes,2,opt,name=RecvID" json:"recvID"`
|
||||
// @inject_tag: json:"msgFrom"
|
||||
MsgFrom int32 `protobuf:"varint,3,opt,name=MsgFrom" json:"msgFrom"`
|
||||
// @inject_tag: json:"contentType"
|
||||
ContentType int32 `protobuf:"varint,4,opt,name=ContentType" json:"contentType"`
|
||||
// @inject_tag: json:"serverMsgID"
|
||||
ServerMsgID string `protobuf:"bytes,5,opt,name=ServerMsgID" json:"serverMsgID"`
|
||||
// @inject_tag: json:"content"
|
||||
Content string `protobuf:"bytes,6,opt,name=Content" json:"content"`
|
||||
// @inject_tag: json:"seq"
|
||||
Seq int64 `protobuf:"varint,7,opt,name=Seq" json:"seq"`
|
||||
// @inject_tag: json:"sendTime"
|
||||
SendTime int64 `protobuf:"varint,8,opt,name=SendTime" json:"sendTime"`
|
||||
// @inject_tag: json:"senderPlatformID"
|
||||
SenderPlatformID int32 `protobuf:"varint,9,opt,name=SenderPlatformID" json:"senderPlatformID"`
|
||||
// @inject_tag: json:"senderNickName"
|
||||
SenderNickName string `protobuf:"bytes,10,opt,name=SenderNickName" json:"senderNickName"`
|
||||
// @inject_tag: json:"senderFaceUrl"
|
||||
SenderFaceURL string `protobuf:"bytes,11,opt,name=SenderFaceURL" json:"senderFaceUrl"`
|
||||
// @inject_tag: json:"clientMsgID"
|
||||
ClientMsgID string `protobuf:"bytes,12,opt,name=ClientMsgID" json:"clientMsgID"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *MsgFormat) Reset() { *m = MsgFormat{} }
|
||||
func (m *MsgFormat) String() string { return proto.CompactTextString(m) }
|
||||
func (*MsgFormat) ProtoMessage() {}
|
||||
func (*MsgFormat) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_ws_f143de4f947df40f, []int{5}
|
||||
}
|
||||
func (m *MsgFormat) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_MsgFormat.Unmarshal(m, b)
|
||||
}
|
||||
func (m *MsgFormat) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_MsgFormat.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (dst *MsgFormat) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_MsgFormat.Merge(dst, src)
|
||||
}
|
||||
func (m *MsgFormat) XXX_Size() int {
|
||||
return xxx_messageInfo_MsgFormat.Size(m)
|
||||
}
|
||||
func (m *MsgFormat) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_MsgFormat.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_MsgFormat proto.InternalMessageInfo
|
||||
|
||||
func (m *MsgFormat) GetSendID() string {
|
||||
if m != nil {
|
||||
return m.SendID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *MsgFormat) GetRecvID() string {
|
||||
if m != nil {
|
||||
return m.RecvID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *MsgFormat) GetMsgFrom() int32 {
|
||||
if m != nil {
|
||||
return m.MsgFrom
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *MsgFormat) GetContentType() int32 {
|
||||
if m != nil {
|
||||
return m.ContentType
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *MsgFormat) GetServerMsgID() string {
|
||||
if m != nil {
|
||||
return m.ServerMsgID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *MsgFormat) GetContent() string {
|
||||
if m != nil {
|
||||
return m.Content
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *MsgFormat) GetSeq() int64 {
|
||||
if m != nil {
|
||||
return m.Seq
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *MsgFormat) GetSendTime() int64 {
|
||||
if m != nil {
|
||||
return m.SendTime
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *MsgFormat) GetSenderPlatformID() int32 {
|
||||
if m != nil {
|
||||
return m.SenderPlatformID
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *MsgFormat) GetSenderNickName() string {
|
||||
if m != nil {
|
||||
return m.SenderNickName
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *MsgFormat) GetSenderFaceURL() string {
|
||||
if m != nil {
|
||||
return m.SenderFaceURL
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *MsgFormat) GetClientMsgID() string {
|
||||
if m != nil {
|
||||
return m.ClientMsgID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type UserSendMsgReq struct {
|
||||
Options map[string]int32 `protobuf:"bytes,1,rep,name=Options" json:"Options,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"varint,2,opt,name=value"`
|
||||
SenderNickName string `protobuf:"bytes,2,opt,name=SenderNickName" json:"SenderNickName,omitempty"`
|
||||
SenderFaceURL string `protobuf:"bytes,3,opt,name=SenderFaceURL" json:"SenderFaceURL,omitempty"`
|
||||
PlatformID int32 `protobuf:"varint,4,opt,name=PlatformID" json:"PlatformID,omitempty"`
|
||||
SessionType int32 `protobuf:"varint,5,opt,name=SessionType" json:"SessionType,omitempty"`
|
||||
MsgFrom int32 `protobuf:"varint,6,opt,name=MsgFrom" json:"MsgFrom,omitempty"`
|
||||
ContentType int32 `protobuf:"varint,7,opt,name=ContentType" json:"ContentType,omitempty"`
|
||||
RecvID string `protobuf:"bytes,8,opt,name=RecvID" json:"RecvID,omitempty"`
|
||||
ForceList []string `protobuf:"bytes,9,rep,name=ForceList" json:"ForceList,omitempty"`
|
||||
Content string `protobuf:"bytes,10,opt,name=Content" json:"Content,omitempty"`
|
||||
ClientMsgID string `protobuf:"bytes,11,opt,name=ClientMsgID" json:"ClientMsgID,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *UserSendMsgReq) Reset() { *m = UserSendMsgReq{} }
|
||||
func (m *UserSendMsgReq) String() string { return proto.CompactTextString(m) }
|
||||
func (*UserSendMsgReq) ProtoMessage() {}
|
||||
func (*UserSendMsgReq) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_ws_f143de4f947df40f, []int{6}
|
||||
}
|
||||
func (m *UserSendMsgReq) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_UserSendMsgReq.Unmarshal(m, b)
|
||||
}
|
||||
func (m *UserSendMsgReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_UserSendMsgReq.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (dst *UserSendMsgReq) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_UserSendMsgReq.Merge(dst, src)
|
||||
}
|
||||
func (m *UserSendMsgReq) XXX_Size() int {
|
||||
return xxx_messageInfo_UserSendMsgReq.Size(m)
|
||||
}
|
||||
func (m *UserSendMsgReq) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_UserSendMsgReq.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_UserSendMsgReq proto.InternalMessageInfo
|
||||
|
||||
func (m *UserSendMsgReq) GetOptions() map[string]int32 {
|
||||
if m != nil {
|
||||
return m.Options
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *UserSendMsgReq) GetSenderNickName() string {
|
||||
if m != nil {
|
||||
return m.SenderNickName
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *UserSendMsgReq) GetSenderFaceURL() string {
|
||||
if m != nil {
|
||||
return m.SenderFaceURL
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *UserSendMsgReq) GetPlatformID() int32 {
|
||||
if m != nil {
|
||||
return m.PlatformID
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *UserSendMsgReq) GetSessionType() int32 {
|
||||
if m != nil {
|
||||
return m.SessionType
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *UserSendMsgReq) GetMsgFrom() int32 {
|
||||
if m != nil {
|
||||
return m.MsgFrom
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *UserSendMsgReq) GetContentType() int32 {
|
||||
if m != nil {
|
||||
return m.ContentType
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *UserSendMsgReq) GetRecvID() string {
|
||||
if m != nil {
|
||||
return m.RecvID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *UserSendMsgReq) GetForceList() []string {
|
||||
if m != nil {
|
||||
return m.ForceList
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *UserSendMsgReq) GetContent() string {
|
||||
if m != nil {
|
||||
return m.Content
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *UserSendMsgReq) GetClientMsgID() string {
|
||||
if m != nil {
|
||||
return m.ClientMsgID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type UserSendMsgResp struct {
|
||||
ServerMsgID string `protobuf:"bytes,1,opt,name=ServerMsgID" json:"ServerMsgID,omitempty"`
|
||||
ClientMsgID string `protobuf:"bytes,2,opt,name=ClientMsgID" json:"ClientMsgID,omitempty"`
|
||||
SendTime int64 `protobuf:"varint,3,opt,name=sendTime" json:"sendTime,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *UserSendMsgResp) Reset() { *m = UserSendMsgResp{} }
|
||||
func (m *UserSendMsgResp) String() string { return proto.CompactTextString(m) }
|
||||
func (*UserSendMsgResp) ProtoMessage() {}
|
||||
func (*UserSendMsgResp) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_ws_f143de4f947df40f, []int{7}
|
||||
}
|
||||
func (m *UserSendMsgResp) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_UserSendMsgResp.Unmarshal(m, b)
|
||||
}
|
||||
func (m *UserSendMsgResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_UserSendMsgResp.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (dst *UserSendMsgResp) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_UserSendMsgResp.Merge(dst, src)
|
||||
}
|
||||
func (m *UserSendMsgResp) XXX_Size() int {
|
||||
return xxx_messageInfo_UserSendMsgResp.Size(m)
|
||||
}
|
||||
func (m *UserSendMsgResp) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_UserSendMsgResp.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_UserSendMsgResp proto.InternalMessageInfo
|
||||
|
||||
func (m *UserSendMsgResp) GetServerMsgID() string {
|
||||
if m != nil {
|
||||
return m.ServerMsgID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *UserSendMsgResp) GetClientMsgID() string {
|
||||
if m != nil {
|
||||
return m.ClientMsgID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *UserSendMsgResp) GetSendTime() int64 {
|
||||
if m != nil {
|
||||
return m.SendTime
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type MsgData struct {
|
||||
SendID string `protobuf:"bytes,1,opt,name=sendID" json:"sendID,omitempty"`
|
||||
RecvID string `protobuf:"bytes,2,opt,name=recvID" json:"recvID,omitempty"`
|
||||
SessionType int32 `protobuf:"varint,3,opt,name=sessionType" json:"sessionType,omitempty"`
|
||||
MsgFrom int32 `protobuf:"varint,4,opt,name=msgFrom" json:"msgFrom,omitempty"`
|
||||
ContentType int32 `protobuf:"varint,5,opt,name=contentType" json:"contentType,omitempty"`
|
||||
ServerMsgID string `protobuf:"bytes,6,opt,name=serverMsgID" json:"serverMsgID,omitempty"`
|
||||
Content string `protobuf:"bytes,7,opt,name=content" json:"content,omitempty"`
|
||||
SendTime int64 `protobuf:"varint,8,opt,name=sendTime" json:"sendTime,omitempty"`
|
||||
Seq int64 `protobuf:"varint,9,opt,name=seq" json:"seq,omitempty"`
|
||||
SenderPlatformID int32 `protobuf:"varint,10,opt,name=senderPlatformID" json:"senderPlatformID,omitempty"`
|
||||
SenderNickName string `protobuf:"bytes,11,opt,name=senderNickName" json:"senderNickName,omitempty"`
|
||||
SenderFaceURL string `protobuf:"bytes,12,opt,name=senderFaceURL" json:"senderFaceURL,omitempty"`
|
||||
ClientMsgID string `protobuf:"bytes,13,opt,name=clientMsgID" json:"clientMsgID,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *MsgData) Reset() { *m = MsgData{} }
|
||||
func (m *MsgData) String() string { return proto.CompactTextString(m) }
|
||||
func (*MsgData) ProtoMessage() {}
|
||||
func (*MsgData) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_ws_f143de4f947df40f, []int{8}
|
||||
}
|
||||
func (m *MsgData) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_MsgData.Unmarshal(m, b)
|
||||
}
|
||||
func (m *MsgData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_MsgData.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (dst *MsgData) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_MsgData.Merge(dst, src)
|
||||
}
|
||||
func (m *MsgData) XXX_Size() int {
|
||||
return xxx_messageInfo_MsgData.Size(m)
|
||||
}
|
||||
func (m *MsgData) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_MsgData.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_MsgData proto.InternalMessageInfo
|
||||
|
||||
func (m *MsgData) GetSendID() string {
|
||||
if m != nil {
|
||||
return m.SendID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *MsgData) GetRecvID() string {
|
||||
if m != nil {
|
||||
return m.RecvID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *MsgData) GetSessionType() int32 {
|
||||
if m != nil {
|
||||
return m.SessionType
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *MsgData) GetMsgFrom() int32 {
|
||||
if m != nil {
|
||||
return m.MsgFrom
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *MsgData) GetContentType() int32 {
|
||||
if m != nil {
|
||||
return m.ContentType
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *MsgData) GetServerMsgID() string {
|
||||
if m != nil {
|
||||
return m.ServerMsgID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *MsgData) GetContent() string {
|
||||
if m != nil {
|
||||
return m.Content
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *MsgData) GetSendTime() int64 {
|
||||
if m != nil {
|
||||
return m.SendTime
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *MsgData) GetSeq() int64 {
|
||||
if m != nil {
|
||||
return m.Seq
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *MsgData) GetSenderPlatformID() int32 {
|
||||
if m != nil {
|
||||
return m.SenderPlatformID
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *MsgData) GetSenderNickName() string {
|
||||
if m != nil {
|
||||
return m.SenderNickName
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *MsgData) GetSenderFaceURL() string {
|
||||
if m != nil {
|
||||
return m.SenderFaceURL
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *MsgData) GetClientMsgID() string {
|
||||
if m != nil {
|
||||
return m.ClientMsgID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*PullMessageBySeqListResp)(nil), "open_im_sdk.PullMessageBySeqListResp")
|
||||
proto.RegisterType((*PullMessageBySeqListReq)(nil), "open_im_sdk.PullMessageBySeqListReq")
|
||||
proto.RegisterType((*GetMaxAndMinSeqReq)(nil), "open_im_sdk.GetMaxAndMinSeqReq")
|
||||
proto.RegisterType((*GetMaxAndMinSeqResp)(nil), "open_im_sdk.GetMaxAndMinSeqResp")
|
||||
proto.RegisterType((*GatherFormat)(nil), "open_im_sdk.GatherFormat")
|
||||
proto.RegisterType((*MsgFormat)(nil), "open_im_sdk.MsgFormat")
|
||||
proto.RegisterType((*UserSendMsgReq)(nil), "open_im_sdk.UserSendMsgReq")
|
||||
proto.RegisterMapType((map[string]int32)(nil), "open_im_sdk.UserSendMsgReq.OptionsEntry")
|
||||
proto.RegisterType((*UserSendMsgResp)(nil), "open_im_sdk.UserSendMsgResp")
|
||||
proto.RegisterType((*MsgData)(nil), "open_im_sdk.MsgData")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("sdk_ws/ws.proto", fileDescriptor_ws_f143de4f947df40f) }
|
||||
|
||||
var fileDescriptor_ws_f143de4f947df40f = []byte{
|
||||
// 739 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x55, 0x4b, 0x6b, 0xdb, 0x4a,
|
||||
0x14, 0x46, 0x52, 0xfc, 0xd0, 0xb1, 0xf3, 0x60, 0x6e, 0xc8, 0xd5, 0x0d, 0x97, 0x8b, 0x11, 0x97,
|
||||
0x62, 0xb2, 0x70, 0x20, 0xd9, 0x94, 0x94, 0x52, 0x9a, 0x3a, 0x09, 0x2e, 0x71, 0x1a, 0xc6, 0xc9,
|
||||
0xa6, 0x9b, 0xa0, 0xda, 0x53, 0x57, 0xd8, 0x7a, 0x58, 0x47, 0x79, 0xf8, 0xc7, 0xf4, 0x0f, 0x75,
|
||||
0xd1, 0x7f, 0x54, 0x28, 0x67, 0x46, 0x72, 0x66, 0x6c, 0xd3, 0x76, 0x37, 0xe7, 0xd3, 0x9c, 0x99,
|
||||
0x39, 0xdf, 0x03, 0xc1, 0x36, 0x8e, 0x26, 0x77, 0x8f, 0x78, 0xf8, 0x88, 0x9d, 0x34, 0x4b, 0xf2,
|
||||
0x84, 0x35, 0x92, 0x54, 0xc4, 0x77, 0x61, 0x74, 0x87, 0xa3, 0x89, 0xff, 0xcd, 0x02, 0xef, 0xfa,
|
||||
0x7e, 0x3a, 0xed, 0x0b, 0xc4, 0x60, 0x2c, 0x4e, 0xe7, 0x03, 0x31, 0xbb, 0x0c, 0x31, 0xe7, 0x02,
|
||||
0x53, 0xb6, 0x07, 0xd5, 0x7e, 0xf0, 0x34, 0x10, 0x33, 0xcf, 0x6a, 0x59, 0x6d, 0x87, 0x17, 0x95,
|
||||
0xc4, 0xc3, 0x98, 0x70, 0xbb, 0xc0, 0x65, 0xc5, 0xde, 0xc0, 0xe6, 0x20, 0x8c, 0xc7, 0x53, 0x71,
|
||||
0x8b, 0x22, 0xeb, 0xe3, 0xd8, 0x73, 0x5a, 0x4e, 0xbb, 0x71, 0xf4, 0x4f, 0x47, 0xbb, 0xb1, 0x73,
|
||||
0x11, 0xe4, 0x5f, 0x44, 0x76, 0x9e, 0x64, 0x51, 0x90, 0x73, 0x73, 0x3f, 0x7b, 0x0d, 0xcd, 0x8b,
|
||||
0x2c, 0xb9, 0x4f, 0xcb, 0xfe, 0x8d, 0xdf, 0xf5, 0x1b, 0xdb, 0xfd, 0x63, 0xf8, 0x7b, 0xfd, 0x2c,
|
||||
0x33, 0xe6, 0x41, 0x0d, 0x55, 0xe5, 0x59, 0x2d, 0xa7, 0xed, 0xf0, 0xb2, 0xf4, 0x77, 0x81, 0x5d,
|
||||
0x88, 0xbc, 0x1f, 0x3c, 0xbd, 0x8d, 0x47, 0x6a, 0x0e, 0x2e, 0x66, 0xfe, 0x19, 0xfc, 0xb5, 0x82,
|
||||
0x2a, 0x46, 0x22, 0x83, 0x91, 0x68, 0xc1, 0x48, 0x64, 0x30, 0xa2, 0x2a, 0xff, 0x3d, 0x34, 0xf5,
|
||||
0xf7, 0xb2, 0x2d, 0xb0, 0x7b, 0x5d, 0xd9, 0xeb, 0x72, 0xbb, 0xd7, 0x65, 0x07, 0xb0, 0x21, 0xdf,
|
||||
0x64, 0xcb, 0x41, 0xf7, 0x8c, 0x41, 0xfb, 0x38, 0x2e, 0xa6, 0x94, 0x7b, 0xfc, 0x1f, 0x36, 0xb8,
|
||||
0x0b, 0x8c, 0x6e, 0x1c, 0x88, 0x78, 0xb4, 0x38, 0xad, 0xa8, 0x08, 0xe7, 0x62, 0xf8, 0xd0, 0xeb,
|
||||
0xca, 0x97, 0xb8, 0xbc, 0xa8, 0x88, 0x00, 0x6a, 0xce, 0x92, 0xc8, 0x73, 0x5a, 0x56, 0xbb, 0xc2,
|
||||
0xcb, 0x92, 0xb5, 0xa0, 0xf1, 0x2e, 0x89, 0x73, 0x11, 0xe7, 0x37, 0xf3, 0x54, 0x78, 0x1b, 0xf2,
|
||||
0xab, 0x0e, 0xd1, 0x8e, 0x81, 0xc8, 0x1e, 0x24, 0xc9, 0xbd, 0xae, 0x57, 0x91, 0x07, 0xeb, 0x10,
|
||||
0x9d, 0x5e, 0x34, 0x78, 0x55, 0xf9, 0xb5, 0x2c, 0xd9, 0x0e, 0x38, 0x44, 0x4b, 0x4d, 0xd2, 0x42,
|
||||
0x4b, 0xb6, 0x0f, 0x75, 0x7a, 0xeb, 0x4d, 0x18, 0x09, 0xaf, 0x2e, 0xe1, 0x45, 0xcd, 0x0e, 0x60,
|
||||
0x87, 0xd6, 0x22, 0xbb, 0x9e, 0x06, 0xf9, 0xe7, 0x24, 0x8b, 0x7a, 0x5d, 0xcf, 0x95, 0x0f, 0x5a,
|
||||
0xc1, 0xd9, 0x0b, 0xd8, 0x52, 0xd8, 0x55, 0x38, 0x9c, 0x5c, 0x05, 0x91, 0xf0, 0x40, 0x5e, 0xbd,
|
||||
0x84, 0xb2, 0xff, 0x61, 0x53, 0x21, 0xe7, 0xc1, 0x50, 0xdc, 0xf2, 0x4b, 0xaf, 0x21, 0xb7, 0x99,
|
||||
0xa0, 0x64, 0x61, 0x1a, 0x8a, 0x38, 0x57, 0x33, 0x36, 0xd5, 0x8c, 0x1a, 0xe4, 0x7f, 0x77, 0x60,
|
||||
0x8b, 0x9c, 0x46, 0x7d, 0x7d, 0x1c, 0x93, 0xab, 0x4e, 0xa1, 0xf6, 0x21, 0xcd, 0xc3, 0x24, 0x46,
|
||||
0xe9, 0xaa, 0xc6, 0x51, 0xdb, 0x50, 0xd0, 0xdc, 0xdd, 0x29, 0xb6, 0x9e, 0xc5, 0x79, 0x36, 0xe7,
|
||||
0x65, 0xe3, 0x9a, 0x31, 0xec, 0x3f, 0x1b, 0xc3, 0x59, 0x37, 0xc6, 0x7f, 0x00, 0x1a, 0x75, 0x4a,
|
||||
0x4b, 0x0d, 0x51, 0x52, 0x22, 0x86, 0x49, 0x2c, 0xc5, 0xae, 0x28, 0xb1, 0x35, 0x48, 0x37, 0x4a,
|
||||
0xf5, 0x97, 0x46, 0xa9, 0xad, 0x1a, 0xe5, 0xd9, 0x7c, 0x75, 0xc3, 0x7c, 0xff, 0x82, 0x7b, 0x9e,
|
||||
0x64, 0x43, 0x21, 0xbd, 0xee, 0xb6, 0x9c, 0xb6, 0xcb, 0x9f, 0x01, 0xdd, 0x3c, 0x60, 0x9a, 0x67,
|
||||
0x49, 0x94, 0xc6, 0x8a, 0x28, 0xfb, 0x27, 0xd0, 0xd4, 0x69, 0x25, 0xbb, 0x4d, 0xc4, 0xbc, 0xc8,
|
||||
0x04, 0x2d, 0xd9, 0x2e, 0x54, 0x1e, 0x82, 0xe9, 0xbd, 0xa2, 0xb5, 0xc2, 0x55, 0x71, 0x62, 0xbf,
|
||||
0xb4, 0xfc, 0x19, 0x6c, 0x1b, 0x0a, 0x61, 0xba, 0xec, 0x74, 0x6b, 0xd5, 0xe9, 0x4b, 0x4f, 0xb2,
|
||||
0x57, 0x9e, 0x44, 0xfe, 0xc6, 0xd2, 0xdf, 0x8e, 0xf2, 0x77, 0x59, 0xfb, 0x5f, 0x1d, 0xc9, 0x6e,
|
||||
0x37, 0xc8, 0x03, 0x22, 0x0b, 0x8d, 0x04, 0xe3, 0x22, 0xc1, 0x99, 0x91, 0x60, 0x55, 0xd1, 0xcd,
|
||||
0xa8, 0x49, 0xa7, 0x52, 0xac, 0x43, 0x44, 0x64, 0x54, 0x48, 0xa7, 0x94, 0x2f, 0x4b, 0xea, 0x1d,
|
||||
0x6a, 0xd2, 0x15, 0xb2, 0x0f, 0xcd, 0x8c, 0xa3, 0x36, 0xb9, 0x4a, 0xb1, 0x0e, 0xd1, 0xe9, 0x45,
|
||||
0x83, 0x94, 0xde, 0xe5, 0x65, 0x69, 0x4c, 0x5c, 0x37, 0x27, 0x26, 0x41, 0x50, 0xcc, 0x64, 0x88,
|
||||
0x1d, 0x4e, 0x4b, 0xca, 0x38, 0x2e, 0x67, 0x1c, 0x54, 0xc6, 0x71, 0x4d, 0xc6, 0xd1, 0x0c, 0x87,
|
||||
0xf2, 0xc0, 0x12, 0x4a, 0xe1, 0x40, 0x23, 0x1c, 0x2a, 0xbf, 0x26, 0x28, 0x59, 0xd0, 0xb4, 0xdb,
|
||||
0x54, 0x33, 0x6a, 0xd0, 0xe9, 0xde, 0xc7, 0xdd, 0xce, 0xa1, 0xfa, 0x61, 0xbe, 0xd2, 0x92, 0xfc,
|
||||
0xa9, 0x2a, 0x7f, 0x9d, 0xc7, 0x3f, 0x03, 0x00, 0x00, 0xff, 0xff, 0x38, 0x51, 0xff, 0xb4, 0x4d,
|
||||
0x07, 0x00, 0x00,
|
||||
}
|
@ -0,0 +1,89 @@
|
||||
syntax = "proto3";
|
||||
package open_im_sdk;//The package name to which the proto file belongs
|
||||
option go_package = "./sdk_ws;open_im_sdk";//The generated go pb file is in the current directory, and the package name is open_im_sdk
|
||||
|
||||
|
||||
message PullMessageBySeqListResp {
|
||||
int64 MaxSeq = 1;
|
||||
int64 MinSeq = 2;
|
||||
repeated GatherFormat SingleUserMsg = 3;
|
||||
repeated GatherFormat GroupUserMsg = 4;
|
||||
}
|
||||
message PullMessageBySeqListReq{
|
||||
repeated int64 seqList =1;
|
||||
}
|
||||
message GetMaxAndMinSeqReq {
|
||||
}
|
||||
message GetMaxAndMinSeqResp {
|
||||
int64 maxSeq = 1;
|
||||
int64 minSeq = 2;
|
||||
}
|
||||
message GatherFormat{
|
||||
// @inject_tag: json:"id"
|
||||
string ID = 1;
|
||||
// @inject_tag: json:"list"
|
||||
repeated MsgFormat List = 2;//detail msg
|
||||
}
|
||||
message MsgFormat{
|
||||
// @inject_tag: json:"sendID"
|
||||
string SendID = 1;
|
||||
// @inject_tag: json:"recvID"
|
||||
string RecvID = 2;
|
||||
// @inject_tag: json:"msgFrom"
|
||||
int32 MsgFrom = 3;
|
||||
// @inject_tag: json:"contentType"
|
||||
int32 ContentType = 4;
|
||||
// @inject_tag: json:"serverMsgID"
|
||||
string ServerMsgID = 5;
|
||||
// @inject_tag: json:"content"
|
||||
string Content = 6;
|
||||
// @inject_tag: json:"seq"
|
||||
int64 Seq = 7;
|
||||
// @inject_tag: json:"sendTime"
|
||||
int64 SendTime = 8;
|
||||
// @inject_tag: json:"senderPlatformID"
|
||||
int32 SenderPlatformID = 9;
|
||||
// @inject_tag: json:"senderNickName"
|
||||
string SenderNickName = 10;
|
||||
// @inject_tag: json:"senderFaceUrl"
|
||||
string SenderFaceURL = 11;
|
||||
// @inject_tag: json:"clientMsgID"
|
||||
string ClientMsgID = 12;
|
||||
}
|
||||
|
||||
message UserSendMsgReq {
|
||||
map<string,int32> Options= 1;
|
||||
string SenderNickName = 2;
|
||||
string SenderFaceURL = 3;
|
||||
int32 PlatformID = 4;
|
||||
int32 SessionType = 5;
|
||||
int32 MsgFrom = 6;
|
||||
int32 ContentType = 7;
|
||||
string RecvID = 8;
|
||||
repeated string ForceList = 9;
|
||||
string Content = 10;
|
||||
string ClientMsgID = 11;
|
||||
}
|
||||
|
||||
message UserSendMsgResp {
|
||||
string ServerMsgID = 1;
|
||||
string ClientMsgID = 2;
|
||||
int64 sendTime = 3;
|
||||
|
||||
}
|
||||
message MsgData {
|
||||
string sendID = 1;
|
||||
string recvID = 2;
|
||||
int32 sessionType = 3;
|
||||
int32 msgFrom = 4;
|
||||
int32 contentType = 5;
|
||||
string serverMsgID = 6;
|
||||
string content =7;
|
||||
int64 sendTime =8;
|
||||
int64 seq =9;
|
||||
int32 senderPlatformID =10;
|
||||
string senderNickName =11;
|
||||
string senderFaceURL =12;
|
||||
string clientMsgID =13;
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue