From 71a612ba8876eb55406d108f3a30685b332599e8 Mon Sep 17 00:00:00 2001 From: link1st <562117637@qq.com> Date: 2021年2月21日 12:17:06 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=20rpc=20?= =?UTF-8?q?=E5=8D=8F=E8=AE=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- protobuf/im_protobuf.pb.go | 1162 +++++++++++++++++-------------- protobuf/im_protobuf.proto | 56 +- protobuf/im_protobuf_grpc.pb.go | 217 ++++++ 3 files changed, 874 insertions(+), 561 deletions(-) create mode 100644 protobuf/im_protobuf_grpc.pb.go diff --git a/protobuf/im_protobuf.pb.go b/protobuf/im_protobuf.pb.go index 6cbd911..7e3c997 100644 --- a/protobuf/im_protobuf.pb.go +++ b/protobuf/im_protobuf.pb.go @@ -1,740 +1,836 @@ // Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.25.0 +// protoc v3.5.0 // source: im_protobuf.proto package protobuf import ( - context "context" - fmt "fmt" proto "github.com/golang/protobuf/proto" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - math "math" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" ) -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) -// 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.ProtoPackageIsVersion3 // please upgrade the proto package +// This is a compile-time assertion that a sufficiently up-to-date version +// of the legacy proto package is being used. +const _ = proto.ProtoPackageIsVersion4 // 查询用户是否在线 type QueryUsersOnlineReq struct { - AppId uint32 `protobuf:"varint,1,opt,name=appId,proto3" json:"appId,omitempty"` - UserId string `protobuf:"bytes,2,opt,name=userId,proto3" json:"userId,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -func (m *QueryUsersOnlineReq) Reset() { *m = QueryUsersOnlineReq{} } -func (m *QueryUsersOnlineReq) String() string { return proto.CompactTextString(m) } -func (*QueryUsersOnlineReq) ProtoMessage() {} -func (*QueryUsersOnlineReq) Descriptor() ([]byte, []int) { - return fileDescriptor_62691ff0994625a6, []int{0} + AppID uint32 `protobuf:"varint,1,opt,name=appID,proto3" json:"appID,omitempty"` // appID + UserID string `protobuf:"bytes,2,opt,name=userID,proto3" json:"userID,omitempty"` // userID } -func (m *QueryUsersOnlineReq) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_QueryUsersOnlineReq.Unmarshal(m, b) -} -func (m *QueryUsersOnlineReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_QueryUsersOnlineReq.Marshal(b, m, deterministic) -} -func (m *QueryUsersOnlineReq) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryUsersOnlineReq.Merge(m, src) +func (x *QueryUsersOnlineReq) Reset() { + *x = QueryUsersOnlineReq{} + if protoimpl.UnsafeEnabled { + mi := &file_im_protobuf_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *QueryUsersOnlineReq) XXX_Size() int { - return xxx_messageInfo_QueryUsersOnlineReq.Size(m) + +func (x *QueryUsersOnlineReq) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *QueryUsersOnlineReq) XXX_DiscardUnknown() { - xxx_messageInfo_QueryUsersOnlineReq.DiscardUnknown(m) + +func (*QueryUsersOnlineReq) ProtoMessage() {} + +func (x *QueryUsersOnlineReq) ProtoReflect() protoreflect.Message { + mi := &file_im_protobuf_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -var xxx_messageInfo_QueryUsersOnlineReq proto.InternalMessageInfo +// Deprecated: Use QueryUsersOnlineReq.ProtoReflect.Descriptor instead. +func (*QueryUsersOnlineReq) Descriptor() ([]byte, []int) { + return file_im_protobuf_proto_rawDescGZIP(), []int{0} +} -func (m *QueryUsersOnlineReq) GetAppId() uint32 { - if m != nil { - return m.AppId +func (x *QueryUsersOnlineReq) GetAppID() uint32 { + if x != nil { + return x.AppID } return 0 } -func (m *QueryUsersOnlineReq) GetUserId() string { - if m != nil { - return m.UserId +func (x *QueryUsersOnlineReq) GetUserID() string { + if x != nil { + return x.UserID } return "" } type QueryUsersOnlineRsp struct { - RetCode uint32 `protobuf:"varint,1,opt,name=retCode,proto3" json:"retCode,omitempty"` - ErrMsg string `protobuf:"bytes,2,opt,name=errMsg,proto3" json:"errMsg,omitempty"` - Online bool `protobuf:"varint,3,opt,name=online,proto3" json:"online,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -func (m *QueryUsersOnlineRsp) Reset() { *m = QueryUsersOnlineRsp{} } -func (m *QueryUsersOnlineRsp) String() string { return proto.CompactTextString(m) } -func (*QueryUsersOnlineRsp) ProtoMessage() {} -func (*QueryUsersOnlineRsp) Descriptor() ([]byte, []int) { - return fileDescriptor_62691ff0994625a6, []int{1} + RetCode uint32 `protobuf:"varint,1,opt,name=retCode,proto3" json:"retCode,omitempty"` + ErrMsg string `protobuf:"bytes,2,opt,name=errMsg,proto3" json:"errMsg,omitempty"` + Online bool `protobuf:"varint,3,opt,name=online,proto3" json:"online,omitempty"` } -func (m *QueryUsersOnlineRsp) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_QueryUsersOnlineRsp.Unmarshal(m, b) -} -func (m *QueryUsersOnlineRsp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_QueryUsersOnlineRsp.Marshal(b, m, deterministic) -} -func (m *QueryUsersOnlineRsp) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryUsersOnlineRsp.Merge(m, src) +func (x *QueryUsersOnlineRsp) Reset() { + *x = QueryUsersOnlineRsp{} + if protoimpl.UnsafeEnabled { + mi := &file_im_protobuf_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *QueryUsersOnlineRsp) XXX_Size() int { - return xxx_messageInfo_QueryUsersOnlineRsp.Size(m) + +func (x *QueryUsersOnlineRsp) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *QueryUsersOnlineRsp) XXX_DiscardUnknown() { - xxx_messageInfo_QueryUsersOnlineRsp.DiscardUnknown(m) + +func (*QueryUsersOnlineRsp) ProtoMessage() {} + +func (x *QueryUsersOnlineRsp) ProtoReflect() protoreflect.Message { + mi := &file_im_protobuf_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -var xxx_messageInfo_QueryUsersOnlineRsp proto.InternalMessageInfo +// Deprecated: Use QueryUsersOnlineRsp.ProtoReflect.Descriptor instead. +func (*QueryUsersOnlineRsp) Descriptor() ([]byte, []int) { + return file_im_protobuf_proto_rawDescGZIP(), []int{1} +} -func (m *QueryUsersOnlineRsp) GetRetCode() uint32 { - if m != nil { - return m.RetCode +func (x *QueryUsersOnlineRsp) GetRetCode() uint32 { + if x != nil { + return x.RetCode } return 0 } -func (m *QueryUsersOnlineRsp) GetErrMsg() string { - if m != nil { - return m.ErrMsg +func (x *QueryUsersOnlineRsp) GetErrMsg() string { + if x != nil { + return x.ErrMsg } return "" } -func (m *QueryUsersOnlineRsp) GetOnline() bool { - if m != nil { - return m.Online +func (x *QueryUsersOnlineRsp) GetOnline() bool { + if x != nil { + return x.Online } return false } // 发送消息 type SendMsgReq struct { - Seq string `protobuf:"bytes,1,opt,name=seq,proto3" json:"seq,omitempty"` - AppId uint32 `protobuf:"varint,2,opt,name=appId,proto3" json:"appId,omitempty"` - UserId string `protobuf:"bytes,3,opt,name=userId,proto3" json:"userId,omitempty"` - Cms string `protobuf:"bytes,4,opt,name=cms,proto3" json:"cms,omitempty"` - Type string `protobuf:"bytes,5,opt,name=type,proto3" json:"type,omitempty"` - Msg string `protobuf:"bytes,6,opt,name=msg,proto3" json:"msg,omitempty"` - IsLocal bool `protobuf:"varint,7,opt,name=isLocal,proto3" json:"isLocal,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *SendMsgReq) Reset() { *m = SendMsgReq{} } -func (m *SendMsgReq) String() string { return proto.CompactTextString(m) } -func (*SendMsgReq) ProtoMessage() {} -func (*SendMsgReq) Descriptor() ([]byte, []int) { - return fileDescriptor_62691ff0994625a6, []int{2} -} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -func (m *SendMsgReq) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_SendMsgReq.Unmarshal(m, b) + Seq string `protobuf:"bytes,1,opt,name=seq,proto3" json:"seq,omitempty"` // 序列号 + AppID uint32 `protobuf:"varint,2,opt,name=appID,proto3" json:"appID,omitempty"` // appID + SendUserID string `protobuf:"bytes,3,opt,name=sendUserID,proto3" json:"sendUserID,omitempty"` // 发送者用户ID + UserID string `protobuf:"bytes,4,opt,name=userID,proto3" json:"userID,omitempty"` // 接收者用户ID + Cms string `protobuf:"bytes,5,opt,name=cms,proto3" json:"cms,omitempty"` // cms 动作: msg/enter/exit + Type string `protobuf:"bytes,6,opt,name=type,proto3" json:"type,omitempty"` // type 消息类型,默认是 text + Msg string `protobuf:"bytes,7,opt,name=msg,proto3" json:"msg,omitempty"` // msg + IsLocal bool `protobuf:"varint,8,opt,name=isLocal,proto3" json:"isLocal,omitempty"` // 是否查询本机 acc内部调用为:true(本机查询不到即结束) } -func (m *SendMsgReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_SendMsgReq.Marshal(b, m, deterministic) -} -func (m *SendMsgReq) XXX_Merge(src proto.Message) { - xxx_messageInfo_SendMsgReq.Merge(m, src) + +func (x *SendMsgReq) Reset() { + *x = SendMsgReq{} + if protoimpl.UnsafeEnabled { + mi := &file_im_protobuf_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *SendMsgReq) XXX_Size() int { - return xxx_messageInfo_SendMsgReq.Size(m) + +func (x *SendMsgReq) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *SendMsgReq) XXX_DiscardUnknown() { - xxx_messageInfo_SendMsgReq.DiscardUnknown(m) + +func (*SendMsgReq) ProtoMessage() {} + +func (x *SendMsgReq) ProtoReflect() protoreflect.Message { + mi := &file_im_protobuf_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -var xxx_messageInfo_SendMsgReq proto.InternalMessageInfo +// Deprecated: Use SendMsgReq.ProtoReflect.Descriptor instead. +func (*SendMsgReq) Descriptor() ([]byte, []int) { + return file_im_protobuf_proto_rawDescGZIP(), []int{2} +} -func (m *SendMsgReq) GetSeq() string { - if m != nil { - return m.Seq +func (x *SendMsgReq) GetSeq() string { + if x != nil { + return x.Seq } return "" } -func (m *SendMsgReq) GetAppId() uint32 { - if m != nil { - return m.AppId +func (x *SendMsgReq) GetAppID() uint32 { + if x != nil { + return x.AppID } return 0 } -func (m *SendMsgReq) GetUserId() string { - if m != nil { - return m.UserId +func (x *SendMsgReq) GetSendUserID() string { + if x != nil { + return x.SendUserID + } + return "" +} + +func (x *SendMsgReq) GetUserID() string { + if x != nil { + return x.UserID } return "" } -func (m *SendMsgReq) GetCms() string { - if m != nil { - return m.Cms +func (x *SendMsgReq) GetCms() string { + if x != nil { + return x.Cms } return "" } -func (m *SendMsgReq) GetType() string { - if m != nil { - return m.Type +func (x *SendMsgReq) GetType() string { + if x != nil { + return x.Type } return "" } -func (m *SendMsgReq) GetMsg() string { - if m != nil { - return m.Msg +func (x *SendMsgReq) GetMsg() string { + if x != nil { + return x.Msg } return "" } -func (m *SendMsgReq) GetIsLocal() bool { - if m != nil { - return m.IsLocal +func (x *SendMsgReq) GetIsLocal() bool { + if x != nil { + return x.IsLocal } return false } type SendMsgRsp struct { - RetCode uint32 `protobuf:"varint,1,opt,name=retCode,proto3" json:"retCode,omitempty"` - ErrMsg string `protobuf:"bytes,2,opt,name=errMsg,proto3" json:"errMsg,omitempty"` - SendMsgId string `protobuf:"bytes,3,opt,name=sendMsgId,proto3" json:"sendMsgId,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -func (m *SendMsgRsp) Reset() { *m = SendMsgRsp{} } -func (m *SendMsgRsp) String() string { return proto.CompactTextString(m) } -func (*SendMsgRsp) ProtoMessage() {} -func (*SendMsgRsp) Descriptor() ([]byte, []int) { - return fileDescriptor_62691ff0994625a6, []int{3} + RetCode uint32 `protobuf:"varint,1,opt,name=retCode,proto3" json:"retCode,omitempty"` + ErrMsg string `protobuf:"bytes,2,opt,name=errMsg,proto3" json:"errMsg,omitempty"` + SendMsgID string `protobuf:"bytes,3,opt,name=sendMsgID,proto3" json:"sendMsgID,omitempty"` // 消息ID } -func (m *SendMsgRsp) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_SendMsgRsp.Unmarshal(m, b) -} -func (m *SendMsgRsp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_SendMsgRsp.Marshal(b, m, deterministic) -} -func (m *SendMsgRsp) XXX_Merge(src proto.Message) { - xxx_messageInfo_SendMsgRsp.Merge(m, src) +func (x *SendMsgRsp) Reset() { + *x = SendMsgRsp{} + if protoimpl.UnsafeEnabled { + mi := &file_im_protobuf_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *SendMsgRsp) XXX_Size() int { - return xxx_messageInfo_SendMsgRsp.Size(m) + +func (x *SendMsgRsp) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *SendMsgRsp) XXX_DiscardUnknown() { - xxx_messageInfo_SendMsgRsp.DiscardUnknown(m) + +func (*SendMsgRsp) ProtoMessage() {} + +func (x *SendMsgRsp) ProtoReflect() protoreflect.Message { + mi := &file_im_protobuf_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -var xxx_messageInfo_SendMsgRsp proto.InternalMessageInfo +// Deprecated: Use SendMsgRsp.ProtoReflect.Descriptor instead. +func (*SendMsgRsp) Descriptor() ([]byte, []int) { + return file_im_protobuf_proto_rawDescGZIP(), []int{3} +} -func (m *SendMsgRsp) GetRetCode() uint32 { - if m != nil { - return m.RetCode +func (x *SendMsgRsp) GetRetCode() uint32 { + if x != nil { + return x.RetCode } return 0 } -func (m *SendMsgRsp) GetErrMsg() string { - if m != nil { - return m.ErrMsg +func (x *SendMsgRsp) GetErrMsg() string { + if x != nil { + return x.ErrMsg } return "" } -func (m *SendMsgRsp) GetSendMsgId() string { - if m != nil { - return m.SendMsgId +func (x *SendMsgRsp) GetSendMsgID() string { + if x != nil { + return x.SendMsgID } return "" } -// 发送消息 -type SendMsgAllReq struct { - Seq string `protobuf:"bytes,1,opt,name=seq,proto3" json:"seq,omitempty"` - AppId uint32 `protobuf:"varint,2,opt,name=appId,proto3" json:"appId,omitempty"` - UserId string `protobuf:"bytes,3,opt,name=userId,proto3" json:"userId,omitempty"` - Cms string `protobuf:"bytes,4,opt,name=cms,proto3" json:"cms,omitempty"` - Type string `protobuf:"bytes,5,opt,name=type,proto3" json:"type,omitempty"` - Msg string `protobuf:"bytes,6,opt,name=msg,proto3" json:"msg,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} +// 给这台机器的房间内所有用户发送消息 +type SendRoomMsgReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -func (m *SendMsgAllReq) Reset() { *m = SendMsgAllReq{} } -func (m *SendMsgAllReq) String() string { return proto.CompactTextString(m) } -func (*SendMsgAllReq) ProtoMessage() {} -func (*SendMsgAllReq) Descriptor() ([]byte, []int) { - return fileDescriptor_62691ff0994625a6, []int{4} + Seq string `protobuf:"bytes,1,opt,name=seq,proto3" json:"seq,omitempty"` // 序列号 + AppID uint32 `protobuf:"varint,2,opt,name=appID,proto3" json:"appID,omitempty"` // appID + RoomID uint32 `protobuf:"varint,3,opt,name=roomID,proto3" json:"roomID,omitempty"` // appID + UserID string `protobuf:"bytes,4,opt,name=userID,proto3" json:"userID,omitempty"` // 发送者ID + Cms string `protobuf:"bytes,5,opt,name=cms,proto3" json:"cms,omitempty"` // cms 动作: msg/enter/exit + Type string `protobuf:"bytes,6,opt,name=type,proto3" json:"type,omitempty"` // type 消息类型,默认是 text + Msg string `protobuf:"bytes,7,opt,name=msg,proto3" json:"msg,omitempty"` // msg } -func (m *SendMsgAllReq) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_SendMsgAllReq.Unmarshal(m, b) -} -func (m *SendMsgAllReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_SendMsgAllReq.Marshal(b, m, deterministic) -} -func (m *SendMsgAllReq) XXX_Merge(src proto.Message) { - xxx_messageInfo_SendMsgAllReq.Merge(m, src) -} -func (m *SendMsgAllReq) XXX_Size() int { - return xxx_messageInfo_SendMsgAllReq.Size(m) +func (x *SendRoomMsgReq) Reset() { + *x = SendRoomMsgReq{} + if protoimpl.UnsafeEnabled { + mi := &file_im_protobuf_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *SendMsgAllReq) XXX_DiscardUnknown() { - xxx_messageInfo_SendMsgAllReq.DiscardUnknown(m) + +func (x *SendRoomMsgReq) String() string { + return protoimpl.X.MessageStringOf(x) } -var xxx_messageInfo_SendMsgAllReq proto.InternalMessageInfo +func (*SendRoomMsgReq) ProtoMessage() {} -func (m *SendMsgAllReq) GetSeq() string { - if m != nil { - return m.Seq +func (x *SendRoomMsgReq) ProtoReflect() protoreflect.Message { + mi := &file_im_protobuf_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms } - return "" + return mi.MessageOf(x) } -func (m *SendMsgAllReq) GetAppId() uint32 { - if m != nil { - return m.AppId - } - return 0 +// Deprecated: Use SendRoomMsgReq.ProtoReflect.Descriptor instead. +func (*SendRoomMsgReq) Descriptor() ([]byte, []int) { + return file_im_protobuf_proto_rawDescGZIP(), []int{4} } -func (m *SendMsgAllReq) GetUserId() string { - if m != nil { - return m.UserId +func (x *SendRoomMsgReq) GetSeq() string { + if x != nil { + return x.Seq } return "" } -func (m *SendMsgAllReq) GetCms() string { - if m != nil { - return m.Cms +func (x *SendRoomMsgReq) GetAppID() uint32 { + if x != nil { + return x.AppID } - return "" + return 0 } -func (m *SendMsgAllReq) GetType() string { - if m != nil { - return m.Type +func (x *SendRoomMsgReq) GetRoomID() uint32 { + if x != nil { + return x.RoomID } - return "" + return 0 } -func (m *SendMsgAllReq) GetMsg() string { - if m != nil { - return m.Msg +func (x *SendRoomMsgReq) GetUserID() string { + if x != nil { + return x.UserID } return "" } -type SendMsgAllRsp struct { - RetCode uint32 `protobuf:"varint,1,opt,name=retCode,proto3" json:"retCode,omitempty"` - ErrMsg string `protobuf:"bytes,2,opt,name=errMsg,proto3" json:"errMsg,omitempty"` - SendMsgId string `protobuf:"bytes,3,opt,name=sendMsgId,proto3" json:"sendMsgId,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *SendMsgAllRsp) Reset() { *m = SendMsgAllRsp{} } -func (m *SendMsgAllRsp) String() string { return proto.CompactTextString(m) } -func (*SendMsgAllRsp) ProtoMessage() {} -func (*SendMsgAllRsp) Descriptor() ([]byte, []int) { - return fileDescriptor_62691ff0994625a6, []int{5} -} - -func (m *SendMsgAllRsp) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_SendMsgAllRsp.Unmarshal(m, b) -} -func (m *SendMsgAllRsp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_SendMsgAllRsp.Marshal(b, m, deterministic) -} -func (m *SendMsgAllRsp) XXX_Merge(src proto.Message) { - xxx_messageInfo_SendMsgAllRsp.Merge(m, src) -} -func (m *SendMsgAllRsp) XXX_Size() int { - return xxx_messageInfo_SendMsgAllRsp.Size(m) -} -func (m *SendMsgAllRsp) XXX_DiscardUnknown() { - xxx_messageInfo_SendMsgAllRsp.DiscardUnknown(m) -} - -var xxx_messageInfo_SendMsgAllRsp proto.InternalMessageInfo - -func (m *SendMsgAllRsp) GetRetCode() uint32 { - if m != nil { - return m.RetCode +func (x *SendRoomMsgReq) GetCms() string { + if x != nil { + return x.Cms } - return 0 + return "" } -func (m *SendMsgAllRsp) GetErrMsg() string { - if m != nil { - return m.ErrMsg +func (x *SendRoomMsgReq) GetType() string { + if x != nil { + return x.Type } return "" } -func (m *SendMsgAllRsp) GetSendMsgId() string { - if m != nil { - return m.SendMsgId +func (x *SendRoomMsgReq) GetMsg() string { + if x != nil { + return x.Msg } return "" } -// 获取用户列表 -type GetUserListReq struct { - AppId uint32 `protobuf:"varint,1,opt,name=appId,proto3" json:"appId,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *GetUserListReq) Reset() { *m = GetUserListReq{} } -func (m *GetUserListReq) String() string { return proto.CompactTextString(m) } -func (*GetUserListReq) ProtoMessage() {} -func (*GetUserListReq) Descriptor() ([]byte, []int) { - return fileDescriptor_62691ff0994625a6, []int{6} -} +type SendRoomMsgRsp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -func (m *GetUserListReq) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_GetUserListReq.Unmarshal(m, b) -} -func (m *GetUserListReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_GetUserListReq.Marshal(b, m, deterministic) -} -func (m *GetUserListReq) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetUserListReq.Merge(m, src) -} -func (m *GetUserListReq) XXX_Size() int { - return xxx_messageInfo_GetUserListReq.Size(m) -} -func (m *GetUserListReq) XXX_DiscardUnknown() { - xxx_messageInfo_GetUserListReq.DiscardUnknown(m) + RetCode uint32 `protobuf:"varint,1,opt,name=retCode,proto3" json:"retCode,omitempty"` + ErrMsg string `protobuf:"bytes,2,opt,name=errMsg,proto3" json:"errMsg,omitempty"` + SendMsgID string `protobuf:"bytes,3,opt,name=sendMsgID,proto3" json:"sendMsgID,omitempty"` } -var xxx_messageInfo_GetUserListReq proto.InternalMessageInfo - -func (m *GetUserListReq) GetAppId() uint32 { - if m != nil { - return m.AppId +func (x *SendRoomMsgRsp) Reset() { + *x = SendRoomMsgRsp{} + if protoimpl.UnsafeEnabled { + mi := &file_im_protobuf_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } - return 0 } -type GetUserListRsp struct { - RetCode uint32 `protobuf:"varint,1,opt,name=retCode,proto3" json:"retCode,omitempty"` - ErrMsg string `protobuf:"bytes,2,opt,name=errMsg,proto3" json:"errMsg,omitempty"` - UserId []string `protobuf:"bytes,3,rep,name=userId,proto3" json:"userId,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` +func (x *SendRoomMsgRsp) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *GetUserListRsp) Reset() { *m = GetUserListRsp{} } -func (m *GetUserListRsp) String() string { return proto.CompactTextString(m) } -func (*GetUserListRsp) ProtoMessage() {} -func (*GetUserListRsp) Descriptor() ([]byte, []int) { - return fileDescriptor_62691ff0994625a6, []int{7} -} +func (*SendRoomMsgRsp) ProtoMessage() {} -func (m *GetUserListRsp) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_GetUserListRsp.Unmarshal(m, b) -} -func (m *GetUserListRsp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_GetUserListRsp.Marshal(b, m, deterministic) -} -func (m *GetUserListRsp) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetUserListRsp.Merge(m, src) -} -func (m *GetUserListRsp) XXX_Size() int { - return xxx_messageInfo_GetUserListRsp.Size(m) -} -func (m *GetUserListRsp) XXX_DiscardUnknown() { - xxx_messageInfo_GetUserListRsp.DiscardUnknown(m) +func (x *SendRoomMsgRsp) ProtoReflect() protoreflect.Message { + mi := &file_im_protobuf_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -var xxx_messageInfo_GetUserListRsp proto.InternalMessageInfo +// Deprecated: Use SendRoomMsgRsp.ProtoReflect.Descriptor instead. +func (*SendRoomMsgRsp) Descriptor() ([]byte, []int) { + return file_im_protobuf_proto_rawDescGZIP(), []int{5} +} -func (m *GetUserListRsp) GetRetCode() uint32 { - if m != nil { - return m.RetCode +func (x *SendRoomMsgRsp) GetRetCode() uint32 { + if x != nil { + return x.RetCode } return 0 } -func (m *GetUserListRsp) GetErrMsg() string { - if m != nil { - return m.ErrMsg +func (x *SendRoomMsgRsp) GetErrMsg() string { + if x != nil { + return x.ErrMsg } return "" } -func (m *GetUserListRsp) GetUserId() []string { - if m != nil { - return m.UserId +func (x *SendRoomMsgRsp) GetSendMsgID() string { + if x != nil { + return x.SendMsgID } - return nil -} - -func init() { - proto.RegisterType((*QueryUsersOnlineReq)(nil), "protobuf.QueryUsersOnlineReq") - proto.RegisterType((*QueryUsersOnlineRsp)(nil), "protobuf.QueryUsersOnlineRsp") - proto.RegisterType((*SendMsgReq)(nil), "protobuf.SendMsgReq") - proto.RegisterType((*SendMsgRsp)(nil), "protobuf.SendMsgRsp") - proto.RegisterType((*SendMsgAllReq)(nil), "protobuf.SendMsgAllReq") - proto.RegisterType((*SendMsgAllRsp)(nil), "protobuf.SendMsgAllRsp") - proto.RegisterType((*GetUserListReq)(nil), "protobuf.GetUserListReq") - proto.RegisterType((*GetUserListRsp)(nil), "protobuf.GetUserListRsp") -} - -func init() { proto.RegisterFile("im_protobuf.proto", fileDescriptor_62691ff0994625a6) } - -var fileDescriptor_62691ff0994625a6 = []byte{ - // 413 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x53, 0x4d, 0xab, 0xd3, 0x40, - 0x14, 0x35, 0xcd, 0x7b, 0xed, 0xcb, 0x95, 0xca, 0x73, 0x7c, 0xe8, 0x18, 0x14, 0xca, 0x2c, 0xa4, - 0x0b, 0xc9, 0x42, 0x17, 0x6e, 0x6d, 0xbb, 0x90, 0x42, 0x8b, 0x35, 0xc5, 0x8d, 0x08, 0xa5, 0x4d, - 0xae, 0x21, 0x90, 0x34, 0xd3, 0xb9, 0xa9, 0xd8, 0x5f, 0xe0, 0xbf, 0xd0, 0xbf, 0x2a, 0x33, 0xf9, - 0x6a, 0x35, 0x75, 0x51, 0x10, 0x57, 0xb9, 0xe7, 0xde, 0x73, 0x0f, 0x67, 0x2e, 0x27, 0xf0, 0x30, - 0x4e, 0x57, 0x52, 0x65, 0x79, 0xb6, 0xd9, 0x7f, 0xf1, 0x4c, 0xc1, 0x6e, 0x2a, 0x2c, 0x26, 0xf0, - 0xe8, 0xc3, 0x1e, 0xd5, 0xe1, 0x23, 0xa1, 0xa2, 0xf7, 0xdb, 0x24, 0xde, 0xa2, 0x8f, 0x3b, 0x76, - 0x07, 0xd7, 0x6b, 0x29, 0xa7, 0x21, 0xb7, 0x06, 0xd6, 0xb0, 0xef, 0x17, 0x80, 0x3d, 0x86, 0xee, - 0x9e, 0x50, 0x4d, 0x43, 0xde, 0x19, 0x58, 0x43, 0xc7, 0x2f, 0x91, 0x58, 0xb5, 0x88, 0x90, 0x64, - 0x1c, 0x7a, 0x0a, 0xf3, 0x49, 0x16, 0x62, 0x29, 0x53, 0x41, 0x2d, 0x84, 0x4a, 0xcd, 0x29, 0xaa, - 0x84, 0x0a, 0xa4, 0xfb, 0x99, 0x59, 0xe7, 0xf6, 0xc0, 0x1a, 0xde, 0xf8, 0x25, 0x12, 0x3f, 0x2c, - 0x80, 0x25, 0x6e, 0xc3, 0x39, 0x45, 0xda, 0xdd, 0x2d, 0xd8, 0x84, 0x3b, 0x23, 0xea, 0xf8, 0xba, - 0x6c, 0xfc, 0x76, 0xda, 0xfd, 0xda, 0xc7, 0x7e, 0xf5, 0x7e, 0x90, 0x12, 0xbf, 0x2a, 0xf6, 0x83, - 0x94, 0x18, 0x83, 0xab, 0xfc, 0x20, 0x91, 0x5f, 0x9b, 0x96, 0xa9, 0x35, 0x2b, 0xa5, 0x88, 0x77, - 0x0b, 0x56, 0x4a, 0x91, 0x7e, 0x50, 0x4c, 0xb3, 0x2c, 0x58, 0x27, 0xbc, 0x67, 0xfc, 0x55, 0x50, - 0x7c, 0x6e, 0xfc, 0x5d, 0xf4, 0xf0, 0x67, 0xe0, 0x50, 0xb1, 0x5f, 0x9b, 0x6d, 0x1a, 0xe2, 0xbb, - 0x05, 0xfd, 0x52, 0x7e, 0x94, 0x24, 0xff, 0xf1, 0x02, 0x62, 0x75, 0x62, 0xe4, 0x1f, 0x3c, 0xf5, - 0x05, 0x3c, 0x78, 0x87, 0xb9, 0x0e, 0xd2, 0x2c, 0xa6, 0xfc, 0x6c, 0x14, 0xc5, 0xa7, 0x53, 0xde, - 0xa5, 0x69, 0xab, 0x8f, 0x63, 0x37, 0xc7, 0x79, 0xf5, 0xb3, 0x03, 0xce, 0x28, 0x08, 0x96, 0xa8, - 0xbe, 0xa2, 0x62, 0x3e, 0xdc, 0xfe, 0x1e, 0x6e, 0xf6, 0xdc, 0xab, 0x7f, 0xa8, 0x96, 0xbf, 0xc7, - 0xfd, 0xdb, 0x98, 0xa4, 0xb8, 0xc7, 0xde, 0x40, 0xaf, 0x3c, 0x23, 0xbb, 0x6b, 0xb8, 0x4d, 0xc2, - 0xdd, 0x96, 0xae, 0x59, 0x7c, 0x5b, 0xe7, 0x6c, 0x94, 0x24, 0xec, 0xc9, 0x1f, 0xac, 0x22, 0x1e, - 0x6e, 0xfb, 0xc0, 0x28, 0x4c, 0xe0, 0xfe, 0xd1, 0xe1, 0x18, 0x6f, 0x98, 0xa7, 0x77, 0x77, 0xcf, - 0x4c, 0xb4, 0xc8, 0xf8, 0x25, 0x3c, 0x8d, 0x33, 0x2f, 0x52, 0x32, 0xf0, 0xf0, 0xdb, 0x3a, 0x95, - 0x09, 0x52, 0xcd, 0x1e, 0xf7, 0x17, 0x65, 0x65, 0xbe, 0x0b, 0x6b, 0xd3, 0x35, 0xa3, 0xd7, 0xbf, - 0x02, 0x00, 0x00, 0xff, 0xff, 0x53, 0x3e, 0x6a, 0x5a, 0x89, 0x04, 0x00, 0x00, + return "" } -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 +// 获取用户列表 +type GetUserListReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -// AccServerClient is the client API for AccServer service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type AccServerClient interface { - // 查询用户是否在线 - QueryUsersOnline(ctx context.Context, in *QueryUsersOnlineReq, opts ...grpc.CallOption) (*QueryUsersOnlineRsp, error) - // 发送消息 - SendMsg(ctx context.Context, in *SendMsgReq, opts ...grpc.CallOption) (*SendMsgRsp, error) - // 发送消息 - SendMsgAll(ctx context.Context, in *SendMsgAllReq, opts ...grpc.CallOption) (*SendMsgAllRsp, error) - // 获取用户列表 - GetUserList(ctx context.Context, in *GetUserListReq, opts ...grpc.CallOption) (*GetUserListRsp, error) + AppID uint32 `protobuf:"varint,1,opt,name=appID,proto3" json:"appID,omitempty"` // appID + RoomID uint32 `protobuf:"varint,2,opt,name=roomID,proto3" json:"roomID,omitempty"` // 房间ID 不填,则获取真个APP的用户 } -type accServerClient struct { - cc *grpc.ClientConn +func (x *GetUserListReq) Reset() { + *x = GetUserListReq{} + if protoimpl.UnsafeEnabled { + mi := &file_im_protobuf_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func NewAccServerClient(cc *grpc.ClientConn) AccServerClient { - return &accServerClient{cc} +func (x *GetUserListReq) String() string { + return protoimpl.X.MessageStringOf(x) } -func (c *accServerClient) QueryUsersOnline(ctx context.Context, in *QueryUsersOnlineReq, opts ...grpc.CallOption) (*QueryUsersOnlineRsp, error) { - out := new(QueryUsersOnlineRsp) - err := c.cc.Invoke(ctx, "/protobuf.AccServer/QueryUsersOnline", in, out, opts...) - if err != nil { - return nil, err +func (*GetUserListReq) ProtoMessage() {} + +func (x *GetUserListReq) ProtoReflect() protoreflect.Message { + mi := &file_im_protobuf_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms } - return out, nil + return mi.MessageOf(x) } -func (c *accServerClient) SendMsg(ctx context.Context, in *SendMsgReq, opts ...grpc.CallOption) (*SendMsgRsp, error) { - out := new(SendMsgRsp) - err := c.cc.Invoke(ctx, "/protobuf.AccServer/SendMsg", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil +// Deprecated: Use GetUserListReq.ProtoReflect.Descriptor instead. +func (*GetUserListReq) Descriptor() ([]byte, []int) { + return file_im_protobuf_proto_rawDescGZIP(), []int{6} } -func (c *accServerClient) SendMsgAll(ctx context.Context, in *SendMsgAllReq, opts ...grpc.CallOption) (*SendMsgAllRsp, error) { - out := new(SendMsgAllRsp) - err := c.cc.Invoke(ctx, "/protobuf.AccServer/SendMsgAll", in, out, opts...) - if err != nil { - return nil, err +func (x *GetUserListReq) GetAppID() uint32 { + if x != nil { + return x.AppID } - return out, nil + return 0 } -func (c *accServerClient) GetUserList(ctx context.Context, in *GetUserListReq, opts ...grpc.CallOption) (*GetUserListRsp, error) { - out := new(GetUserListRsp) - err := c.cc.Invoke(ctx, "/protobuf.AccServer/GetUserList", in, out, opts...) - if err != nil { - return nil, err +func (x *GetUserListReq) GetRoomID() uint32 { + if x != nil { + return x.RoomID } - return out, nil + return 0 } -// AccServerServer is the server API for AccServer service. -type AccServerServer interface { - // 查询用户是否在线 - QueryUsersOnline(context.Context, *QueryUsersOnlineReq) (*QueryUsersOnlineRsp, error) - // 发送消息 - SendMsg(context.Context, *SendMsgReq) (*SendMsgRsp, error) - // 发送消息 - SendMsgAll(context.Context, *SendMsgAllReq) (*SendMsgAllRsp, error) - // 获取用户列表 - GetUserList(context.Context, *GetUserListReq) (*GetUserListRsp, error) -} +type GetUserListRsp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -// UnimplementedAccServerServer can be embedded to have forward compatible implementations. -type UnimplementedAccServerServer struct { + RetCode uint32 `protobuf:"varint,1,opt,name=retCode,proto3" json:"retCode,omitempty"` + ErrMsg string `protobuf:"bytes,2,opt,name=errMsg,proto3" json:"errMsg,omitempty"` + UserID []string `protobuf:"bytes,3,rep,name=userID,proto3" json:"userID,omitempty"` } -func (*UnimplementedAccServerServer) QueryUsersOnline(ctx context.Context, req *QueryUsersOnlineReq) (*QueryUsersOnlineRsp, error) { - return nil, status.Errorf(codes.Unimplemented, "method QueryUsersOnline not implemented") -} -func (*UnimplementedAccServerServer) SendMsg(ctx context.Context, req *SendMsgReq) (*SendMsgRsp, error) { - return nil, status.Errorf(codes.Unimplemented, "method SendMsg not implemented") -} -func (*UnimplementedAccServerServer) SendMsgAll(ctx context.Context, req *SendMsgAllReq) (*SendMsgAllRsp, error) { - return nil, status.Errorf(codes.Unimplemented, "method SendMsgAll not implemented") -} -func (*UnimplementedAccServerServer) GetUserList(ctx context.Context, req *GetUserListReq) (*GetUserListRsp, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetUserList not implemented") +func (x *GetUserListRsp) Reset() { + *x = GetUserListRsp{} + if protoimpl.UnsafeEnabled { + mi := &file_im_protobuf_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func RegisterAccServerServer(s *grpc.Server, srv AccServerServer) { - s.RegisterService(&_AccServer_serviceDesc, srv) +func (x *GetUserListRsp) String() string { + return protoimpl.X.MessageStringOf(x) } -func _AccServer_QueryUsersOnline_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryUsersOnlineReq) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(AccServerServer).QueryUsersOnline(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/protobuf.AccServer/QueryUsersOnline", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(AccServerServer).QueryUsersOnline(ctx, req.(*QueryUsersOnlineReq)) +func (*GetUserListRsp) ProtoMessage() {} + +func (x *GetUserListRsp) ProtoReflect() protoreflect.Message { + mi := &file_im_protobuf_proto_msgTypes[7] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms } - return interceptor(ctx, in, info, handler) + return mi.MessageOf(x) } -func _AccServer_SendMsg_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(SendMsgReq) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(AccServerServer).SendMsg(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/protobuf.AccServer/SendMsg", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(AccServerServer).SendMsg(ctx, req.(*SendMsgReq)) - } - return interceptor(ctx, in, info, handler) +// Deprecated: Use GetUserListRsp.ProtoReflect.Descriptor instead. +func (*GetUserListRsp) Descriptor() ([]byte, []int) { + return file_im_protobuf_proto_rawDescGZIP(), []int{7} } -func _AccServer_SendMsgAll_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(SendMsgAllReq) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(AccServerServer).SendMsgAll(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/protobuf.AccServer/SendMsgAll", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(AccServerServer).SendMsgAll(ctx, req.(*SendMsgAllReq)) +func (x *GetUserListRsp) GetRetCode() uint32 { + if x != nil { + return x.RetCode } - return interceptor(ctx, in, info, handler) + return 0 } -func _AccServer_GetUserList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetUserListReq) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(AccServerServer).GetUserList(ctx, in) +func (x *GetUserListRsp) GetErrMsg() string { + if x != nil { + return x.ErrMsg } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/protobuf.AccServer/GetUserList", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(AccServerServer).GetUserList(ctx, req.(*GetUserListReq)) + return "" +} + +func (x *GetUserListRsp) GetUserID() []string { + if x != nil { + return x.UserID } - return interceptor(ctx, in, info, handler) + return nil } -var _AccServer_serviceDesc = grpc.ServiceDesc{ - ServiceName: "protobuf.AccServer", - HandlerType: (*AccServerServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "QueryUsersOnline", - Handler: _AccServer_QueryUsersOnline_Handler, - }, - { - MethodName: "SendMsg", - Handler: _AccServer_SendMsg_Handler, - }, - { - MethodName: "SendMsgAll", - Handler: _AccServer_SendMsgAll_Handler, - }, - { - MethodName: "GetUserList", - Handler: _AccServer_GetUserList_Handler, +var File_im_protobuf_proto protoreflect.FileDescriptor + +var file_im_protobuf_proto_rawDesc = []byte{ + 0x0a, 0x11, 0x69, 0x6d, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x12, 0x08, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x22, 0x43, 0x0a, + 0x13, 0x51, 0x75, 0x65, 0x72, 0x79, 0x55, 0x73, 0x65, 0x72, 0x73, 0x4f, 0x6e, 0x6c, 0x69, 0x6e, + 0x65, 0x52, 0x65, 0x71, 0x12, 0x14, 0x0a, 0x05, 0x61, 0x70, 0x70, 0x49, 0x44, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0d, 0x52, 0x05, 0x61, 0x70, 0x70, 0x49, 0x44, 0x12, 0x16, 0x0a, 0x06, 0x75, 0x73, + 0x65, 0x72, 0x49, 0x44, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, + 0x49, 0x44, 0x22, 0x5f, 0x0a, 0x13, 0x51, 0x75, 0x65, 0x72, 0x79, 0x55, 0x73, 0x65, 0x72, 0x73, + 0x4f, 0x6e, 0x6c, 0x69, 0x6e, 0x65, 0x52, 0x73, 0x70, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x65, 0x74, + 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x07, 0x72, 0x65, 0x74, 0x43, + 0x6f, 0x64, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x65, 0x72, 0x72, 0x4d, 0x73, 0x67, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x06, 0x65, 0x72, 0x72, 0x4d, 0x73, 0x67, 0x12, 0x16, 0x0a, 0x06, 0x6f, + 0x6e, 0x6c, 0x69, 0x6e, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x6f, 0x6e, 0x6c, + 0x69, 0x6e, 0x65, 0x22, 0xbe, 0x01, 0x0a, 0x0a, 0x53, 0x65, 0x6e, 0x64, 0x4d, 0x73, 0x67, 0x52, + 0x65, 0x71, 0x12, 0x10, 0x0a, 0x03, 0x73, 0x65, 0x71, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x03, 0x73, 0x65, 0x71, 0x12, 0x14, 0x0a, 0x05, 0x61, 0x70, 0x70, 0x49, 0x44, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0d, 0x52, 0x05, 0x61, 0x70, 0x70, 0x49, 0x44, 0x12, 0x1e, 0x0a, 0x0a, 0x73, 0x65, + 0x6e, 0x64, 0x55, 0x73, 0x65, 0x72, 0x49, 0x44, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, + 0x73, 0x65, 0x6e, 0x64, 0x55, 0x73, 0x65, 0x72, 0x49, 0x44, 0x12, 0x16, 0x0a, 0x06, 0x75, 0x73, + 0x65, 0x72, 0x49, 0x44, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, + 0x49, 0x44, 0x12, 0x10, 0x0a, 0x03, 0x63, 0x6d, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x03, 0x63, 0x6d, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x06, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x73, 0x67, 0x18, + 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6d, 0x73, 0x67, 0x12, 0x18, 0x0a, 0x07, 0x69, 0x73, + 0x4c, 0x6f, 0x63, 0x61, 0x6c, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x69, 0x73, 0x4c, + 0x6f, 0x63, 0x61, 0x6c, 0x22, 0x5c, 0x0a, 0x0a, 0x53, 0x65, 0x6e, 0x64, 0x4d, 0x73, 0x67, 0x52, + 0x73, 0x70, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x65, 0x74, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0d, 0x52, 0x07, 0x72, 0x65, 0x74, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x16, 0x0a, 0x06, + 0x65, 0x72, 0x72, 0x4d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x65, 0x72, + 0x72, 0x4d, 0x73, 0x67, 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x65, 0x6e, 0x64, 0x4d, 0x73, 0x67, 0x49, + 0x44, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x65, 0x6e, 0x64, 0x4d, 0x73, 0x67, + 0x49, 0x44, 0x22, 0xa0, 0x01, 0x0a, 0x0e, 0x53, 0x65, 0x6e, 0x64, 0x52, 0x6f, 0x6f, 0x6d, 0x4d, + 0x73, 0x67, 0x52, 0x65, 0x71, 0x12, 0x10, 0x0a, 0x03, 0x73, 0x65, 0x71, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x03, 0x73, 0x65, 0x71, 0x12, 0x14, 0x0a, 0x05, 0x61, 0x70, 0x70, 0x49, 0x44, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05, 0x61, 0x70, 0x70, 0x49, 0x44, 0x12, 0x16, 0x0a, + 0x06, 0x72, 0x6f, 0x6f, 0x6d, 0x49, 0x44, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x72, + 0x6f, 0x6f, 0x6d, 0x49, 0x44, 0x12, 0x16, 0x0a, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x44, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x44, 0x12, 0x10, 0x0a, + 0x03, 0x63, 0x6d, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x63, 0x6d, 0x73, 0x12, + 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, + 0x79, 0x70, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x73, 0x67, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x03, 0x6d, 0x73, 0x67, 0x22, 0x60, 0x0a, 0x0e, 0x53, 0x65, 0x6e, 0x64, 0x52, 0x6f, 0x6f, + 0x6d, 0x4d, 0x73, 0x67, 0x52, 0x73, 0x70, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x65, 0x74, 0x43, 0x6f, + 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x07, 0x72, 0x65, 0x74, 0x43, 0x6f, 0x64, + 0x65, 0x12, 0x16, 0x0a, 0x06, 0x65, 0x72, 0x72, 0x4d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x06, 0x65, 0x72, 0x72, 0x4d, 0x73, 0x67, 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x65, 0x6e, + 0x64, 0x4d, 0x73, 0x67, 0x49, 0x44, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x65, + 0x6e, 0x64, 0x4d, 0x73, 0x67, 0x49, 0x44, 0x22, 0x3e, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x55, 0x73, + 0x65, 0x72, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x12, 0x14, 0x0a, 0x05, 0x61, 0x70, 0x70, + 0x49, 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05, 0x61, 0x70, 0x70, 0x49, 0x44, 0x12, + 0x16, 0x0a, 0x06, 0x72, 0x6f, 0x6f, 0x6d, 0x49, 0x44, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, + 0x06, 0x72, 0x6f, 0x6f, 0x6d, 0x49, 0x44, 0x22, 0x5a, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x55, 0x73, + 0x65, 0x72, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x73, 0x70, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x65, 0x74, + 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x07, 0x72, 0x65, 0x74, 0x43, + 0x6f, 0x64, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x65, 0x72, 0x72, 0x4d, 0x73, 0x67, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x06, 0x65, 0x72, 0x72, 0x4d, 0x73, 0x67, 0x12, 0x16, 0x0a, 0x06, 0x75, + 0x73, 0x65, 0x72, 0x49, 0x44, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x75, 0x73, 0x65, + 0x72, 0x49, 0x44, 0x32, 0xa2, 0x02, 0x0a, 0x09, 0x41, 0x63, 0x63, 0x53, 0x65, 0x72, 0x76, 0x65, + 0x72, 0x12, 0x52, 0x0a, 0x10, 0x51, 0x75, 0x65, 0x72, 0x79, 0x55, 0x73, 0x65, 0x72, 0x73, 0x4f, + 0x6e, 0x6c, 0x69, 0x6e, 0x65, 0x12, 0x1d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, + 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x55, 0x73, 0x65, 0x72, 0x73, 0x4f, 0x6e, 0x6c, 0x69, 0x6e, + 0x65, 0x52, 0x65, 0x71, 0x1a, 0x1d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, + 0x51, 0x75, 0x65, 0x72, 0x79, 0x55, 0x73, 0x65, 0x72, 0x73, 0x4f, 0x6e, 0x6c, 0x69, 0x6e, 0x65, + 0x52, 0x73, 0x70, 0x22, 0x00, 0x12, 0x37, 0x0a, 0x07, 0x53, 0x65, 0x6e, 0x64, 0x4d, 0x73, 0x67, + 0x12, 0x14, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x65, 0x6e, 0x64, + 0x4d, 0x73, 0x67, 0x52, 0x65, 0x71, 0x1a, 0x14, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, + 0x66, 0x2e, 0x53, 0x65, 0x6e, 0x64, 0x4d, 0x73, 0x67, 0x52, 0x73, 0x70, 0x22, 0x00, 0x12, 0x43, + 0x0a, 0x0b, 0x53, 0x65, 0x6e, 0x64, 0x52, 0x6f, 0x6f, 0x6d, 0x4d, 0x73, 0x67, 0x12, 0x18, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x65, 0x6e, 0x64, 0x52, 0x6f, 0x6f, + 0x6d, 0x4d, 0x73, 0x67, 0x52, 0x65, 0x71, 0x1a, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, + 0x75, 0x66, 0x2e, 0x53, 0x65, 0x6e, 0x64, 0x52, 0x6f, 0x6f, 0x6d, 0x4d, 0x73, 0x67, 0x52, 0x73, + 0x70, 0x22, 0x00, 0x12, 0x43, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x4c, 0x69, + 0x73, 0x74, 0x12, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x47, 0x65, + 0x74, 0x55, 0x73, 0x65, 0x72, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x18, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x4c, + 0x69, 0x73, 0x74, 0x52, 0x73, 0x70, 0x22, 0x00, 0x42, 0x39, 0x0a, 0x19, 0x69, 0x6f, 0x2e, 0x67, + 0x72, 0x70, 0x63, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x75, 0x66, 0x42, 0x0d, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x50, + 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x0b, 0x2e, 0x2e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x62, 0x75, 0x66, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_im_protobuf_proto_rawDescOnce sync.Once + file_im_protobuf_proto_rawDescData = file_im_protobuf_proto_rawDesc +) + +func file_im_protobuf_proto_rawDescGZIP() []byte { + file_im_protobuf_proto_rawDescOnce.Do(func() { + file_im_protobuf_proto_rawDescData = protoimpl.X.CompressGZIP(file_im_protobuf_proto_rawDescData) + }) + return file_im_protobuf_proto_rawDescData +} + +var file_im_protobuf_proto_msgTypes = make([]protoimpl.MessageInfo, 8) +var file_im_protobuf_proto_goTypes = []interface{}{ + (*QueryUsersOnlineReq)(nil), // 0: protobuf.QueryUsersOnlineReq + (*QueryUsersOnlineRsp)(nil), // 1: protobuf.QueryUsersOnlineRsp + (*SendMsgReq)(nil), // 2: protobuf.SendMsgReq + (*SendMsgRsp)(nil), // 3: protobuf.SendMsgRsp + (*SendRoomMsgReq)(nil), // 4: protobuf.SendRoomMsgReq + (*SendRoomMsgRsp)(nil), // 5: protobuf.SendRoomMsgRsp + (*GetUserListReq)(nil), // 6: protobuf.GetUserListReq + (*GetUserListRsp)(nil), // 7: protobuf.GetUserListRsp +} +var file_im_protobuf_proto_depIdxs = []int32{ + 0, // 0: protobuf.AccServer.QueryUsersOnline:input_type -> protobuf.QueryUsersOnlineReq + 2, // 1: protobuf.AccServer.SendMsg:input_type -> protobuf.SendMsgReq + 4, // 2: protobuf.AccServer.SendRoomMsg:input_type -> protobuf.SendRoomMsgReq + 6, // 3: protobuf.AccServer.GetUserList:input_type -> protobuf.GetUserListReq + 1, // 4: protobuf.AccServer.QueryUsersOnline:output_type -> protobuf.QueryUsersOnlineRsp + 3, // 5: protobuf.AccServer.SendMsg:output_type -> protobuf.SendMsgRsp + 5, // 6: protobuf.AccServer.SendRoomMsg:output_type -> protobuf.SendRoomMsgRsp + 7, // 7: protobuf.AccServer.GetUserList:output_type -> protobuf.GetUserListRsp + 4, // [4:8] is the sub-list for method output_type + 0, // [0:4] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_im_protobuf_proto_init() } +func file_im_protobuf_proto_init() { + if File_im_protobuf_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_im_protobuf_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*QueryUsersOnlineReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_im_protobuf_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*QueryUsersOnlineRsp); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_im_protobuf_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SendMsgReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_im_protobuf_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SendMsgRsp); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_im_protobuf_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SendRoomMsgReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_im_protobuf_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SendRoomMsgRsp); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_im_protobuf_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetUserListReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_im_protobuf_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetUserListRsp); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_im_protobuf_proto_rawDesc, + NumEnums: 0, + NumMessages: 8, + NumExtensions: 0, + NumServices: 1, }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "im_protobuf.proto", + GoTypes: file_im_protobuf_proto_goTypes, + DependencyIndexes: file_im_protobuf_proto_depIdxs, + MessageInfos: file_im_protobuf_proto_msgTypes, + }.Build() + File_im_protobuf_proto = out.File + file_im_protobuf_proto_rawDesc = nil + file_im_protobuf_proto_goTypes = nil + file_im_protobuf_proto_depIdxs = nil } diff --git a/protobuf/im_protobuf.proto b/protobuf/im_protobuf.proto index 7729ff2..7d457a4 100644 --- a/protobuf/im_protobuf.proto +++ b/protobuf/im_protobuf.proto @@ -1,5 +1,6 @@ syntax = "proto3"; +option go_package = "../protobuf"; option java_multiple_files = true; option java_package = "io.grpc.examples.protobuf"; option java_outer_classname = "ProtobufProto"; @@ -10,23 +11,19 @@ package protobuf; // The AccServer service definition. service AccServer { // 查询用户是否在线 - rpc QueryUsersOnline (QueryUsersOnlineReq) returns (QueryUsersOnlineRsp) { - } + rpc QueryUsersOnline (QueryUsersOnlineReq) returns (QueryUsersOnlineRsp){} // 发送消息 - rpc SendMsg (SendMsgReq) returns (SendMsgRsp) { - } - // 给这台机器的房间内所有用户发送消息 - rpc SendMsgAll (SendMsgAllReq) returns (SendMsgAllRsp) { - } + rpc SendMsg (SendMsgReq) returns (SendMsgRsp){} + // 发送群消息 + rpc SendRoomMsg (SendRoomMsgReq) returns (SendRoomMsgRsp){} // 获取用户列表 - rpc GetUserList (GetUserListReq) returns (GetUserListRsp) { - } + rpc GetUserList (GetUserListReq) returns (GetUserListRsp){} } // 查询用户是否在线 message QueryUsersOnlineReq { - uint32 appId = 1; // AppID - string userId = 2; // 用户ID + uint32 appID = 1; // appID + string userID = 2; // userID } message QueryUsersOnlineRsp { @@ -38,43 +35,46 @@ message QueryUsersOnlineRsp { // 发送消息 message SendMsgReq { string seq = 1; // 序列号 - uint32 appId = 2; // appId/房间Id - string userId = 3; // 用户ID - string cms = 4; // cms 动作: msg/enter/exit - string type = 5; // type 消息类型,默认是 text - string msg = 6; // msg - bool isLocal = 7; // 是否查询本机 acc内部调用为:true(本机查询不到即结束) + uint32 appID = 2; // appID + string sendUserID = 3; // 发送者用户ID + string userID = 4; // 接收者用户ID + string cms = 5; // cms 动作: msg/enter/exit + string type = 6; // type 消息类型,默认是 text + string msg = 7; // msg + bool isLocal = 8; // 是否查询本机 acc内部调用为:true(本机查询不到即结束) } message SendMsgRsp { uint32 retCode = 1; string errMsg = 2; - string sendMsgId = 3; + string sendMsgID = 3; // 消息ID } // 给这台机器的房间内所有用户发送消息 -message SendMsgAllReq { +message SendRoomMsgReq { string seq = 1; // 序列号 - uint32 appId = 2; // appId/房间Id - string userId = 3; // 不发送的用户ID - string cms = 4; // cms 动作: msg/enter/exit - string type = 5; // type 消息类型,默认是 text - string msg = 6; // msg + uint32 appID = 2; // appID + uint32 roomID = 3; // roomID + string userID = 4; // 发送者ID + string cms = 5; // cms 动作: msg/enter/exit + string type = 6; // type 消息类型,默认是 text + string msg = 7; // msg } -message SendMsgAllRsp { +message SendRoomMsgRsp { uint32 retCode = 1; string errMsg = 2; - string sendMsgId = 3; + string sendMsgID = 3; } // 获取用户列表 message GetUserListReq { - uint32 appId = 1; + uint32 appID = 1; // appID + uint32 roomID = 2; // 房间ID 不填,则获取整个APP的用户 } message GetUserListRsp { uint32 retCode = 1; string errMsg = 2; - repeated string userId = 3; + repeated string userID = 3; } \ No newline at end of file diff --git a/protobuf/im_protobuf_grpc.pb.go b/protobuf/im_protobuf_grpc.pb.go new file mode 100644 index 0000000..023319f --- /dev/null +++ b/protobuf/im_protobuf_grpc.pb.go @@ -0,0 +1,217 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. + +package protobuf + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +// AccServerClient is the client API for AccServer service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type AccServerClient interface { + // 查询用户是否在线 + QueryUsersOnline(ctx context.Context, in *QueryUsersOnlineReq, opts ...grpc.CallOption) (*QueryUsersOnlineRsp, error) + // 发送消息 + SendMsg(ctx context.Context, in *SendMsgReq, opts ...grpc.CallOption) (*SendMsgRsp, error) + // 发送群消息 + SendRoomMsg(ctx context.Context, in *SendRoomMsgReq, opts ...grpc.CallOption) (*SendRoomMsgRsp, error) + // 获取用户列表 + GetUserList(ctx context.Context, in *GetUserListReq, opts ...grpc.CallOption) (*GetUserListRsp, error) +} + +type accServerClient struct { + cc grpc.ClientConnInterface +} + +func NewAccServerClient(cc grpc.ClientConnInterface) AccServerClient { + return &accServerClient{cc} +} + +func (c *accServerClient) QueryUsersOnline(ctx context.Context, in *QueryUsersOnlineReq, opts ...grpc.CallOption) (*QueryUsersOnlineRsp, error) { + out := new(QueryUsersOnlineRsp) + err := c.cc.Invoke(ctx, "/protobuf.AccServer/QueryUsersOnline", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *accServerClient) SendMsg(ctx context.Context, in *SendMsgReq, opts ...grpc.CallOption) (*SendMsgRsp, error) { + out := new(SendMsgRsp) + err := c.cc.Invoke(ctx, "/protobuf.AccServer/SendMsg", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *accServerClient) SendRoomMsg(ctx context.Context, in *SendRoomMsgReq, opts ...grpc.CallOption) (*SendRoomMsgRsp, error) { + out := new(SendRoomMsgRsp) + err := c.cc.Invoke(ctx, "/protobuf.AccServer/SendRoomMsg", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *accServerClient) GetUserList(ctx context.Context, in *GetUserListReq, opts ...grpc.CallOption) (*GetUserListRsp, error) { + out := new(GetUserListRsp) + err := c.cc.Invoke(ctx, "/protobuf.AccServer/GetUserList", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// AccServerServer is the server API for AccServer service. +// All implementations must embed UnimplementedAccServerServer +// for forward compatibility +type AccServerServer interface { + // 查询用户是否在线 + QueryUsersOnline(context.Context, *QueryUsersOnlineReq) (*QueryUsersOnlineRsp, error) + // 发送消息 + SendMsg(context.Context, *SendMsgReq) (*SendMsgRsp, error) + // 发送群消息 + SendRoomMsg(context.Context, *SendRoomMsgReq) (*SendRoomMsgRsp, error) + // 获取用户列表 + GetUserList(context.Context, *GetUserListReq) (*GetUserListRsp, error) + mustEmbedUnimplementedAccServerServer() +} + +// UnimplementedAccServerServer must be embedded to have forward compatible implementations. +type UnimplementedAccServerServer struct { +} + +func (UnimplementedAccServerServer) QueryUsersOnline(context.Context, *QueryUsersOnlineReq) (*QueryUsersOnlineRsp, error) { + return nil, status.Errorf(codes.Unimplemented, "method QueryUsersOnline not implemented") +} +func (UnimplementedAccServerServer) SendMsg(context.Context, *SendMsgReq) (*SendMsgRsp, error) { + return nil, status.Errorf(codes.Unimplemented, "method SendMsg not implemented") +} +func (UnimplementedAccServerServer) SendRoomMsg(context.Context, *SendRoomMsgReq) (*SendRoomMsgRsp, error) { + return nil, status.Errorf(codes.Unimplemented, "method SendRoomMsg not implemented") +} +func (UnimplementedAccServerServer) GetUserList(context.Context, *GetUserListReq) (*GetUserListRsp, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetUserList not implemented") +} +func (UnimplementedAccServerServer) mustEmbedUnimplementedAccServerServer() {} + +// UnsafeAccServerServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to AccServerServer will +// result in compilation errors. +type UnsafeAccServerServer interface { + mustEmbedUnimplementedAccServerServer() +} + +func RegisterAccServerServer(s grpc.ServiceRegistrar, srv AccServerServer) { + s.RegisterService(&AccServer_ServiceDesc, srv) +} + +func _AccServer_QueryUsersOnline_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryUsersOnlineReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AccServerServer).QueryUsersOnline(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/protobuf.AccServer/QueryUsersOnline", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AccServerServer).QueryUsersOnline(ctx, req.(*QueryUsersOnlineReq)) + } + return interceptor(ctx, in, info, handler) +} + +func _AccServer_SendMsg_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(SendMsgReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AccServerServer).SendMsg(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/protobuf.AccServer/SendMsg", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AccServerServer).SendMsg(ctx, req.(*SendMsgReq)) + } + return interceptor(ctx, in, info, handler) +} + +func _AccServer_SendRoomMsg_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(SendRoomMsgReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AccServerServer).SendRoomMsg(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/protobuf.AccServer/SendRoomMsg", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AccServerServer).SendRoomMsg(ctx, req.(*SendRoomMsgReq)) + } + return interceptor(ctx, in, info, handler) +} + +func _AccServer_GetUserList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetUserListReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AccServerServer).GetUserList(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/protobuf.AccServer/GetUserList", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AccServerServer).GetUserList(ctx, req.(*GetUserListReq)) + } + return interceptor(ctx, in, info, handler) +} + +// AccServer_ServiceDesc is the grpc.ServiceDesc for AccServer service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var AccServer_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "protobuf.AccServer", + HandlerType: (*AccServerServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "QueryUsersOnline", + Handler: _AccServer_QueryUsersOnline_Handler, + }, + { + MethodName: "SendMsg", + Handler: _AccServer_SendMsg_Handler, + }, + { + MethodName: "SendRoomMsg", + Handler: _AccServer_SendRoomMsg_Handler, + }, + { + MethodName: "GetUserList", + Handler: _AccServer_GetUserList_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "im_protobuf.proto", +} From 626ee12235667e5cbc397ae3df50275dc1de82e7 Mon Sep 17 00:00:00 2001 From: link1st <562117637@qq.com> Date: 2021年2月21日 15:15:43 +0800 Subject: [PATCH 2/2] =?UTF-8?q?feat:=20=E6=98=8E=E7=A1=AE=E5=8C=BA?= =?UTF-8?q?=E5=88=86=20appID=E3=80=81roomID=E3=80=81userID?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/error_code.go | 4 +- controllers/base_controller.go | 1 + controllers/home/home_controller.go | 19 ++-- controllers/systems/system_controller.go | 7 +- controllers/user/user_controller.go | 82 ++++++---------- go.mod | 13 ++- go.sum | 65 +++++++++++++ helper/order_helper.go | 8 +- helper/server_helper.go | 5 +- helper/strings_helper.go | 16 ++++ lib/cache/user_cache.go | 2 +- models/msg_model.go | 22 ++--- models/request_model.go | 8 +- models/response_model.go | 2 +- models/server_model.go | 8 +- models/user_model.go | 20 ++-- protobuf/gen.sh | 6 +- routers/acc_routers.go | 2 +- routers/web_routers.go | 5 +- servers/grpcclient/grpc_client.go | 114 ++++++++++------------- servers/grpcserver/grpc_server.go | 88 +++++++---------- servers/task/clean_connection _task.go | 6 +- servers/task/server_task.go | 8 +- servers/task/task_init.go | 16 ++-- servers/websocket/acc_controller.go | 32 +++---- servers/websocket/acc_process.go | 2 +- servers/websocket/client.go | 20 ++-- servers/websocket/client_manager.go | 64 +++++++------ servers/websocket/init_acc.go | 30 +++--- servers/websocket/user_srv.go | 81 ++++++---------- views/home/index.tpl | 32 +++---- 31 files changed, 381 insertions(+), 407 deletions(-) create mode 100644 helper/strings_helper.go diff --git a/common/error_code.go b/common/error_code.go index 10e01c0..2ab937c 100644 --- a/common/error_code.go +++ b/common/error_code.go @@ -11,7 +11,7 @@ const ( OK = 200 // Success NotLoggedIn = 1000 // 未登录 ParameterIllegal = 1001 // 参数不合法 - UnauthorizedUserId = 1002 // 非法的用户Id + UnauthorizedUserID = 1002 // 非法的用户Id Unauthorized = 1003 // 未授权 ServerError = 1004 // 系统错误 NotData = 1005 // 没有数据 @@ -29,7 +29,7 @@ func GetErrorMessage(code uint32, message string) string { OK: "Success", NotLoggedIn: "未登录", ParameterIllegal: "参数不合法", - UnauthorizedUserId: "非法的用户Id", + UnauthorizedUserID: "非法的用户Id", Unauthorized: "未授权", NotData: "没有数据", ServerError: "系统错误", diff --git a/controllers/base_controller.go b/controllers/base_controller.go index b241d4f..b956b27 100644 --- a/controllers/base_controller.go +++ b/controllers/base_controller.go @@ -13,6 +13,7 @@ import ( "net/http" ) +// BaseController 基础控制器 type BaseController struct { gin.Context } diff --git a/controllers/home/home_controller.go b/controllers/home/home_controller.go index b4c8d98..dd42abf 100644 --- a/controllers/home/home_controller.go +++ b/controllers/home/home_controller.go @@ -11,26 +11,21 @@ import ( "fmt" "github.com/gin-gonic/gin" "github.com/spf13/viper" + "gowebsocket/helper" "gowebsocket/servers/websocket" "net/http" - "strconv" ) -// 聊天页面 +// Index 聊天页面 func Index(c *gin.Context) { - - appIdStr := c.Query("appId") - appIdUint64, _ := strconv.ParseInt(appIdStr, 10, 32) - appId := uint32(appIdUint64) - if !websocket.InAppIds(appId) { - appId = websocket.GetDefaultAppId() + appID := helper.StrToUint32(c.Query("appID")) + if !websocket.InAppIDs(appID) { + appID = websocket.GetDefaultAppID() } - - fmt.Println("http_request 聊天首页", appId) - + fmt.Println("http_request 聊天首页", appID) data := gin.H{ "title": "聊天首页", - "appId": appId, + "appID": appID, "httpUrl": viper.GetString("app.httpUrl"), "webSocketUrl": viper.GetString("app.webSocketUrl"), } diff --git a/controllers/systems/system_controller.go b/controllers/systems/system_controller.go index 57aa9bf..73d4b97 100644 --- a/controllers/systems/system_controller.go +++ b/controllers/systems/system_controller.go @@ -16,23 +16,18 @@ import ( "runtime" ) -// 查询系统状态 +// Status 查询系统状态 func Status(c *gin.Context) { - isDebug := c.Query("isDebug") fmt.Println("http_request 查询系统状态", isDebug) - data := make(map[string]interface{}) - numGoroutine := runtime.NumGoroutine() numCPU := runtime.NumCPU() // goroutine 的数量 data["numGoroutine"] = numGoroutine data["numCPU"] = numCPU - // ClientManager 信息 data["managerInfo"] = websocket.GetManagerInfo(isDebug) - controllers.Response(c, common.OK, "", data) } diff --git a/controllers/user/user_controller.go b/controllers/user/user_controller.go index ae4be57..1e98fc4 100644 --- a/controllers/user/user_controller.go +++ b/controllers/user/user_controller.go @@ -12,24 +12,21 @@ import ( "github.com/gin-gonic/gin" "gowebsocket/common" "gowebsocket/controllers" + "gowebsocket/helper" "gowebsocket/lib/cache" "gowebsocket/models" "gowebsocket/servers/websocket" "strconv" ) -// 查看全部在线用户 +// List 查看全部在线用户 func List(c *gin.Context) { - - appIdStr := c.Query("appId") - appIdUint64, _ := strconv.ParseInt(appIdStr, 10, 32) - appId := uint32(appIdUint64) - - fmt.Println("http_request 查看全部在线用户", appId) - + appID := helper.StrToUint32(c.Query("appID")) + roomID := helper.StrToUint32(c.Query("roomID")) + fmt.Println("http_request 查看全部在线用户", appID, roomID) data := make(map[string]interface{}) - userList := websocket.UserList(appId) + userList := websocket.UserList(appID, roomID) data["userList"] = userList data["userCount"] = len(userList) @@ -38,85 +35,68 @@ func List(c *gin.Context) { // 查看用户是否在线 func Online(c *gin.Context) { - - userId := c.Query("userId") - appIdStr := c.Query("appId") - appIdUint64, _ := strconv.ParseInt(appIdStr, 10, 32) - appId := uint32(appIdUint64) - - fmt.Println("http_request 查看用户是否在线", userId, appIdStr) + userID := c.Query("userID") + appID := helper.StrToUint32(c.Query("appID")) + fmt.Println("http_request 查看用户是否在线", userID, appID) data := make(map[string]interface{}) - - online := websocket.CheckUserOnline(appId, userId) - data["userId"] = userId + online := websocket.CheckUserOnline(appID, userID) + data["userID"] = userID data["online"] = online - controllers.Response(c, common.OK, "", data) } // 给用户发送消息 func SendMessage(c *gin.Context) { // 获取参数 - appIdStr := c.PostForm("appId") - userId := c.PostForm("userId") - msgId := c.PostForm("msgId") + appIDStr := c.PostForm("appID") + userID := c.PostForm("userID") + msgID := c.PostForm("msgID") message := c.PostForm("message") - appIdUint64, _ := strconv.ParseInt(appIdStr, 10, 32) - appId := uint32(appIdUint64) + appIDUint64, _ := strconv.ParseInt(appIDStr, 10, 32) + appID := uint32(appIDUint64) - fmt.Println("http_request 给用户发送消息", appIdStr, userId, msgId, message) + fmt.Println("http_request 给用户发送消息", appIDStr, userID, msgID, message) // TODO::进行用户权限认证,一般是客户端传入TOKEN,然后检验TOKEN是否合法,通过TOKEN解析出来用户ID - // 本项目只是演示,所以直接过去客户端传入的用户ID(userId) + // 本项目只是演示,所以直接过去客户端传入的用户ID(userID) data := make(map[string]interface{}) - - if cache.SeqDuplicates(msgId) { - fmt.Println("给用户发送消息 重复提交:", msgId) + if cache.SeqDuplicates(msgID) { + fmt.Println("给用户发送消息 重复提交:", msgID) controllers.Response(c, common.OK, "", data) - return } - sendResults, err := websocket.SendUserMessage(appId, userId, msgId, message) + sendResults, err := websocket.SendUserMessage(appID, userID, msgID, message) if err != nil { data["sendResultsErr"] = err.Error() } - data["sendResults"] = sendResults - controllers.Response(c, common.OK, "", data) } -// 给全员发送消息 -func SendMessageAll(c *gin.Context) { +// SendRoomMessage 群成员发送消息 +func SendRoomMessage(c *gin.Context) { // 获取参数 - appIdStr := c.PostForm("appId") - userId := c.PostForm("userId") - msgId := c.PostForm("msgId") + appID := helper.StrToUint32(c.PostForm("appID")) + roomID := helper.StrToUint32(c.PostForm("roomID")) + userID := c.PostForm("userID") + msgID := c.PostForm("msgID") message := c.PostForm("message") - appIdUint64, _ := strconv.ParseInt(appIdStr, 10, 32) - appId := uint32(appIdUint64) - - fmt.Println("http_request 给全体用户发送消息", appIdStr, userId, msgId, message) + fmt.Println("http_request 给全体用户发送消息", appID, roomID, userID, msgID, message) data := make(map[string]interface{}) - if cache.SeqDuplicates(msgId) { - fmt.Println("给用户发送消息 重复提交:", msgId) + if cache.SeqDuplicates(msgID) { + fmt.Println("给用户发送消息 重复提交:", msgID) controllers.Response(c, common.OK, "", data) - return } - - sendResults, err := websocket.SendUserMessageAll(appId, userId, msgId, models.MessageCmdMsg, message) + sendResults, err := websocket.SendRoomMsg(appID, roomID, userID, msgID, models.MessageCmdMsg, message) if err != nil { data["sendResultsErr"] = err.Error() - } - data["sendResults"] = sendResults - controllers.Response(c, common.OK, "", data) } diff --git a/go.mod b/go.mod index 7fe1e7d..0721390 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/gin-contrib/sse v0.1.0 // indirect github.com/gin-gonic/gin v1.4.0 github.com/go-redis/redis v0.0.0-20190719092155-6bc7daa5b1e8 - github.com/golang/protobuf v1.3.2 + github.com/golang/protobuf v1.4.3 github.com/gorilla/websocket v1.4.0 github.com/hashicorp/hcl v1.0.1-0.20190611123218-cf7d376da96d // indirect github.com/json-iterator/go v1.1.7 // indirect @@ -20,8 +20,11 @@ require ( github.com/spf13/viper v1.4.1-0.20190728125013-1b33e8258e07 github.com/subosito/gotenv v1.1.1 // indirect github.com/ugorji/go v1.1.7 // indirect - golang.org/x/net v0.0.0-20190724013045-ca1201d0de80 // indirect - golang.org/x/sys v0.0.0-20190712062909-fae7ac547cb7 // indirect - golang.org/x/text v0.3.2 // indirect - google.golang.org/grpc v1.21.0 + golang.org/x/net v0.0.0-20210220033124-5f55cee0dc0d // indirect + golang.org/x/sys v0.0.0-20210220050731-9a76102bfb43 // indirect + golang.org/x/text v0.3.5 // indirect + google.golang.org/genproto v0.0.0-20210219173056-d891e3cb3b5b // indirect + google.golang.org/grpc v1.35.0 + google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0 // indirect + google.golang.org/protobuf v1.25.0 ) diff --git a/go.sum b/go.sum index a9a70ee..e6f11bc 100644 --- a/go.sum +++ b/go.sum @@ -7,8 +7,10 @@ github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRF github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= @@ -19,6 +21,10 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= +github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.8-0.20190312181446-1485a34d5d57 h1:r+AdyYQnMjCqabCiXfAES7u0tbaqXlLXuZ5FT+5OEQs= github.com/fsnotify/fsnotify v1.4.8-0.20190312181446-1485a34d5d57/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= @@ -44,9 +50,23 @@ github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5y github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= +github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.4.3 h1:JjCZWpVbqXDqFVmTfYWEVTMIYrL/NPdPSCHPJ0T/raM= +github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q= github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= @@ -102,6 +122,7 @@ github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXP github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= @@ -130,6 +151,7 @@ github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/subosito/gotenv v1.1.1 h1:TWxckSF6WVKWbo2M3tMqCtWa9NFUgqM1SSynxmYONOI= github.com/subosito/gotenv v1.1.1/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= @@ -146,21 +168,28 @@ go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/ go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190724013045-ca1201d0de80 h1:Ao/3l156eZf2AW5wK8a7/smtodRU+gha3+BeqJ69lRk= golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20210220033124-5f55cee0dc0d h1:1aflnvSoWWLI2k/dMUAl5lvU1YO4Mb4hz0gh+1rjcxU= +golang.org/x/net v0.0.0-20210220033124-5f55cee0dc0d/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -170,20 +199,55 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190712062909-fae7ac547cb7 h1:LepdCS8Gf/MVejFIt8lsiexZATdoGVyp5bcyS+rYoUI= golang.org/x/sys v0.0.0-20190712062909-fae7ac547cb7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210220050731-9a76102bfb43 h1:SgQ6LNaYJU0JIuEHv9+s6EbhSCwYeAf5Yvj6lpYlqAE= +golang.org/x/sys v0.0.0-20210220050731-9a76102bfb43/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.5 h1:i6eZZ+zk0SOf0xgBpEpPD18qWcJda6q1sxt3S0kzyUQ= +golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8 h1:Nw54tB0rB7hY/N0NQvRW8DG4Yk3Q6T9cu9RcFQDu1tc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 h1:+kGHl1aib/qcwaRi1CbqBZ1rk19r85MNUf8HaBghugY= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= +google.golang.org/genproto v0.0.0-20210219173056-d891e3cb3b5b h1:zTeTu5p/EXQSqNJboHUw32wdNFYQTT9vSc+ibSpCoLk= +google.golang.org/genproto v0.0.0-20210219173056-d891e3cb3b5b/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.21.0 h1:G+97AoqBnmZIT91cLG/EkCoK9NSelj64P8bOHHNmGn0= google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= +google.golang.org/grpc v1.27.0 h1:rRYRFMVgRv6E0D70Skyfsr28tDXIuuPZyWGMPdMcnXg= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.35.0 h1:TwIQcH3es+MojMVojxxfQ3l3OF2KzlRxML2xZq0kRo8= +google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= +google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0 h1:M1YKkFIboKNieVO5DLUEVzQfGwJD30Nv2jfUgzb5UcE= +google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= +google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c= +google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= @@ -202,3 +266,4 @@ gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/helper/order_helper.go b/helper/order_helper.go index c7f9953..cfd55d9 100644 --- a/helper/order_helper.go +++ b/helper/order_helper.go @@ -12,10 +12,8 @@ import ( "time" ) -func GetOrderIdTime() (orderId string) { - +// GetOrderIDTime 生成订单号 +func GetOrderIDTime() (orderId string) { currentTime := time.Now().Nanosecond() - orderId = fmt.Sprintf("%d", currentTime) - - return + return fmt.Sprintf("%d", currentTime) } diff --git a/helper/server_helper.go b/helper/server_helper.go index a09f9da..2f1360d 100644 --- a/helper/server_helper.go +++ b/helper/server_helper.go @@ -11,14 +11,12 @@ import ( "net" ) -// 获取服务器Ip +// GetServerIp 获取服务器Ip func GetServerIp() (ip string) { addrs, err := net.InterfaceAddrs() - if err != nil { return "" } - for _, address := range addrs { // 检查ip地址判断是否回环地址 if ipNet, ok := address.(*net.IPNet); ok && !ipNet.IP.IsLoopback() { @@ -27,6 +25,5 @@ func GetServerIp() (ip string) { } } } - return } diff --git a/helper/strings_helper.go b/helper/strings_helper.go new file mode 100644 index 0000000..38dc13e --- /dev/null +++ b/helper/strings_helper.go @@ -0,0 +1,16 @@ +/** +* Created by GoLand. +* User: link1st +* Date: 2021年2月21日 +* Time: 12:45 + */ + +package helper + +import "strconv" + +// StrToUint32 str to uint32 +func StrToUint32(str string) uint32 { + data, _ := strconv.ParseInt(str, 10, 32) + return uint32(data) +} diff --git a/lib/cache/user_cache.go b/lib/cache/user_cache.go index af1e0d9..74f48f3 100644 --- a/lib/cache/user_cache.go +++ b/lib/cache/user_cache.go @@ -53,7 +53,7 @@ func GetUserOnlineInfo(userKey string) (userOnline *models.UserOnline, err error return } - fmt.Println("获取用户在线数据", userKey, "time", userOnline.LoginTime, userOnline.HeartbeatTime, "AccIp", userOnline.AccIp, userOnline.IsLogoff) + fmt.Println("获取用户在线数据", userKey, "time", userOnline.LoginTime, userOnline.HeartbeatTime, "AccIP", userOnline.AccIP, userOnline.IsLogoff) return } diff --git a/models/msg_model.go b/models/msg_model.go index 7188772..05d6f56 100644 --- a/models/msg_model.go +++ b/models/msg_model.go @@ -36,33 +36,33 @@ func NewTestMsg(from string, Msg string) (message *Message) { return } -func getTextMsgData(cmd, uuId, msgId, message string) string { - textMsg := NewTestMsg(uuId, message) - head := NewResponseHead(msgId, cmd, common.OK, "Ok", textMsg) +func getTextMsgData(cmd, uuID, msgID, message string) string { + textMsg := NewTestMsg(uuID, message) + head := NewResponseHead(msgID, cmd, common.OK, "Ok", textMsg) return head.String() } // 文本消息 -func GetMsgData(uuId, msgId, cmd, message string) string { +func GetMsgData(uuID, msgID, cmd, message string) string { - return getTextMsgData(cmd, uuId, msgId, message) + return getTextMsgData(cmd, uuID, msgID, message) } // 文本消息 -func GetTextMsgData(uuId, msgId, message string) string { +func GetTextMsgData(uuID, msgID, message string) string { - return getTextMsgData("msg", uuId, msgId, message) + return getTextMsgData("msg", uuID, msgID, message) } // 用户进入消息 -func GetTextMsgDataEnter(uuId, msgId, message string) string { +func GetTextMsgDataEnter(uuID, msgID, message string) string { - return getTextMsgData("enter", uuId, msgId, message) + return getTextMsgData("enter", uuID, msgID, message) } // 用户退出消息 -func GetTextMsgDataExit(uuId, msgId, message string) string { +func GetTextMsgDataExit(uuID, msgID, message string) string { - return getTextMsgData("exit", uuId, msgId, message) + return getTextMsgData("exit", uuID, msgID, message) } diff --git a/models/request_model.go b/models/request_model.go index 7c0aea4..c73ca6b 100644 --- a/models/request_model.go +++ b/models/request_model.go @@ -10,7 +10,7 @@ package models /************************ 请求数据 **************************/ // 通用请求数据格式 type Request struct { - Seq string `json:"seq"` // 消息的唯一Id + Seq string `json:"seq"` // 消息的唯一ID Cmd string `json:"cmd"` // 请求命令字 Data interface{} `json:"data,omitempty"` // 数据 json } @@ -18,11 +18,11 @@ type Request struct { // 登录请求数据 type Login struct { ServiceToken string `json:"serviceToken"` // 验证用户是否登录 - AppId uint32 `json:"appId,omitempty"` - UserId string `json:"userId,omitempty"` + AppID uint32 `json:"appID,omitempty"` + UserID string `json:"userID,omitempty"` } // 心跳请求数据 type HeartBeat struct { - UserId string `json:"userId,omitempty"` + UserID string `json:"userID,omitempty"` } diff --git a/models/response_model.go b/models/response_model.go index f508b15..b1d3bda 100644 --- a/models/response_model.go +++ b/models/response_model.go @@ -11,7 +11,7 @@ import "encoding/json" /************************ 响应数据 **************************/ type Head struct { - Seq string `json:"seq"` // 消息的Id + Seq string `json:"seq"` // 消息的ID Cmd string `json:"cmd"` // 消息的cmd 动作 Response *Response `json:"response"` // 消息体 } diff --git a/models/server_model.go b/models/server_model.go index fa3ebea..7912013 100644 --- a/models/server_model.go +++ b/models/server_model.go @@ -14,13 +14,13 @@ import ( ) type Server struct { - Ip string `json:"ip"` // ip + IP string `json:"ip"` // ip Port string `json:"port"` // 端口 } func NewServer(ip string, port string) *Server { - return &Server{Ip: ip, Port: port} + return &Server{IP: ip, Port: port} } func (s *Server) String() (str string) { @@ -28,7 +28,7 @@ func (s *Server) String() (str string) { return } - str = fmt.Sprintf("%s:%s", s.Ip, s.Port) + str = fmt.Sprintf("%s:%s", s.IP, s.Port) return } @@ -41,7 +41,7 @@ func StringToServer(str string) (server *Server, err error) { } server = &Server{ - Ip: list[0], + IP: list[0], Port: list[1], } diff --git a/models/user_model.go b/models/user_model.go index 07bd441..be8367d 100644 --- a/models/user_model.go +++ b/models/user_model.go @@ -18,10 +18,10 @@ const ( // 用户在线状态 type UserOnline struct { - AccIp string `json:"accIp"` // acc Ip + AccIP string `json:"accIp"` // acc IP AccPort string `json:"accPort"` // acc 端口 - AppId uint32 `json:"appId"` // appId - UserId string `json:"userId"` // 用户Id + AppID uint32 `json:"appID"` // appID + UserID string `json:"userID"` // 用户ID ClientIp string `json:"clientIp"` // 客户端Ip ClientPort string `json:"clientPort"` // 客户端端口 LoginTime uint64 `json:"loginTime"` // 用户上次登录时间 @@ -35,13 +35,13 @@ type UserOnline struct { /********************** 数据处理 *********************************/ // 用户登录 -func UserLogin(accIp, accPort string, appId uint32, userId string, addr string, loginTime uint64) (userOnline *UserOnline) { +func UserLogin(accIp, accPort string, appID uint32, userID string, addr string, loginTime uint64) (userOnline *UserOnline) { userOnline = &UserOnline{ - AccIp: accIp, + AccIP: accIp, AccPort: accPort, - AppId: appId, - UserId: userId, + AppID: appID, + UserID: userID, ClientIp: addr, LoginTime: loginTime, HeartbeatTime: loginTime, @@ -82,13 +82,13 @@ func (u *UserOnline) IsOnline() (online bool) { currentTime := uint64(time.Now().Unix()) if u.HeartbeatTime < (currentTime - heartbeatTimeout) { - fmt.Println("用户是否在线 心跳超时", u.AppId, u.UserId, u.HeartbeatTime) + fmt.Println("用户是否在线 心跳超时", u.AppID, u.UserID, u.HeartbeatTime) return } if u.IsLogoff { - fmt.Println("用户是否在线 用户已经下线", u.AppId, u.UserId) + fmt.Println("用户是否在线 用户已经下线", u.AppID, u.UserID) return } @@ -99,7 +99,7 @@ func (u *UserOnline) IsOnline() (online bool) { // 用户是否在本台机器上 func (u *UserOnline) UserIsLocal(localIp, localPort string) (result bool) { - if u.AccIp == localIp && u.AccPort == localPort { + if u.AccIP == localIp && u.AccPort == localPort { result = true return diff --git a/protobuf/gen.sh b/protobuf/gen.sh index 8dae6cb..67e4542 100755 --- a/protobuf/gen.sh +++ b/protobuf/gen.sh @@ -1,3 +1,5 @@ -#!/usr/bin/env bash +#!/bin/bash -protoc --go_out=plugins=grpc:. im_protobuf.proto +protoc --go_out=. --go_opt=paths=source_relative \ + --go-grpc_out=. --go-grpc_opt=paths=source_relative \ + im_protobuf.proto \ No newline at end of file diff --git a/routers/acc_routers.go b/routers/acc_routers.go index 86e7f78..aa50660 100644 --- a/routers/acc_routers.go +++ b/routers/acc_routers.go @@ -11,7 +11,7 @@ import ( "gowebsocket/servers/websocket" ) -// Websocket 路由 +// WebsocketInit websocket路由 func WebsocketInit() { websocket.Register("login", websocket.LoginController) websocket.Register("heartbeat", websocket.HeartbeatController) diff --git a/routers/web_routers.go b/routers/web_routers.go index 24d2a7d..89dfc45 100644 --- a/routers/web_routers.go +++ b/routers/web_routers.go @@ -14,6 +14,7 @@ import ( "gowebsocket/controllers/user" ) +// Init init func Init(router *gin.Engine) { router.LoadHTMLGlob("views/**/*") @@ -23,7 +24,7 @@ func Init(router *gin.Engine) { userRouter.GET("/list", user.List) userRouter.GET("/online", user.Online) userRouter.POST("/sendMessage", user.SendMessage) - userRouter.POST("/sendMessageAll", user.SendMessageAll) + userRouter.POST("/sendRoomMessage", user.SendRoomMessage) } // 系统 @@ -37,6 +38,4 @@ func Init(router *gin.Engine) { { homeRouter.GET("/index", home.Index) } - - // router.POST("/user/online", user.Online) } diff --git a/servers/grpcclient/grpc_client.go b/servers/grpcclient/grpc_client.go index 04427e8..f2ecc14 100644 --- a/servers/grpcclient/grpc_client.go +++ b/servers/grpcclient/grpc_client.go @@ -14,15 +14,12 @@ import ( "google.golang.org/grpc" "gowebsocket/common" "gowebsocket/models" - "gowebsocket/protobuf" + pb "gowebsocket/protobuf" "time" ) -// rpc client -// 给全体用户发送消息 -// link::https://github.com/grpc/grpc-go/blob/master/examples/helloworld/greeter_client/main.go -func SendMsgAll(server *models.Server, seq string, appId uint32, userId string, cmd string, message string) (sendMsgId string, err error) { - // Set up a connection to the server. +// SendMsg 给用户发送消息 +func SendMsg(server *models.Server, seq string, appID uint32, userID string, cmd string, msgType string, message string) (sendMsgID string, err error) { conn, err := grpc.Dial(server.String(), grpc.WithInsecure()) if err != nil { fmt.Println("连接失败", server.String()) @@ -31,42 +28,41 @@ func SendMsgAll(server *models.Server, seq string, appId uint32, userId string, } defer conn.Close() - c := protobuf.NewAccServerClient(conn) + c := pb.NewAccServerClient(conn) ctx, cancel := context.WithTimeout(context.Background(), time.Second) defer cancel() - req := protobuf.SendMsgAllReq{ - Seq: seq, - AppId: appId, - UserId: userId, - Cms: cmd, - Msg: message, + req := pb.SendMsgReq{ + Seq: seq, + AppID: appID, + SendUserID: userID, // 发送者用户ID + UserID: userID, // 接收者用户ID + Cms: cmd, + Type: msgType, + Msg: message, + IsLocal: false, } - rsp, err := c.SendMsgAll(ctx, &req) + rsp, err := c.SendMsg(ctx, &req) if err != nil { - fmt.Println("给全体用户发送消息", err) + fmt.Println("发送消息", err) return } - if rsp.GetRetCode() != common.OK { - fmt.Println("给全体用户发送消息", rsp.String()) + fmt.Println("发送消息", rsp.String()) err = errors.New(fmt.Sprintf("发送消息失败 code:%d", rsp.GetRetCode())) - return } - - sendMsgId = rsp.GetSendMsgId() - fmt.Println("给全体用户发送消息 成功:", sendMsgId) - + sendMsgID = rsp.GetSendMsgID() + fmt.Println("发送消息 成功:", sendMsgID) return } -// 获取用户列表 +// rpc client +// 给房间内用户发送消息 // link::https://github.com/grpc/grpc-go/blob/master/examples/helloworld/greeter_client/main.go -func GetUserList(server *models.Server, appId uint32) (userIds []string, err error) { - userIds = make([]string, 0) - +func SendRoomMsg(server *models.Server, seq string, appID, roomID uint32, userID string, cmd string, message string) (sendMsgID string, err error) { + // Set up a connection to the server. conn, err := grpc.Dial(server.String(), grpc.WithInsecure()) if err != nil { fmt.Println("连接失败", server.String()) @@ -74,76 +70,60 @@ func GetUserList(server *models.Server, appId uint32) (userIds []string, err err return } defer conn.Close() - - c := protobuf.NewAccServerClient(conn) + c := pb.NewAccServerClient(conn) ctx, cancel := context.WithTimeout(context.Background(), time.Second) defer cancel() - - req := protobuf.GetUserListReq{ - AppId: appId, + req := pb.SendRoomMsgReq{ + Seq: seq, + AppID: appID, + RoomID: roomID, + UserID: userID, + Cms: cmd, + Msg: message, } - rsp, err := c.GetUserList(ctx, &req) + rsp, err := c.SendRoomMsg(ctx, &req) if err != nil { - fmt.Println("获取用户列表 发送请求错误:", err) - + fmt.Println("给全体用户发送消息", err) return } - if rsp.GetRetCode() != common.OK { - fmt.Println("获取用户列表 返回码错误:", rsp.String()) + fmt.Println("给全体用户发送消息", rsp.String()) err = errors.New(fmt.Sprintf("发送消息失败 code:%d", rsp.GetRetCode())) - return } - - userIds = rsp.GetUserId() - fmt.Println("获取用户列表 成功:", userIds) - + sendMsgID = rsp.GetSendMsgID() + fmt.Println("给全体用户发送消息 成功:", sendMsgID) return } -// rpc client -// 发送消息 +// 获取用户列表 // link::https://github.com/grpc/grpc-go/blob/master/examples/helloworld/greeter_client/main.go -func SendMsg(server *models.Server, seq string, appId uint32, userId string, cmd string, msgType string, message string) (sendMsgId string, err error) { - // Set up a connection to the server. +func GetUserList(server *models.Server, appID, roomID uint32) (userIDs []string, err error) { + userIDs = make([]string, 0) conn, err := grpc.Dial(server.String(), grpc.WithInsecure()) if err != nil { fmt.Println("连接失败", server.String()) - return } defer conn.Close() - - c := protobuf.NewAccServerClient(conn) + c := pb.NewAccServerClient(conn) ctx, cancel := context.WithTimeout(context.Background(), time.Second) defer cancel() - - req := protobuf.SendMsgReq{ - Seq: seq, - AppId: appId, - UserId: userId, - Cms: cmd, - Type: msgType, - Msg: message, - IsLocal: false, + req := pb.GetUserListReq{ + AppID: appID, + RoomID: roomID, } - rsp, err := c.SendMsg(ctx, &req) + rsp, err := c.GetUserList(ctx, &req) if err != nil { - fmt.Println("发送消息", err) - + fmt.Println("获取用户列表 发送请求错误:", err) return } - if rsp.GetRetCode() != common.OK { - fmt.Println("发送消息", rsp.String()) + fmt.Println("获取用户列表 返回码错误:", rsp.String()) err = errors.New(fmt.Sprintf("发送消息失败 code:%d", rsp.GetRetCode())) - return } - - sendMsgId = rsp.GetSendMsgId() - fmt.Println("发送消息 成功:", sendMsgId) - + userIDs = rsp.GetUserID() + fmt.Println("获取用户列表 成功:", userIDs) return } diff --git a/servers/grpcserver/grpc_server.go b/servers/grpcserver/grpc_server.go index eeb7393..016bb6f 100644 --- a/servers/grpcserver/grpc_server.go +++ b/servers/grpcserver/grpc_server.go @@ -10,143 +10,119 @@ package grpcserver import ( "context" "fmt" + "github.com/golang/protobuf/jsonpb" "github.com/golang/protobuf/proto" "github.com/spf13/viper" "google.golang.org/grpc" "gowebsocket/common" "gowebsocket/models" - "gowebsocket/protobuf" + pb "gowebsocket/protobuf" "gowebsocket/servers/websocket" "log" "net" ) +// server server type server struct { + pb.UnimplementedAccServerServer } +// setErr 设置错误信息 func setErr(rsp proto.Message, code uint32, message string) { - message = common.GetErrorMessage(code, message) switch v := rsp.(type) { - case *protobuf.QueryUsersOnlineRsp: + case *pb.QueryUsersOnlineRsp: v.RetCode = code v.ErrMsg = message - case *protobuf.SendMsgRsp: + case *pb.SendMsgRsp: v.RetCode = code v.ErrMsg = message - case *protobuf.SendMsgAllRsp: + case *pb.SendRoomMsgRsp: v.RetCode = code v.ErrMsg = message - case *protobuf.GetUserListRsp: + case *pb.GetUserListRsp: v.RetCode = code v.ErrMsg = message default: - } - } // 查询用户是否在线 -func (s *server) QueryUsersOnline(c context.Context, req *protobuf.QueryUsersOnlineReq) (rsp *protobuf.QueryUsersOnlineRsp, err error) { - - fmt.Println("grpc_request 查询用户是否在线", req.String()) - - rsp = &protobuf.QueryUsersOnlineRsp{} - - online := websocket.CheckUserOnline(req.GetAppId(), req.GetUserId()) +func (s *server) QueryUsersOnline(_ context.Context, req *pb.QueryUsersOnlineReq) (rsp *pb.QueryUsersOnlineRsp, err error) { + searchRspStr, _ := (&jsonpb.Marshaler{}).MarshalToString(req) + fmt.Println("grpc_request 查询用户是否在线", searchRspStr) + // 发送请求 + rsp = &pb.QueryUsersOnlineRsp{} + online := websocket.CheckUserOnline(req.GetAppID(), req.GetUserID()) setErr(req, common.OK, "") rsp.Online = online - return rsp, nil } // 给本机用户发消息 -func (s *server) SendMsg(c context.Context, req *protobuf.SendMsgReq) (rsp *protobuf.SendMsgRsp, err error) { - +func (s *server) SendMsg(_ context.Context, req *pb.SendMsgReq) (rsp *pb.SendMsgRsp, err error) { fmt.Println("grpc_request 给本机用户发消息", req.String()) - - rsp = &protobuf.SendMsgRsp{} - + rsp = &pb.SendMsgRsp{} if req.GetIsLocal() { - // 不支持 setErr(rsp, common.ParameterIllegal, "") - return } - data := models.GetMsgData(req.GetUserId(), req.GetSeq(), req.GetCms(), req.GetMsg()) - sendResults, err := websocket.SendUserMessageLocal(req.GetAppId(), req.GetUserId(), data) + data := models.GetMsgData(req.GetUserID(), req.GetSeq(), req.GetCms(), req.GetMsg()) + sendResults, err := websocket.SendUserMessageLocal(req.GetAppID(), req.GetUserID(), data) if err != nil { fmt.Println("系统错误", err) setErr(rsp, common.ServerError, "") - return rsp, nil } - if !sendResults { fmt.Println("发送失败", err) setErr(rsp, common.OperationFailure, "") - return rsp, nil } - setErr(rsp, common.OK, "") - fmt.Println("grpc_response 给本机用户发消息", rsp.String()) return } -// 给本机全体用户发消息 -func (s *server) SendMsgAll(c context.Context, req *protobuf.SendMsgAllReq) (rsp *protobuf.SendMsgAllRsp, err error) { - - fmt.Println("grpc_request 给本机全体用户发消息", req.String()) - - rsp = &protobuf.SendMsgAllRsp{} - - data := models.GetMsgData(req.GetUserId(), req.GetSeq(), req.GetCms(), req.GetMsg()) - websocket.AllSendMessages(req.GetAppId(), req.GetUserId(), data) - +// SendRoomMsg 给房间内用法发送消息 +func (s *server) SendRoomMsg(_ context.Context, req *pb.SendRoomMsgReq) (rsp *pb.SendRoomMsgRsp, err error) { + fmt.Println("grpc_request 给房间内用法发送消息", req.String()) + rsp = &pb.SendRoomMsgRsp{} + data := models.GetMsgData(req.GetUserID(), req.GetSeq(), req.GetCms(), req.GetMsg()) + websocket.AllSendMessages(req.GetAppID(), req.GetUserID(), data) setErr(rsp, common.OK, "") - - fmt.Println("grpc_response 给本机全体用户发消息:", rsp.String()) + fmt.Println("grpc_response 给房间内用法发送消息:", rsp.String()) return } // 获取本机用户列表 -func (s *server) GetUserList(c context.Context, req *protobuf.GetUserListReq) (rsp *protobuf.GetUserListRsp, err error) { - +func (s *server) GetUserList(_ context.Context, req *pb.GetUserListReq) (rsp *pb.GetUserListRsp, err error) { fmt.Println("grpc_request 获取本机用户列表", req.String()) - - appId := req.GetAppId() - rsp = &protobuf.GetUserListRsp{} - + appID := req.GetAppID() + rsp = &pb.GetUserListRsp{} // 本机 - userList := websocket.GetUserList(appId) - + userList := websocket.GetUserList(appID) setErr(rsp, common.OK, "") - rsp.UserId = userList - + rsp.UserID = userList fmt.Println("grpc_response 获取本机用户列表:", rsp.String()) - return } // rpc server // link::https://github.com/grpc/grpc-go/blob/master/examples/helloworld/greeter_server/main.go func Init() { - rpcPort := viper.GetString("app.rpcPort") fmt.Println("rpc server 启动", rpcPort) - lis, err := net.Listen("tcp", ":"+rpcPort) if err != nil { log.Fatalf("failed to listen: %v", err) } s := grpc.NewServer() - protobuf.RegisterAccServerServer(s, &server{}) + pb.RegisterAccServerServer(s, &server{}) if err := s.Serve(lis); err != nil { log.Fatalf("failed to serve: %v", err) } diff --git a/servers/task/clean_connection _task.go b/servers/task/clean_connection _task.go index e98cfe8..ca815e8 100644 --- a/servers/task/clean_connection _task.go +++ b/servers/task/clean_connection _task.go @@ -14,24 +14,20 @@ import ( "time" ) +// Init 清理超时连接定时任务 func Init() { Timer(3*time.Second, 30*time.Second, cleanConnection, "", nil, nil) - } // 清理超时连接 func cleanConnection(param interface{}) (result bool) { result = true - defer func() { if r := recover(); r != nil { fmt.Println("ClearTimeoutConnections stop", r, string(debug.Stack())) } }() - fmt.Println("定时任务,清理超时连接", param) - websocket.ClearTimeoutConnections() - return } diff --git a/servers/task/server_task.go b/servers/task/server_task.go index 9b03c44..79c50c1 100644 --- a/servers/task/server_task.go +++ b/servers/task/server_task.go @@ -15,6 +15,7 @@ import ( "time" ) +// ServerInit 注册服务定时任务 func ServerInit() { Timer(2*time.Second, 60*time.Second, server, "", serverDefer, "") } @@ -22,19 +23,15 @@ func ServerInit() { // 服务注册 func server(param interface{}) (result bool) { result = true - defer func() { if r := recover(); r != nil { fmt.Println("服务注册 stop", r, string(debug.Stack())) } }() - server := websocket.GetServer() currentTime := uint64(time.Now().Unix()) fmt.Println("定时任务,服务注册", param, server, currentTime) - cache.SetServerInfo(server, currentTime) - return } @@ -45,11 +42,8 @@ func serverDefer(param interface{}) (result bool) { fmt.Println("服务下线 stop", r, string(debug.Stack())) } }() - fmt.Println("服务下线", param) - server := websocket.GetServer() cache.DelServerInfo(server) - return } diff --git a/servers/task/task_init.go b/servers/task/task_init.go index 9495d9d..7543940 100644 --- a/servers/task/task_init.go +++ b/servers/task/task_init.go @@ -9,15 +9,14 @@ package task import "time" +// TimerFunc 定时器方法 type TimerFunc func(interface{}) bool -/** - * 定时调用 - * @delay 首次延时 - * @tick 间隔 - * @fun 定时执行function - * @param fun参数 - */ +// Timer +// delay 首次延时 +// tick 间隔 +// fun 定时执行function +// param fun参数 func Timer(delay, tick time.Duration, fun TimerFunc, param interface{}, funcDefer TimerFunc, paramDefer interface{}) { go func() { defer func() { @@ -25,14 +24,11 @@ func Timer(delay, tick time.Duration, fun TimerFunc, param interface{}, funcDefe funcDefer(paramDefer) } }() - if fun == nil { return } - t := time.NewTimer(delay) defer t.Stop() - for { select { case <-t.c: diff --git a/servers/websocket/acc_controller.go b/servers/websocket/acc_controller.go index ad2a858..8f19012 100644 --- a/servers/websocket/acc_controller.go +++ b/servers/websocket/acc_controller.go @@ -46,31 +46,31 @@ func LoginController(client *Client, seq string, message []byte) (code uint32, m // TODO::进行用户权限认证,一般是客户端传入TOKEN,然后检验TOKEN是否合法,通过TOKEN解析出来用户ID // 本项目只是演示,所以直接过去客户端传入的用户ID - if request.UserId == "" || len(request.UserId)>= 20 { - code = common.UnauthorizedUserId - fmt.Println("用户登录 非法的用户", seq, request.UserId) + if request.UserID == "" || len(request.UserID)>= 20 { + code = common.UnauthorizedUserID + fmt.Println("用户登录 非法的用户", seq, request.UserID) return } - if !InAppIds(request.AppId) { + if !InAppIDs(request.AppID) { code = common.Unauthorized - fmt.Println("用户登录 不支持的平台", seq, request.AppId) + fmt.Println("用户登录 不支持的平台", seq, request.AppID) return } if client.IsLogin() { - fmt.Println("用户登录 用户已经登录", client.AppId, client.UserId, seq) + fmt.Println("用户登录 用户已经登录", client.AppID, client.UserID, seq) code = common.OperationFailure return } - client.Login(request.AppId, request.UserId, currentTime) + client.Login(request.AppID, request.UserID, currentTime) // 存储数据 - userOnline := models.UserLogin(serverIp, serverPort, request.AppId, request.UserId, client.Addr, currentTime) + userOnline := models.UserLogin(serverIP, serverPort, request.AppID, request.UserID, client.Addr, currentTime) err := cache.SetUserOnlineInfo(client.GetKey(), userOnline) if err != nil { code = common.ServerError @@ -81,13 +81,13 @@ func LoginController(client *Client, seq string, message []byte) (code uint32, m // 用户登录 login := &login{ - AppId: request.AppId, - UserId: request.UserId, + AppID: request.AppID, + UserID: request.UserID, Client: client, } clientManager.Login <- login - fmt.Println("用户登录 成功", seq, client.Addr, request.UserId) + fmt.Println("用户登录 成功", seq, client.Addr, request.UserID) return } @@ -106,10 +106,10 @@ func HeartbeatController(client *Client, seq string, message []byte) (code uint3 return } - fmt.Println("webSocket_request 心跳接口", client.AppId, client.UserId) + fmt.Println("webSocket_request 心跳接口", client.AppID, client.UserID) if !client.IsLogin() { - fmt.Println("心跳接口 用户未登录", client.AppId, client.UserId, seq) + fmt.Println("心跳接口 用户未登录", client.AppID, client.UserID, seq) code = common.NotLoggedIn return @@ -119,12 +119,12 @@ func HeartbeatController(client *Client, seq string, message []byte) (code uint3 if err != nil { if err == redis.Nil { code = common.NotLoggedIn - fmt.Println("心跳接口 用户未登录", seq, client.AppId, client.UserId) + fmt.Println("心跳接口 用户未登录", seq, client.AppID, client.UserID) return } else { code = common.ServerError - fmt.Println("心跳接口 GetUserOnlineInfo", seq, client.AppId, client.UserId, err) + fmt.Println("心跳接口 GetUserOnlineInfo", seq, client.AppID, client.UserID, err) return } @@ -135,7 +135,7 @@ func HeartbeatController(client *Client, seq string, message []byte) (code uint3 err = cache.SetUserOnlineInfo(client.GetKey(), userOnline) if err != nil { code = common.ServerError - fmt.Println("心跳接口 SetUserOnlineInfo", seq, client.AppId, client.UserId, err) + fmt.Println("心跳接口 SetUserOnlineInfo", seq, client.AppID, client.UserID, err) return } diff --git a/servers/websocket/acc_process.go b/servers/websocket/acc_process.go index 54c00ac..6e7b951 100644 --- a/servers/websocket/acc_process.go +++ b/servers/websocket/acc_process.go @@ -102,7 +102,7 @@ func ProcessData(client *Client, message []byte) { client.SendMsg(headByte) - fmt.Println("acc_response send", client.Addr, client.AppId, client.UserId, "cmd", cmd, "code", code) + fmt.Println("acc_response send", client.Addr, client.AppID, client.UserID, "cmd", cmd, "code", code) return } diff --git a/servers/websocket/client.go b/servers/websocket/client.go index 6ed4349..55e6b46 100644 --- a/servers/websocket/client.go +++ b/servers/websocket/client.go @@ -20,14 +20,14 @@ const ( // 用户登录 type login struct { - AppId uint32 - UserId string + AppID uint32 + UserID string Client *Client } // 读取客户端数据 func (l *login) GetKey() (key string) { - key = GetUserKey(l.AppId, l.UserId) + key = GetUserKey(l.AppID, l.UserID) return } @@ -37,8 +37,8 @@ type Client struct { Addr string // 客户端地址 Socket *websocket.Conn // 用户连接 Send chan []byte // 待发送的数据 - AppId uint32 // 登录的平台Id app/web/ios - UserId string // 用户Id,用户登录以后才有 + AppID uint32 // 登录的平台ID app/web/ios + UserID string // 用户ID,用户登录以后才有 FirstTime uint64 // 首次连接事件 HeartbeatTime uint64 // 用户上次心跳时间 LoginTime uint64 // 登录时间 登录以后才有 @@ -59,7 +59,7 @@ func NewClient(addr string, socket *websocket.Conn, firstTime uint64) (client *C // 读取客户端数据 func (c *Client) GetKey() (key string) { - key = GetUserKey(c.AppId, c.UserId) + key = GetUserKey(c.AppID, c.UserID) return } @@ -144,9 +144,9 @@ func (c *Client) close() { } // 用户登录 -func (c *Client) Login(appId uint32, userId string, loginTime uint64) { - c.AppId = appId - c.UserId = userId +func (c *Client) Login(appID uint32, userID string, loginTime uint64) { + c.AppID = appID + c.UserID = userID c.LoginTime = loginTime // 登录成功=心跳一次 c.Heartbeat(loginTime) @@ -172,7 +172,7 @@ func (c *Client) IsHeartbeatTimeout(currentTime uint64) (timeout bool) { func (c *Client) IsLogin() (isLogin bool) { // 用户登录了 - if c.UserId != "" { + if c.UserID != "" { isLogin = true return diff --git a/servers/websocket/client_manager.go b/servers/websocket/client_manager.go index ba0a1f5..04ae6c2 100644 --- a/servers/websocket/client_manager.go +++ b/servers/websocket/client_manager.go @@ -20,7 +20,7 @@ import ( type ClientManager struct { Clients map[*Client]bool // 全部的连接 ClientsLock sync.RWMutex // 读写锁 - Users map[string]*Client // 登录的用户 // appId+uuid + Users map[string]*Client // 登录的用户 // appID+uuid UserLock sync.RWMutex // 读写锁 Register chan *Client // 连接连接处理 Login chan *login // 用户登录处理 @@ -42,8 +42,8 @@ func NewClientManager() (clientManager *ClientManager) { } // 获取用户key -func GetUserKey(appId uint32, userId string) (key string) { - key = fmt.Sprintf("%d_%s", appId, userId) +func GetUserKey(appID uint32, userID string) (key string) { + key = fmt.Sprintf("%d_%s", appID, userID) return } @@ -117,12 +117,12 @@ func (manager *ClientManager) DelClients(client *Client) { } // 获取用户的连接 -func (manager *ClientManager) GetUserClient(appId uint32, userId string) (client *Client) { +func (manager *ClientManager) GetUserClient(appID uint32, userID string) (client *Client) { manager.UserLock.RLock() defer manager.UserLock.RUnlock() - userKey := GetUserKey(appId, userId) + userKey := GetUserKey(appID, userID) if value, ok := manager.Users[userKey]; ok { client = value } @@ -150,7 +150,7 @@ func (manager *ClientManager) DelUsers(client *Client) (result bool) { manager.UserLock.Lock() defer manager.UserLock.Unlock() - key := GetUserKey(client.AppId, client.UserId) + key := GetUserKey(client.AppID, client.UserID) if value, ok := manager.Users[key]; ok { // 判断是否为相同的用户 if value.Addr != client.Addr { @@ -178,7 +178,7 @@ func (manager *ClientManager) GetUserKeys() (userKeys []string) { } // 获取用户的key -func (manager *ClientManager) GetUserList(appId uint32) (userList []string) { +func (manager *ClientManager) GetUserList(appID uint32) (userList []string) { userList = make([]string, 0) @@ -186,8 +186,8 @@ func (manager *ClientManager) GetUserList(appId uint32) (userList []string) { defer manager.UserLock.RUnlock() for _, v := range manager.Users { - if v.AppId == appId { - userList = append(userList, v.UserId) + if v.AppID == appID { + userList = append(userList, v.UserID) } } @@ -221,11 +221,11 @@ func (manager *ClientManager) sendAll(message []byte, ignoreClient *Client) { } // 向全部成员(除了自己)发送数据 -func (manager *ClientManager) sendAppIdAll(message []byte, appId uint32, ignoreClient *Client) { +func (manager *ClientManager) sendAppIDAll(message []byte, appID uint32, ignoreClient *Client) { clients := manager.GetUserClients() for _, conn := range clients { - if conn != ignoreClient && conn.AppId == appId { + if conn != ignoreClient && conn.AppID == appID { conn.SendMsg(message) } } @@ -250,10 +250,14 @@ func (manager *ClientManager) EventLogin(login *login) { manager.AddUsers(userKey, login.Client) } - fmt.Println("EventLogin 用户登录", client.Addr, login.AppId, login.UserId) + fmt.Println("EventLogin 用户登录", client.Addr, login.AppID, login.UserID) - orderId := helper.GetOrderIdTime() - SendUserMessageAll(login.AppId, login.UserId, orderId, models.MessageCmdEnter, "哈喽~") + orderID := helper.GetOrderIDTime() + // TODO::获取所有 roomID + var ( + roomID uint32 + ) + SendRoomMsg(login.AppID, roomID, login.UserID, orderID, models.MessageCmdEnter, "哈喽~") } // 用户断开连接 @@ -278,11 +282,15 @@ func (manager *ClientManager) EventUnregister(client *Client) { // 关闭 chan // close(client.Send) - fmt.Println("EventUnregister 用户断开连接", client.Addr, client.AppId, client.UserId) + fmt.Println("EventUnregister 用户断开连接", client.Addr, client.AppID, client.UserID) - if client.UserId != "" { - orderId := helper.GetOrderIdTime() - SendUserMessageAll(client.AppId, client.UserId, orderId, models.MessageCmdExit, "用户已经离开~") + if client.UserID != "" { + orderID := helper.GetOrderIDTime() + // TODO::获取所有 roomID + var ( + roomID uint32 + ) + SendRoomMsg(client.AppID, roomID, client.UserID, orderID, models.MessageCmdExit, "用户已经离开~") } } @@ -346,8 +354,8 @@ func GetManagerInfo(isDebug string) (managerInfo map[string]interface{}) { } // 获取用户所在的连接 -func GetUserClient(appId uint32, userId string) (client *Client) { - client = clientManager.GetUserClient(appId, userId) +func GetUserClient(appID uint32, userID string) (client *Client) { + client = clientManager.GetUserClient(appID, userID) return } @@ -359,7 +367,7 @@ func ClearTimeoutConnections() { clients := clientManager.GetClients() for client := range clients { if client.IsHeartbeatTimeout(currentTime) { - fmt.Println("心跳时间超时 关闭连接", client.Addr, client.UserId, client.LoginTime, client.HeartbeatTime) + fmt.Println("心跳时间超时 关闭连接", client.Addr, client.UserID, client.LoginTime, client.HeartbeatTime) client.Socket.Close() } @@ -367,18 +375,18 @@ func ClearTimeoutConnections() { } // 获取全部用户 -func GetUserList(appId uint32) (userList []string) { - fmt.Println("获取全部用户", appId) +func GetUserList(appID uint32) (userList []string) { + fmt.Println("获取全部用户", appID) - userList = clientManager.GetUserList(appId) + userList = clientManager.GetUserList(appID) return } // 全员广播 -func AllSendMessages(appId uint32, userId string, data string) { - fmt.Println("全员广播", appId, userId, data) +func AllSendMessages(appID uint32, userID string, data string) { + fmt.Println("全员广播", appID, userID, data) - ignoreClient := clientManager.GetUserClient(appId, userId) - clientManager.sendAppIdAll([]byte(data), appId, ignoreClient) + ignoreClient := clientManager.GetUserClient(appID, userID) + clientManager.sendAppIDAll([]byte(data), appID, ignoreClient) } diff --git a/servers/websocket/init_acc.go b/servers/websocket/init_acc.go index 72220f5..a7856b1 100644 --- a/servers/websocket/init_acc.go +++ b/servers/websocket/init_acc.go @@ -18,41 +18,41 @@ import ( ) const ( - defaultAppId = 101 // 默认平台Id + defaultAppID = 101 // 默认平台ID ) var ( clientManager = NewClientManager() // 管理者 - appIds = []uint32{defaultAppId, 102, 103, 104} // 全部的平台 + appIDs = []uint32{defaultAppID, 102, 103, 104} // 全部的平台 - serverIp string + serverIP string serverPort string ) -func GetAppIds() []uint32 { +func GetAppIDs() []uint32 { - return appIds + return appIDs } func GetServer() (server *models.Server) { - server = models.NewServer(serverIp, serverPort) + server = models.NewServer(serverIP, serverPort) return } func IsLocal(server *models.Server) (isLocal bool) { - if server.Ip == serverIp && server.Port == serverPort { + if server.IP == serverIP && server.Port == serverPort { isLocal = true } return } -func InAppIds(appId uint32) (inAppId bool) { +func InAppIDs(appID uint32) (inAppID bool) { - for _, value := range appIds { - if value == appId { - inAppId = true + for _, value := range appIDs { + if value == appID { + inAppID = true return } @@ -61,8 +61,8 @@ func InAppIds(appId uint32) (inAppId bool) { return } -func GetDefaultAppId() (appId uint32) { - appId = defaultAppId +func GetDefaultAppID() (appID uint32) { + appID = defaultAppID return } @@ -70,7 +70,7 @@ func GetDefaultAppId() (appId uint32) { // 启动程序 func StartWebSocket() { - serverIp = helper.GetServerIp() + serverIP = helper.GetServerIp() webSocketPort := viper.GetString("app.webSocketPort") rpcPort := viper.GetString("app.rpcPort") @@ -81,7 +81,7 @@ func StartWebSocket() { // 添加处理程序 go clientManager.start() - fmt.Println("WebSocket 启动程序成功", serverIp, serverPort) + fmt.Println("WebSocket 启动程序成功", serverIP, serverPort) http.ListenAndServe(":"+webSocketPort, nil) } diff --git a/servers/websocket/user_srv.go b/servers/websocket/user_srv.go index acfd597..617baae 100644 --- a/servers/websocket/user_srv.go +++ b/servers/websocket/user_srv.go @@ -18,145 +18,118 @@ import ( ) // 查询所有用户 -func UserList(appId uint32) (userList []string) { - +func UserList(appID, roomID uint32) (userList []string) { userList = make([]string, 0) currentTime := uint64(time.Now().Unix()) servers, err := cache.GetServerAll(currentTime) if err != nil { fmt.Println("给全体用户发消息", err) - return } - for _, server := range servers { var ( list []string ) if IsLocal(server) { - list = GetUserList(appId) + list = GetUserList(appID) } else { - list, _ = grpcclient.GetUserList(server, appId) + list, _ = grpcclient.GetUserList(server, appID, roomID) } userList = append(userList, list...) } - return } // 查询用户是否在线 -func CheckUserOnline(appId uint32, userId string) (online bool) { +func CheckUserOnline(appID uint32, userID string) (online bool) { // 全平台查询 - if appId == 0 { - for _, appId := range GetAppIds() { - online, _ = checkUserOnline(appId, userId) + if appID == 0 { + for _, appID := range GetAppIDs() { + online, _ = checkUserOnline(appID, userID) if online == true { break } } } else { - online, _ = checkUserOnline(appId, userId) + online, _ = checkUserOnline(appID, userID) } - return } // 查询用户 是否在线 -func checkUserOnline(appId uint32, userId string) (online bool, err error) { - key := GetUserKey(appId, userId) +func checkUserOnline(appID uint32, userID string) (online bool, err error) { + key := GetUserKey(appID, userID) userOnline, err := cache.GetUserOnlineInfo(key) if err != nil { if err == redis.Nil { - fmt.Println("GetUserOnlineInfo", appId, userId, err) - + fmt.Println("GetUserOnlineInfo", appID, userID, err) return false, nil } - - fmt.Println("GetUserOnlineInfo", appId, userId, err) - + fmt.Println("GetUserOnlineInfo", appID, userID, err) return } - online = userOnline.IsOnline() - return } // 给用户发送消息 -func SendUserMessage(appId uint32, userId string, msgId, message string) (sendResults bool, err error) { - - data := models.GetTextMsgData(userId, msgId, message) - - client := GetUserClient(appId, userId) - +func SendUserMessage(appID uint32, userID string, msgID, message string) (sendResults bool, err error) { + data := models.GetTextMsgData(userID, msgID, message) + client := GetUserClient(appID, userID) if client != nil { // 在本机发送 - sendResults, err = SendUserMessageLocal(appId, userId, data) + sendResults, err = SendUserMessageLocal(appID, userID, data) if err != nil { - fmt.Println("给用户发送消息", appId, userId, err) + fmt.Println("给用户发送消息", appID, userID, err) } - return } - - key := GetUserKey(appId, userId) + key := GetUserKey(appID, userID) info, err := cache.GetUserOnlineInfo(key) if err != nil { fmt.Println("给用户发送消息失败", key, err) - return false, nil } - - server := models.NewServer(info.AccIp, info.AccPort) - msg, err := grpcclient.SendMsg(server, msgId, appId, userId, models.MessageCmdMsg, models.MessageCmdMsg, message) + server := models.NewServer(info.AccIP, info.AccPort) + msg, err := grpcclient.SendMsg(server, msgID, appID, userID, models.MessageCmdMsg, models.MessageCmdMsg, message) if err != nil { fmt.Println("给用户发送消息失败", key, err) - return false, err } fmt.Println("给用户发送消息成功-rpc", msg) sendResults = true - return } // 给本机用户发送消息 -func SendUserMessageLocal(appId uint32, userId string, data string) (sendResults bool, err error) { - - client := GetUserClient(appId, userId) +func SendUserMessageLocal(appID uint32, userID string, data string) (sendResults bool, err error) { + client := GetUserClient(appID, userID) if client == nil { err = errors.New("用户不在线") - return } - // 发送消息 client.SendMsg([]byte(data)) sendResults = true - return } -// 给全体用户发消息 -func SendUserMessageAll(appId uint32, userId string, msgId, cmd, message string) (sendResults bool, err error) { +// SendRoomMsg 给房间用户发送消息 +func SendRoomMsg(appID, roomID uint32, userID string, msgID, cmd, message string) (sendResults bool, err error) { sendResults = true - currentTime := uint64(time.Now().Unix()) servers, err := cache.GetServerAll(currentTime) if err != nil { fmt.Println("给全体用户发消息", err) - return } - for _, server := range servers { if IsLocal(server) { - data := models.GetMsgData(userId, msgId, cmd, message) - AllSendMessages(appId, userId, data) + data := models.GetMsgData(userID, msgID, cmd, message) + AllSendMessages(appID, userID, data) } else { - grpcclient.SendMsgAll(server, msgId, appId, userId, cmd, message) + grpcclient.SendRoomMsg(server, msgID, appID, roomID, userID, cmd, message) } } - return } diff --git a/views/home/index.tpl b/views/home/index.tpl index 2c87ccd..5999670 100644 --- a/views/home/index.tpl +++ b/views/home/index.tpl @@ -2,7 +2,7 @@ - {{ .title }}--房间Id({{ .appId }}) + {{ .title }}--房间ID({{ .appID }})