mirror of
https://gitee.com/Zhaoxin59/my-chat_-client.git
synced 2026-02-13 16:41:48 +08:00
add data Items
This commit is contained in:
@ -9,17 +9,18 @@ set(CMAKE_AUTORCC ON)
|
|||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
# 查找Qt版本
|
# set(CMAKE_PREFIX_PATH C:/src/vcpkg/installed/x64-windows)
|
||||||
find_package(Qt6 COMPONENTS Widgets QUIET)
|
|
||||||
if(NOT Qt6_FOUND)
|
|
||||||
find_package(Qt5 COMPONENTS Widgets REQUIRED)
|
|
||||||
set(QT_VERSION_MAJOR 5)
|
|
||||||
else()
|
|
||||||
set(QT_VERSION_MAJOR 6)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
file(GLOB PROJECT_SOURCES
|
# 查找Qt版本
|
||||||
model/*.h
|
find_package(Qt6 COMPONENTS Protobuf Widgets QUIET)
|
||||||
|
set(QT_VERSION_MAJOR 6)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
file(GLOB PB_FILES
|
||||||
|
proto/*.proto
|
||||||
|
)
|
||||||
|
file(GLOB_RECURSE PROJECT_SOURCES
|
||||||
*.cpp
|
*.cpp
|
||||||
*.h
|
*.h
|
||||||
*.ui
|
*.ui
|
||||||
@ -37,12 +38,13 @@ if(ANDROID)
|
|||||||
# set_property(TARGET ClientChat APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
|
# set_property(TARGET ClientChat APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
|
||||||
else()
|
else()
|
||||||
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
|
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
|
||||||
|
|
||||||
qt_add_executable(ClientChat
|
qt_add_executable(ClientChat
|
||||||
MANUAL_FINALIZATION
|
MANUAL_FINALIZATION
|
||||||
${PROJECT_SOURCES}
|
${PROJECT_SOURCES}
|
||||||
)
|
)
|
||||||
else()
|
|
||||||
add_executable(ClientChat ${PROJECT_SOURCES})
|
qt_add_protobuf(ClientChat PROTO_FILES ${PB_FILES})
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|||||||
2
debug.h
2
debug.h
@ -1,7 +1,7 @@
|
|||||||
#ifndef DEBUG_H
|
#ifndef DEBUG_H
|
||||||
#define DEBUG_H
|
#define DEBUG_H
|
||||||
|
|
||||||
#define TEST_UI 1
|
#define TEST_UI 0
|
||||||
|
|
||||||
#define TEST_SKIP_LOGIN 1
|
#define TEST_SKIP_LOGIN 1
|
||||||
|
|
||||||
|
|||||||
90
model/data.h
90
model/data.h
@ -8,6 +8,8 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QUuid>
|
#include <QUuid>
|
||||||
|
|
||||||
|
#include "base.qpb.h"
|
||||||
|
|
||||||
// 创建命名空间
|
// 创建命名空间
|
||||||
namespace model {
|
namespace model {
|
||||||
///////////////////////////
|
///////////////////////////
|
||||||
@ -87,6 +89,21 @@ public:
|
|||||||
QString description = ""; //用户签名
|
QString description = ""; //用户签名
|
||||||
QString phone = ""; //手机号码
|
QString phone = ""; //手机号码
|
||||||
QIcon avatar; //用户头像
|
QIcon avatar; //用户头像
|
||||||
|
|
||||||
|
//从protobuffer的UserInfo对象,转换为当前代码的UserInfo对象
|
||||||
|
void load(const bite_im::UserInfo& userInfo) {
|
||||||
|
this->userId = userInfo.userId();
|
||||||
|
this->nickname = userInfo.nickname();
|
||||||
|
this->phone = userInfo.phone();
|
||||||
|
this->description = userInfo.description();
|
||||||
|
if (userInfo.avatar().isEmpty()) {
|
||||||
|
//使用默认的头像即可
|
||||||
|
this->avatar = QIcon(":resource/image/defaultAvatar.png");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this->avatar = makeIcon(userInfo.avatar());
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
///////////////////////////
|
///////////////////////////
|
||||||
@ -126,6 +143,52 @@ static Message makeMessage(MessageType messageType, const QString& chatSessionId
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void load(const bite_im::MessageInfo& messageInfo) {
|
||||||
|
this->messageId = messageInfo.messageId();
|
||||||
|
this->chatSessionId = messageInfo.chatSessionId();
|
||||||
|
this->time = formatTime(messageInfo.timestamp());
|
||||||
|
this->sender.load(messageInfo.sender());
|
||||||
|
|
||||||
|
//设置消息的类型
|
||||||
|
auto type = messageInfo.message().messageType();
|
||||||
|
if (type == bite_im::MessageTypeGadget::MessageType::STRING) {
|
||||||
|
this->messageType = TEXT_TYPE;
|
||||||
|
this->content = messageInfo.message().stringMessage().content().toUtf8();
|
||||||
|
}
|
||||||
|
else if (type == bite_im::MessageTypeGadget::MessageType::IMAGE) {
|
||||||
|
this->messageType = IMAGE_TYPE;
|
||||||
|
if (messageInfo.message().imageMessage().hasImageContent()) {
|
||||||
|
this->content = messageInfo.message().imageMessage().imageContent();
|
||||||
|
}
|
||||||
|
if (messageInfo.message().imageMessage().hasFileId()) {
|
||||||
|
this->fileId = messageInfo.message().imageMessage().fileId();
|
||||||
|
}else if (type == bite_im::MessageTypeGadget::MessageType::FILE) {
|
||||||
|
this->messageType = FILE_TYPE;
|
||||||
|
if (messageInfo.message().fileMessage().hasFileContents()) {
|
||||||
|
this->content = messageInfo.message().fileMessage().fileContents();
|
||||||
|
}
|
||||||
|
if (messageInfo.message().fileMessage().hasFileId()) {
|
||||||
|
this->fileId = messageInfo.message().fileMessage().fileId();
|
||||||
|
}
|
||||||
|
this->fileName = messageInfo.message().fileMessage().fileName();
|
||||||
|
}
|
||||||
|
else if (type == bite_im::MessageTypeGadget::MessageType::SPEECH) {
|
||||||
|
this->messageType = SPEECH_TYPE;
|
||||||
|
if (messageInfo.message().speechMessage().hasFileContents()) {
|
||||||
|
this->content = messageInfo.message().speechMessage().fileContents();
|
||||||
|
}
|
||||||
|
if (messageInfo.message().speechMessage().hasFileId()) {
|
||||||
|
this->fileId = messageInfo.message().speechMessage().fileId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// 错误的类型, 啥都不做了, 只是打印一个日志
|
||||||
|
LOG() << "非法的消息类型! type=" << type;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static QString makeId() {
|
static QString makeId() {
|
||||||
@ -215,6 +278,33 @@ public:
|
|||||||
Message lastMessage; //表示会话的最新消息
|
Message lastMessage; //表示会话的最新消息
|
||||||
QIcon avatar; //会话的头像(单聊或群聊)
|
QIcon avatar; //会话的头像(单聊或群聊)
|
||||||
QString userId = ""; //(单聊为对方的id,群聊为"")
|
QString userId = ""; //(单聊为对方的id,群聊为"")
|
||||||
|
|
||||||
|
|
||||||
|
void load(bite_im::ChatSessionInfo& chatSessionInfo) {
|
||||||
|
this->chatSessionId = chatSessionInfo.chatSessionId();
|
||||||
|
this->chatSessionName = chatSessionInfo.chatSessionName();
|
||||||
|
if (chatSessionInfo.hasSingleChatFriendId()) {
|
||||||
|
this->userId = chatSessionInfo.singleChatFriendId();
|
||||||
|
}
|
||||||
|
if (chatSessionInfo.hasPrevMessage()) {
|
||||||
|
lastMessage.load(chatSessionInfo.prevMessage());
|
||||||
|
}
|
||||||
|
if (chatSessionInfo.hasAvatar() && !chatSessionInfo.avatar().isEmpty()) {
|
||||||
|
//如果有头像,则设置这个头像
|
||||||
|
this->avatar = makeIcon(chatSessionInfo.avatar());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//如果没有,则会根据是单聊还是群聊,使用不同的默认头像
|
||||||
|
if (userId != "") {
|
||||||
|
//单聊
|
||||||
|
this->avatar = QIcon(":/resource/image/defaultAvatar.png");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//群聊
|
||||||
|
this->avatar = QIcon(":/resource/image/groupAvatar.png");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} //end namespace model
|
} //end namespace model
|
||||||
|
|||||||
19
model/datacenter.cpp
Normal file
19
model/datacenter.cpp
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#include "datacenter.h"
|
||||||
|
|
||||||
|
namespace model
|
||||||
|
{
|
||||||
|
DataCenter* DataCenter::instance = nullptr;
|
||||||
|
|
||||||
|
DataCenter* DataCenter::getInstance()
|
||||||
|
{
|
||||||
|
if (instance == nullptr) {
|
||||||
|
instance = new DataCenter();
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
DataCenter::DataCenter()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
56
model/datacenter.h
Normal file
56
model/datacenter.h
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
#include "data.h"
|
||||||
|
|
||||||
|
namespace model
|
||||||
|
{
|
||||||
|
|
||||||
|
class DataCenter : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
static DataCenter* getInstance();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĺ͡<C4BA>
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="a"><3E><>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD></param>
|
||||||
|
/// <param name="b"><3E>ڶ<EFBFBD><DAB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></param>
|
||||||
|
/// <returns><3E><><EFBFBD><EFBFBD> a + b <20>Ľ<EFBFBD><C4BD><EFBFBD></returns>
|
||||||
|
/*int add(int a, int b) {
|
||||||
|
return a + b;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
private:
|
||||||
|
DataCenter();
|
||||||
|
|
||||||
|
static DataCenter* instance;
|
||||||
|
|
||||||
|
//<2F>г<EFBFBD>DataCenter<65><72>Ҫ<EFBFBD><D2AA>֯<EFBFBD><D6AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
//<2F><>ǰ<EFBFBD>ͻ<EFBFBD><CDBB>˵<EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD>ĵ<EFBFBD>¼<EFBFBD>ỰId
|
||||||
|
QString loginSessionId;
|
||||||
|
|
||||||
|
//<2F><>ǰ<EFBFBD><C7B0><EFBFBD>û<EFBFBD><C3BB><EFBFBD>Ϣ
|
||||||
|
UserInfo* myself = nullptr;
|
||||||
|
|
||||||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>
|
||||||
|
QList<UserInfo>* firendList = nullptr;
|
||||||
|
|
||||||
|
//<2F>Ự<EFBFBD>б<EFBFBD>
|
||||||
|
QList<ChatSessionInfo>* chatSessionList = nullptr;
|
||||||
|
|
||||||
|
//<2F><>¼<EFBFBD><C2BC>ǰѡ<C7B0>еĻỰ<C4BB><E1BBB0><EFBFBD>ĸ<EFBFBD>
|
||||||
|
QString currentChatSession = "";
|
||||||
|
|
||||||
|
//<2F><>¼ÿ<C2BC><C3BF><EFBFBD>Ự<EFBFBD>У<EFBFBD><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Щ<EFBFBD><D0A9>Ա
|
||||||
|
QHash<QString, QList<UserInfo>>* memberList = nullptr;//unordered_map
|
||||||
|
|
||||||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĺ<EFBFBD><C4BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>
|
||||||
|
QList<UserInfo>* applyList = nullptr;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
};
|
||||||
|
} //end namespace model
|
||||||
82
proto/base.proto
Normal file
82
proto/base.proto
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
package bite_im;
|
||||||
|
option cc_generic_services = true;
|
||||||
|
|
||||||
|
//用户信息结构
|
||||||
|
message UserInfo {
|
||||||
|
string user_id = 1;//用户ID
|
||||||
|
string nickname = 2;//昵称
|
||||||
|
string description = 3;//个人签名/描述
|
||||||
|
string phone = 4; //绑定手机号
|
||||||
|
bytes avatar = 5;//头像照片,文件内容使用二进制
|
||||||
|
}
|
||||||
|
|
||||||
|
//聊天会话信息
|
||||||
|
message ChatSessionInfo {
|
||||||
|
//群聊会话不需要设置,单聊会话设置为对方用户ID
|
||||||
|
optional string single_chat_friend_id = 1;
|
||||||
|
string chat_session_id = 2; //会话ID
|
||||||
|
string chat_session_name = 3;//会话名称git
|
||||||
|
//会话上一条消息,新建的会话没有最新消息
|
||||||
|
optional MessageInfo prev_message = 4;
|
||||||
|
//会话头像 --群聊会话不需要,直接由前端固定渲染,单聊就是对方的头像
|
||||||
|
optional bytes avatar = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
//消息类型
|
||||||
|
enum MessageType {
|
||||||
|
STRING = 0;
|
||||||
|
IMAGE = 1;
|
||||||
|
FILE = 2;
|
||||||
|
SPEECH = 3;
|
||||||
|
}
|
||||||
|
message StringMessageInfo {
|
||||||
|
string content = 1;//文字聊天内容
|
||||||
|
}
|
||||||
|
message ImageMessageInfo {
|
||||||
|
//图片文件id,客户端发送的时候不用设置,由transmit服务器进行设置后交给storage的时候设置
|
||||||
|
optional string file_id = 1;
|
||||||
|
//图片数据,在ES中存储消息的时候只要id不要文件数据, 服务端转发的时候需要原样转发
|
||||||
|
optional bytes image_content = 2;
|
||||||
|
}
|
||||||
|
message FileMessageInfo {
|
||||||
|
optional string file_id = 1;//文件id,客户端发送的时候不用设置
|
||||||
|
optional int64 file_size = 2;//文件大小
|
||||||
|
optional string file_name = 3;//文件名称
|
||||||
|
//文件数据,在ES中存储消息的时候只要id和元信息,不要文件数据, 服务端转发的时候也不需要填充
|
||||||
|
optional bytes file_contents = 4;
|
||||||
|
}
|
||||||
|
message SpeechMessageInfo {
|
||||||
|
//语音文件id,客户端发送的时候不用设置
|
||||||
|
optional string file_id = 1;
|
||||||
|
//文件数据,在ES中存储消息的时候只要id不要文件数据, 服务端转发的时候也不需要填充
|
||||||
|
optional bytes file_contents = 2;
|
||||||
|
}
|
||||||
|
message MessageContent {
|
||||||
|
MessageType message_type = 1; //消息类型
|
||||||
|
oneof msg_content {
|
||||||
|
StringMessageInfo string_message = 2;//文字消息
|
||||||
|
FileMessageInfo file_message = 3;//文件消息
|
||||||
|
SpeechMessageInfo speech_message = 4;//语音消息
|
||||||
|
ImageMessageInfo image_message = 5;//图片消息
|
||||||
|
};
|
||||||
|
}
|
||||||
|
//消息结构
|
||||||
|
message MessageInfo {
|
||||||
|
string message_id = 1;//消息ID
|
||||||
|
string chat_session_id = 2;//消息所属聊天会话ID
|
||||||
|
int64 timestamp = 3;//消息产生时间
|
||||||
|
UserInfo sender = 4;//消息发送者信息
|
||||||
|
MessageContent message = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
message FileDownloadData {
|
||||||
|
string file_id = 1;
|
||||||
|
bytes file_content = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message FileUploadData {
|
||||||
|
string file_name = 1; //文件名称
|
||||||
|
int64 file_size = 2; //文件大小
|
||||||
|
bytes file_content = 3; //文件数据
|
||||||
|
}
|
||||||
64
proto/file.proto
Normal file
64
proto/file.proto
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
package bite_im;
|
||||||
|
import "base.proto";
|
||||||
|
|
||||||
|
option cc_generic_services = true;
|
||||||
|
|
||||||
|
message GetSingleFileReq {
|
||||||
|
string request_id = 1;
|
||||||
|
string file_id = 2;
|
||||||
|
optional string user_id = 3;
|
||||||
|
optional string session_id = 4;
|
||||||
|
}
|
||||||
|
message GetSingleFileRsp {
|
||||||
|
string request_id = 1;
|
||||||
|
bool success = 2;
|
||||||
|
string errmsg = 3;
|
||||||
|
optional FileDownloadData file_data = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetMultiFileReq {
|
||||||
|
string request_id = 1;
|
||||||
|
optional string user_id = 2;
|
||||||
|
optional string session_id = 3;
|
||||||
|
repeated string file_id_list = 4;
|
||||||
|
}
|
||||||
|
message GetMultiFileRsp {
|
||||||
|
string request_id = 1;
|
||||||
|
bool success = 2;
|
||||||
|
string errmsg = 3;
|
||||||
|
map<string, FileDownloadData> file_data = 4;//文件ID与文件数据的映射map
|
||||||
|
}
|
||||||
|
|
||||||
|
message PutSingleFileReq {
|
||||||
|
string request_id = 1; //请求ID,作为处理流程唯一标识
|
||||||
|
optional string user_id = 2;
|
||||||
|
optional string session_id = 3;
|
||||||
|
FileUploadData file_data = 4;
|
||||||
|
}
|
||||||
|
message PutSingleFileRsp {
|
||||||
|
string request_id = 1;
|
||||||
|
bool success = 2;
|
||||||
|
string errmsg = 3;
|
||||||
|
FileMessageInfo file_info = 4; //返回了文件组织的元信息
|
||||||
|
}
|
||||||
|
|
||||||
|
message PutMultiFileReq {
|
||||||
|
string request_id = 1;
|
||||||
|
optional string user_id = 2;
|
||||||
|
optional string session_id = 3;
|
||||||
|
repeated FileUploadData file_data = 4;
|
||||||
|
}
|
||||||
|
message PutMultiFileRsp {
|
||||||
|
string request_id = 1;
|
||||||
|
bool success = 2;
|
||||||
|
string errmsg = 3;
|
||||||
|
repeated FileMessageInfo file_info = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
service FileService {
|
||||||
|
rpc GetSingleFile(GetSingleFileReq) returns (GetSingleFileRsp);
|
||||||
|
rpc GetMultiFile(GetMultiFileReq) returns (GetMultiFileRsp);
|
||||||
|
rpc PutSingleFile(PutSingleFileReq) returns (PutSingleFileRsp);
|
||||||
|
rpc PutMultiFile(PutMultiFileReq) returns (PutMultiFileRsp);
|
||||||
|
}
|
||||||
155
proto/friend.proto
Normal file
155
proto/friend.proto
Normal file
@ -0,0 +1,155 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
package bite_im;
|
||||||
|
import "base.proto";
|
||||||
|
|
||||||
|
option cc_generic_services = true;
|
||||||
|
|
||||||
|
//--------------------------------------
|
||||||
|
//好友列表获取
|
||||||
|
message GetFriendListReq {
|
||||||
|
string request_id = 1; // 请求标识ID
|
||||||
|
optional string user_id = 2; // 当前请求的发起者用户ID
|
||||||
|
optional string session_id = 3; //登录会话ID--用于网关进行身份识别--其他子服务用不到
|
||||||
|
}
|
||||||
|
message GetFriendListRsp {
|
||||||
|
string request_id = 1;
|
||||||
|
bool success = 2;
|
||||||
|
string errmsg = 3;
|
||||||
|
repeated UserInfo friend_list = 4; //要返回的用户信息
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------
|
||||||
|
//好友删除
|
||||||
|
message FriendRemoveReq {
|
||||||
|
string request_id = 1;
|
||||||
|
optional string user_id = 2; //当前用户ID
|
||||||
|
optional string session_id = 3;
|
||||||
|
string peer_id = 4; //要删除的好友ID
|
||||||
|
}
|
||||||
|
message FriendRemoveRsp {
|
||||||
|
string request_id = 1;
|
||||||
|
bool success = 2;
|
||||||
|
string errmsg = 3;
|
||||||
|
}
|
||||||
|
//--------------------------------------
|
||||||
|
//添加好友--发送好友申请
|
||||||
|
message FriendAddReq {
|
||||||
|
string request_id = 1;
|
||||||
|
optional string session_id = 2;
|
||||||
|
optional string user_id = 3;//申请人id
|
||||||
|
string respondent_id = 4;//被申请人id
|
||||||
|
}
|
||||||
|
message FriendAddRsp {
|
||||||
|
string request_id = 1;
|
||||||
|
bool success = 2;
|
||||||
|
string errmsg = 3;
|
||||||
|
string notify_event_id = 4;//通知事件id
|
||||||
|
}
|
||||||
|
//--------------------------------------
|
||||||
|
//好友申请的处理
|
||||||
|
message FriendAddProcessReq {
|
||||||
|
string request_id = 1;
|
||||||
|
string notify_event_id = 2;//通知事件id
|
||||||
|
bool agree = 3;//是否同意好友申请
|
||||||
|
string apply_user_id = 4; //申请人的用户id
|
||||||
|
optional string session_id = 5;
|
||||||
|
optional string user_id = 6; // 被申请人
|
||||||
|
}
|
||||||
|
// +++++++++++++++++++++++++++++++++
|
||||||
|
message FriendAddProcessRsp {
|
||||||
|
string request_id = 1;
|
||||||
|
bool success = 2;
|
||||||
|
string errmsg = 3;
|
||||||
|
// 同意后会创建会话,向网关返回会话信息,用于通知双方会话的建立,这个字段客户端不需要关注
|
||||||
|
optional string new_session_id = 4;
|
||||||
|
}
|
||||||
|
//--------------------------------------
|
||||||
|
//获取待处理的,申请自己好友的信息列表
|
||||||
|
message GetPendingFriendEventListReq {
|
||||||
|
string request_id = 1;
|
||||||
|
optional string session_id = 2;
|
||||||
|
optional string user_id = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message FriendEvent {
|
||||||
|
optional string event_id = 1;
|
||||||
|
UserInfo sender = 3;
|
||||||
|
}
|
||||||
|
message GetPendingFriendEventListRsp {
|
||||||
|
string request_id = 1;
|
||||||
|
bool success = 2;
|
||||||
|
string errmsg = 3;
|
||||||
|
repeated FriendEvent event = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------
|
||||||
|
//好友搜索
|
||||||
|
message FriendSearchReq {
|
||||||
|
string request_id = 1;
|
||||||
|
string search_key = 2;//就是名称模糊匹配关键字
|
||||||
|
optional string session_id = 3;
|
||||||
|
optional string user_id = 4;
|
||||||
|
}
|
||||||
|
message FriendSearchRsp {
|
||||||
|
string request_id = 1;
|
||||||
|
bool success = 2;
|
||||||
|
string errmsg = 3;
|
||||||
|
repeated UserInfo user_info = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------
|
||||||
|
//会话列表获取
|
||||||
|
message GetChatSessionListReq {
|
||||||
|
string request_id = 1;
|
||||||
|
optional string session_id = 2;
|
||||||
|
optional string user_id = 3;
|
||||||
|
}
|
||||||
|
message GetChatSessionListRsp {
|
||||||
|
string request_id = 1;
|
||||||
|
bool success = 2;
|
||||||
|
string errmsg = 3;
|
||||||
|
repeated ChatSessionInfo chat_session_info_list = 4;
|
||||||
|
}
|
||||||
|
//--------------------------------------
|
||||||
|
//创建会话
|
||||||
|
message ChatSessionCreateReq {
|
||||||
|
string request_id = 1;
|
||||||
|
optional string session_id = 2;
|
||||||
|
optional string user_id = 3;
|
||||||
|
string chat_session_name = 4;
|
||||||
|
//需要注意的是,这个列表中也必须包含创建者自己的用户ID
|
||||||
|
repeated string member_id_list = 5;
|
||||||
|
}
|
||||||
|
message ChatSessionCreateRsp {
|
||||||
|
string request_id = 1;
|
||||||
|
bool success = 2;
|
||||||
|
string errmsg = 3;
|
||||||
|
//这个字段属于后台之间的数据,给前端回复的时候不需要这个字段,会话信息通过通知进行发送
|
||||||
|
optional ChatSessionInfo chat_session_info = 4;
|
||||||
|
}
|
||||||
|
//--------------------------------------
|
||||||
|
//获取会话成员列表
|
||||||
|
message GetChatSessionMemberReq {
|
||||||
|
string request_id = 1;
|
||||||
|
optional string session_id = 2;
|
||||||
|
optional string user_id = 3;
|
||||||
|
string chat_session_id = 4;
|
||||||
|
}
|
||||||
|
message GetChatSessionMemberRsp {
|
||||||
|
string request_id = 1;
|
||||||
|
bool success = 2;
|
||||||
|
string errmsg = 3;
|
||||||
|
repeated UserInfo member_info_list = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
service FriendService {
|
||||||
|
rpc GetFriendList(GetFriendListReq) returns (GetFriendListRsp);
|
||||||
|
rpc FriendRemove(FriendRemoveReq) returns (FriendRemoveRsp);
|
||||||
|
rpc FriendAdd(FriendAddReq) returns (FriendAddRsp);
|
||||||
|
rpc FriendAddProcess(FriendAddProcessReq) returns (FriendAddProcessRsp);
|
||||||
|
rpc FriendSearch(FriendSearchReq) returns (FriendSearchRsp);
|
||||||
|
rpc GetChatSessionList(GetChatSessionListReq) returns (GetChatSessionListRsp);
|
||||||
|
rpc ChatSessionCreate(ChatSessionCreateReq) returns (ChatSessionCreateRsp);
|
||||||
|
rpc GetChatSessionMember(GetChatSessionMemberReq) returns (GetChatSessionMemberRsp);
|
||||||
|
rpc GetPendingFriendEventList(GetPendingFriendEventListReq) returns (GetPendingFriendEventListRsp);
|
||||||
|
}
|
||||||
53
proto/gateway.proto
Normal file
53
proto/gateway.proto
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
package bite_im;
|
||||||
|
option cc_generic_services = true;
|
||||||
|
|
||||||
|
message ClientAuthenticationReq {
|
||||||
|
string request_id = 1;
|
||||||
|
string session_id = 2; // 用于向服务器表明当前长连接客户端的身份
|
||||||
|
}
|
||||||
|
|
||||||
|
//在客户端与网关服务器的通信中,使用HTTP协议进行通信
|
||||||
|
// 通信时采用POST请求作为请求方法
|
||||||
|
// 通信时,正文采用protobuf作为正文协议格式,具体内容字段以前边各个文件中定义的字段格式为准
|
||||||
|
/* 以下是HTTP请求的功能与接口路径对应关系:
|
||||||
|
SERVICE HTTP PATH:
|
||||||
|
{
|
||||||
|
获取随机验证码 /service/user/get_random_verify_code
|
||||||
|
获取短信验证码 /service/user/get_phone_verify_code
|
||||||
|
用户名密码注册 /service/user/username_register
|
||||||
|
用户名密码登录 /service/user/username_login
|
||||||
|
手机号码注册 /service/user/phone_register
|
||||||
|
手机号码登录 /service/user/phone_login
|
||||||
|
获取个人信息 /service/user/get_user_info
|
||||||
|
修改头像 /service/user/set_avatar
|
||||||
|
修改昵称 /service/user/set_nickname
|
||||||
|
修改签名 /service/user/set_description
|
||||||
|
修改绑定手机 /service/user/set_phone
|
||||||
|
|
||||||
|
获取好友列表 /service/friend/get_friend_list
|
||||||
|
获取好友信息 /service/friend/get_friend_info
|
||||||
|
发送好友申请 /service/friend/add_friend_apply
|
||||||
|
好友申请处理 /service/friend/add_friend_process
|
||||||
|
删除好友 /service/friend/remove_friend
|
||||||
|
搜索用户 /service/friend/search_friend
|
||||||
|
获取指定用户的消息会话列表 /service/friend/get_chat_session_list
|
||||||
|
创建消息会话 /service/friend/create_chat_session
|
||||||
|
获取消息会话成员列表 /service/friend/get_chat_session_member
|
||||||
|
获取待处理好友申请事件列表 /service/friend/get_pending_friend_events
|
||||||
|
|
||||||
|
获取历史消息/离线消息列表 /service/message_storage/get_history
|
||||||
|
获取最近N条消息列表 /service/message_storage/get_recent
|
||||||
|
搜索历史消息 /service/message_storage/search_history
|
||||||
|
|
||||||
|
发送消息 /service/message_transmit/new_message
|
||||||
|
|
||||||
|
获取单个文件数据 /service/file/get_single_file
|
||||||
|
获取多个文件数据 /service/file/get_multi_file
|
||||||
|
发送单个文件 /service/file/put_single_file
|
||||||
|
发送多个文件 /service/file/put_multi_file
|
||||||
|
|
||||||
|
语音转文字 /service/speech/recognition
|
||||||
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
55
proto/message.proto
Normal file
55
proto/message.proto
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
package bite_im;
|
||||||
|
import "base.proto";
|
||||||
|
|
||||||
|
option cc_generic_services = true;
|
||||||
|
|
||||||
|
message GetHistoryMsgReq {
|
||||||
|
string request_id = 1;
|
||||||
|
string chat_session_id = 2;
|
||||||
|
int64 start_time = 3;
|
||||||
|
int64 over_time = 4;
|
||||||
|
optional string user_id = 5;
|
||||||
|
optional string session_id = 6;
|
||||||
|
}
|
||||||
|
message GetHistoryMsgRsp {
|
||||||
|
string request_id = 1;
|
||||||
|
bool success = 2;
|
||||||
|
string errmsg = 3;
|
||||||
|
repeated MessageInfo msg_list = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetRecentMsgReq {
|
||||||
|
string request_id = 1;
|
||||||
|
string chat_session_id = 2;
|
||||||
|
int64 msg_count = 3;
|
||||||
|
optional int64 cur_time = 4;//用于扩展获取指定时间前的n条消息
|
||||||
|
optional string user_id = 5;
|
||||||
|
optional string session_id = 6;
|
||||||
|
}
|
||||||
|
message GetRecentMsgRsp {
|
||||||
|
string request_id = 1;
|
||||||
|
bool success = 2;
|
||||||
|
string errmsg = 3;
|
||||||
|
repeated MessageInfo msg_list = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
message MsgSearchReq {
|
||||||
|
string request_id = 1;
|
||||||
|
optional string user_id = 2;
|
||||||
|
optional string session_id = 3;
|
||||||
|
string chat_session_id = 4;
|
||||||
|
string search_key = 5;
|
||||||
|
}
|
||||||
|
message MsgSearchRsp {
|
||||||
|
string request_id = 1;
|
||||||
|
bool success = 2;
|
||||||
|
string errmsg = 3;
|
||||||
|
repeated MessageInfo msg_list = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
service MsgStorageService {
|
||||||
|
rpc GetHistoryMsg(GetHistoryMsgReq) returns (GetHistoryMsgRsp);
|
||||||
|
rpc GetRecentMsg(GetRecentMsgReq) returns (GetRecentMsgRsp);
|
||||||
|
rpc MsgSearch(MsgSearchReq) returns (MsgSearchRsp);
|
||||||
|
}
|
||||||
23
proto/speech.proto
Normal file
23
proto/speech.proto
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
package bite_im;
|
||||||
|
|
||||||
|
option cc_generic_services = true;
|
||||||
|
|
||||||
|
message SpeechRecognitionReq {
|
||||||
|
string request_id = 1; //请求ID
|
||||||
|
bytes speech_content = 2; //语音数据
|
||||||
|
optional string user_id = 3; //用户ID
|
||||||
|
optional string session_id = 4; //登录会话ID -- 网关进行身份鉴权
|
||||||
|
}
|
||||||
|
|
||||||
|
message SpeechRecognitionRsp {
|
||||||
|
string request_id = 1; //请求ID
|
||||||
|
bool success = 2; //请求处理结果标志
|
||||||
|
optional string errmsg = 3; //失败原因
|
||||||
|
optional string recognition_result = 4; //识别后的文字数据
|
||||||
|
}
|
||||||
|
|
||||||
|
//语音识别Rpc服务及接口的定义
|
||||||
|
service SpeechService {
|
||||||
|
rpc SpeechRecognition(SpeechRecognitionReq) returns (SpeechRecognitionRsp);
|
||||||
|
}
|
||||||
32
proto/transmite.proto
Normal file
32
proto/transmite.proto
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
package bite_im;
|
||||||
|
import "base.proto";
|
||||||
|
|
||||||
|
option cc_generic_services = true;
|
||||||
|
|
||||||
|
//这个用于和网关进行通信
|
||||||
|
message NewMessageReq {
|
||||||
|
string request_id = 1; //请求ID -- 全链路唯一标识
|
||||||
|
optional string user_id = 2;
|
||||||
|
optional string session_id = 3;//客户端身份识别信息 -- 这就是消息发送者
|
||||||
|
string chat_session_id = 4; //聊天会话ID -- 标识了当前消息属于哪个会话,应该转发给谁
|
||||||
|
MessageContent message = 5; // 消息内容--消息类型+内容
|
||||||
|
}
|
||||||
|
message NewMessageRsp {
|
||||||
|
string request_id = 1;
|
||||||
|
bool success = 2;
|
||||||
|
string errmsg = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
//这个用于内部的通信,生成完整的消息信息,并获取消息的转发人员列表
|
||||||
|
message GetTransmitTargetRsp {
|
||||||
|
string request_id = 1;
|
||||||
|
bool success = 2;
|
||||||
|
string errmsg = 3;
|
||||||
|
MessageInfo message = 4; // 组织好的消息结构 --
|
||||||
|
repeated string target_id_list = 5; //消息的转发目标列表
|
||||||
|
}
|
||||||
|
|
||||||
|
service MsgTransmitService {
|
||||||
|
rpc GetTransmitTarget(NewMessageReq) returns (GetTransmitTargetRsp);
|
||||||
|
}
|
||||||
166
proto/user.proto
Normal file
166
proto/user.proto
Normal file
@ -0,0 +1,166 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
package bite_im;
|
||||||
|
import "base.proto";
|
||||||
|
option cc_generic_services = true;
|
||||||
|
|
||||||
|
//----------------------------
|
||||||
|
//用户名注册
|
||||||
|
message UserRegisterReq {
|
||||||
|
string request_id = 1;
|
||||||
|
string nickname = 2;
|
||||||
|
string password = 3;
|
||||||
|
optional string verify_code_id = 4; //目前客户端实现了本地验证,该字段没用了
|
||||||
|
optional string verify_code = 5;//目前客户端实现了本地验证,该字段没用了
|
||||||
|
}
|
||||||
|
message UserRegisterRsp {
|
||||||
|
string request_id = 1;
|
||||||
|
bool success = 2;
|
||||||
|
string errmsg = 3;
|
||||||
|
}
|
||||||
|
//----------------------------
|
||||||
|
//用户名登录
|
||||||
|
message UserLoginReq {
|
||||||
|
string request_id = 1;
|
||||||
|
string nickname = 2;
|
||||||
|
string password = 3;
|
||||||
|
optional string verify_code_id = 4;
|
||||||
|
optional string verify_code = 5;
|
||||||
|
}
|
||||||
|
message UserLoginRsp {
|
||||||
|
string request_id = 1;
|
||||||
|
bool success = 2;
|
||||||
|
string errmsg = 3;
|
||||||
|
string login_session_id = 4;
|
||||||
|
}
|
||||||
|
//----------------------------
|
||||||
|
//手机号验证码获取
|
||||||
|
message PhoneVerifyCodeReq {
|
||||||
|
string request_id = 1;
|
||||||
|
string phone_number = 2;
|
||||||
|
}
|
||||||
|
message PhoneVerifyCodeRsp {
|
||||||
|
string request_id = 1;
|
||||||
|
bool success = 2;
|
||||||
|
string errmsg = 3;
|
||||||
|
string verify_code_id = 4;
|
||||||
|
}
|
||||||
|
//----------------------------
|
||||||
|
//手机号注册
|
||||||
|
message PhoneRegisterReq {
|
||||||
|
string request_id = 1;
|
||||||
|
string phone_number = 2;
|
||||||
|
string verify_code_id = 3;
|
||||||
|
string verify_code = 4;
|
||||||
|
}
|
||||||
|
message PhoneRegisterRsp {
|
||||||
|
string request_id = 1;
|
||||||
|
bool success = 2;
|
||||||
|
string errmsg = 3;
|
||||||
|
}
|
||||||
|
//----------------------------
|
||||||
|
//手机号登录
|
||||||
|
message PhoneLoginReq {
|
||||||
|
string request_id = 1;
|
||||||
|
string phone_number = 2;
|
||||||
|
string verify_code_id = 3;
|
||||||
|
string verify_code = 4;
|
||||||
|
}
|
||||||
|
message PhoneLoginRsp {
|
||||||
|
string request_id = 1;
|
||||||
|
bool success = 2;
|
||||||
|
string errmsg = 3;
|
||||||
|
string login_session_id = 4;
|
||||||
|
}
|
||||||
|
//个人信息获取-这个只用于获取当前登录用户的信息
|
||||||
|
// 客户端传递的时候只需要填充session_id即可
|
||||||
|
//其他个人/好友信息的获取在好友操作中完成
|
||||||
|
message GetUserInfoReq {
|
||||||
|
string request_id = 1;
|
||||||
|
optional string user_id = 2; // 这个字段是网关进行身份鉴权之后填入的字段
|
||||||
|
optional string session_id = 3; // 进行客户端身份识别的关键字段
|
||||||
|
}
|
||||||
|
message GetUserInfoRsp {
|
||||||
|
string request_id = 1;
|
||||||
|
bool success = 2;
|
||||||
|
string errmsg = 3;
|
||||||
|
UserInfo user_info = 4;
|
||||||
|
}
|
||||||
|
//内部接口
|
||||||
|
message GetMultiUserInfoReq {
|
||||||
|
string request_id = 1;
|
||||||
|
repeated string users_id = 2;
|
||||||
|
}
|
||||||
|
message GetMultiUserInfoRsp {
|
||||||
|
string request_id = 1;
|
||||||
|
bool success = 2;
|
||||||
|
string errmsg = 3;
|
||||||
|
map<string, UserInfo> users_info = 4;
|
||||||
|
}
|
||||||
|
//----------------------------
|
||||||
|
//用户头像修改
|
||||||
|
message SetUserAvatarReq {
|
||||||
|
string request_id = 1;
|
||||||
|
optional string user_id = 2;
|
||||||
|
optional string session_id = 3;
|
||||||
|
bytes avatar = 4;
|
||||||
|
}
|
||||||
|
message SetUserAvatarRsp {
|
||||||
|
string request_id = 1;
|
||||||
|
bool success = 2;
|
||||||
|
string errmsg = 3;
|
||||||
|
}
|
||||||
|
//----------------------------
|
||||||
|
//用户昵称修改
|
||||||
|
message SetUserNicknameReq {
|
||||||
|
string request_id = 1;
|
||||||
|
optional string user_id = 2;
|
||||||
|
optional string session_id = 3;
|
||||||
|
string nickname = 4;
|
||||||
|
}
|
||||||
|
message SetUserNicknameRsp {
|
||||||
|
string request_id = 1;
|
||||||
|
bool success = 2;
|
||||||
|
string errmsg = 3;
|
||||||
|
}
|
||||||
|
//----------------------------
|
||||||
|
//用户签名修改
|
||||||
|
message SetUserDescriptionReq {
|
||||||
|
string request_id = 1;
|
||||||
|
optional string user_id = 2;
|
||||||
|
optional string session_id = 3;
|
||||||
|
string description = 4;
|
||||||
|
}
|
||||||
|
message SetUserDescriptionRsp {
|
||||||
|
string request_id = 1;
|
||||||
|
bool success = 2;
|
||||||
|
string errmsg = 3;
|
||||||
|
}
|
||||||
|
//----------------------------
|
||||||
|
//用户手机修改
|
||||||
|
message SetUserPhoneNumberReq {
|
||||||
|
string request_id = 1;
|
||||||
|
optional string user_id = 2;
|
||||||
|
optional string session_id = 3;
|
||||||
|
string phone_number = 4;
|
||||||
|
string phone_verify_code_id = 5;
|
||||||
|
string phone_verify_code = 6;
|
||||||
|
}
|
||||||
|
message SetUserPhoneNumberRsp {
|
||||||
|
string request_id = 1;
|
||||||
|
bool success = 2;
|
||||||
|
string errmsg = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
service UserService {
|
||||||
|
rpc UserRegister(UserRegisterReq) returns (UserRegisterRsp);
|
||||||
|
rpc UserLogin(UserLoginReq) returns (UserLoginRsp);
|
||||||
|
rpc GetPhoneVerifyCode(PhoneVerifyCodeReq) returns (PhoneVerifyCodeRsp);
|
||||||
|
rpc PhoneRegister(PhoneRegisterReq) returns (PhoneRegisterRsp);
|
||||||
|
rpc PhoneLogin(PhoneLoginReq) returns (PhoneLoginRsp);
|
||||||
|
rpc GetUserInfo(GetUserInfoReq) returns (GetUserInfoRsp);
|
||||||
|
rpc GetMultiUserInfo(GetMultiUserInfoReq) returns (GetMultiUserInfoRsp);
|
||||||
|
rpc SetUserAvatar(SetUserAvatarReq) returns (SetUserAvatarRsp);
|
||||||
|
rpc SetUserNickname(SetUserNicknameReq) returns (SetUserNicknameRsp);
|
||||||
|
rpc SetUserDescription(SetUserDescriptionReq) returns (SetUserDescriptionRsp);
|
||||||
|
rpc SetUserPhoneNumber(SetUserPhoneNumberReq) returns (SetUserPhoneNumberRsp);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user