chat

package
v0.0.0-...-707c192 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 11, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package chat is a reverse proxy.

It translates gRPC into RESTful JSON APIs.

Index

Constants

View Source
const (
	ChatPrivateService_AddBlocked_FullMethodName = "/chat.pb.ChatPrivateService/AddBlocked"
)
View Source
const (
	ChatService_Chat_FullMethodName = "/chat.pb.ChatService/Chat"
)

Variables

View Source
var (
	ChatError_Code_name = map[int32]string{
		0: "CODE_NONE",
		1: "CODE_INTERVAL",
		2: "CODE_BLOCKED",
	}
	ChatError_Code_value = map[string]int32{
		"CODE_NONE":     0,
		"CODE_INTERVAL": 1,
		"CODE_BLOCKED":  2,
	}
)

Enum value maps for ChatError_Code.

View Source
var ChatPrivateService_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "chat.pb.ChatPrivateService",
	HandlerType: (*ChatPrivateServiceServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "AddBlocked",
			Handler:    _ChatPrivateService_AddBlocked_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "chat/chat.proto",
}

ChatPrivateService_ServiceDesc is the grpc.ServiceDesc for ChatPrivateService service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

View Source
var ChatService_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "chat.pb.ChatService",
	HandlerType: (*ChatServiceServer)(nil),
	Methods:     []grpc.MethodDesc{},
	Streams: []grpc.StreamDesc{
		{
			StreamName:    "Chat",
			Handler:       _ChatService_Chat_Handler,
			ServerStreams: true,
			ClientStreams: true,
		},
	},
	Metadata: "chat/chat.proto",
}

ChatService_ServiceDesc is the grpc.ServiceDesc for ChatService service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

View Source
var File_chat_chat_proto protoreflect.FileDescriptor

Functions

func RegisterChatPrivateServiceHandler

func RegisterChatPrivateServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error

RegisterChatPrivateServiceHandler registers the http handlers for service ChatPrivateService to "mux". The handlers forward requests to the grpc endpoint over "conn".

func RegisterChatPrivateServiceHandlerClient

func RegisterChatPrivateServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client ChatPrivateServiceClient) error

RegisterChatPrivateServiceHandlerClient registers the http handlers for service ChatPrivateService to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "ChatPrivateServiceClient". Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "ChatPrivateServiceClient" doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in "ChatPrivateServiceClient" to call the correct interceptors.

func RegisterChatPrivateServiceHandlerFromEndpoint

func RegisterChatPrivateServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)

RegisterChatPrivateServiceHandlerFromEndpoint is same as RegisterChatPrivateServiceHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.

func RegisterChatPrivateServiceHandlerServer

func RegisterChatPrivateServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server ChatPrivateServiceServer) error

RegisterChatPrivateServiceHandlerServer registers the http handlers for service ChatPrivateService to "mux". UnaryRPC :call ChatPrivateServiceServer directly. StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterChatPrivateServiceHandlerFromEndpoint instead.

func RegisterChatPrivateServiceServer

func RegisterChatPrivateServiceServer(s grpc.ServiceRegistrar, srv ChatPrivateServiceServer)

func RegisterChatServiceHandler

func RegisterChatServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error

RegisterChatServiceHandler registers the http handlers for service ChatService to "mux". The handlers forward requests to the grpc endpoint over "conn".

func RegisterChatServiceHandlerClient

func RegisterChatServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client ChatServiceClient) error

RegisterChatServiceHandlerClient registers the http handlers for service ChatService to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "ChatServiceClient". Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "ChatServiceClient" doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in "ChatServiceClient" to call the correct interceptors.

func RegisterChatServiceHandlerFromEndpoint

func RegisterChatServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)

RegisterChatServiceHandlerFromEndpoint is same as RegisterChatServiceHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.

func RegisterChatServiceHandlerServer

func RegisterChatServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server ChatServiceServer) error

RegisterChatServiceHandlerServer registers the http handlers for service ChatService to "mux". UnaryRPC :call ChatServiceServer directly. StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterChatServiceHandlerFromEndpoint instead.

func RegisterChatServiceServer

func RegisterChatServiceServer(s grpc.ServiceRegistrar, srv ChatServiceServer)

Types

type AddBlockedRequest

type AddBlockedRequest struct {

	// profile id
	ProfileId string `protobuf:"bytes,1,opt,name=profile_id,json=profileId,proto3" json:"profile_id,omitempty"`
	IsBlocked bool   `protobuf:"varint,2,opt,name=is_blocked,json=isBlocked,proto3" json:"is_blocked,omitempty"` // true: add blocked list, false: remove blocked list
	Duration  int64  `protobuf:"varint,3,opt,name=duration,proto3" json:"duration,omitempty"`                    // block time, 0: permanent (s)
	// contains filtered or unexported fields
}

func (*AddBlockedRequest) Descriptor deprecated

func (*AddBlockedRequest) Descriptor() ([]byte, []int)

Deprecated: Use AddBlockedRequest.ProtoReflect.Descriptor instead.

func (*AddBlockedRequest) GetDuration

func (x *AddBlockedRequest) GetDuration() int64

func (*AddBlockedRequest) GetIsBlocked

func (x *AddBlockedRequest) GetIsBlocked() bool

func (*AddBlockedRequest) GetProfileId

func (x *AddBlockedRequest) GetProfileId() string

func (*AddBlockedRequest) ProtoMessage

func (*AddBlockedRequest) ProtoMessage()

func (*AddBlockedRequest) ProtoReflect

func (x *AddBlockedRequest) ProtoReflect() protoreflect.Message

func (*AddBlockedRequest) Reset

func (x *AddBlockedRequest) Reset()

func (*AddBlockedRequest) String

func (x *AddBlockedRequest) String() string

type AddBlockedResponse

type AddBlockedResponse struct {
	// contains filtered or unexported fields
}

func (*AddBlockedResponse) Descriptor deprecated

func (*AddBlockedResponse) Descriptor() ([]byte, []int)

Deprecated: Use AddBlockedResponse.ProtoReflect.Descriptor instead.

func (*AddBlockedResponse) ProtoMessage

func (*AddBlockedResponse) ProtoMessage()

func (*AddBlockedResponse) ProtoReflect

func (x *AddBlockedResponse) ProtoReflect() protoreflect.Message

func (*AddBlockedResponse) Reset

func (x *AddBlockedResponse) Reset()

func (*AddBlockedResponse) String

func (x *AddBlockedResponse) String() string

type ChatError

type ChatError struct {
	Code ChatError_Code `protobuf:"varint,1,opt,name=code,proto3,enum=chat.pb.ChatError_Code" json:"code,omitempty"`
	// contains filtered or unexported fields
}

func (*ChatError) Descriptor deprecated

func (*ChatError) Descriptor() ([]byte, []int)

Deprecated: Use ChatError.ProtoReflect.Descriptor instead.

func (*ChatError) GetCode

func (x *ChatError) GetCode() ChatError_Code

func (*ChatError) ProtoMessage

func (*ChatError) ProtoMessage()

func (*ChatError) ProtoReflect

func (x *ChatError) ProtoReflect() protoreflect.Message

func (*ChatError) Reset

func (x *ChatError) Reset()

func (*ChatError) String

func (x *ChatError) String() string

type ChatError_Code

type ChatError_Code int32
const (
	ChatError_CODE_NONE     ChatError_Code = 0
	ChatError_CODE_INTERVAL ChatError_Code = 1
	ChatError_CODE_BLOCKED  ChatError_Code = 2
)

func (ChatError_Code) Descriptor

func (ChatError_Code) Enum

func (x ChatError_Code) Enum() *ChatError_Code

func (ChatError_Code) EnumDescriptor deprecated

func (ChatError_Code) EnumDescriptor() ([]byte, []int)

Deprecated: Use ChatError_Code.Descriptor instead.

func (ChatError_Code) Number

func (ChatError_Code) String

func (x ChatError_Code) String() string

func (ChatError_Code) Type

type ChatMessage

type ChatMessage struct {

	// send where
	Destination *Destination `protobuf:"bytes,1,opt,name=destination,proto3" json:"destination,omitempty"`
	// chat all content
	Message *ChatMessage_Message `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"`
	// contains filtered or unexported fields
}

func (*ChatMessage) Descriptor deprecated

func (*ChatMessage) Descriptor() ([]byte, []int)

Deprecated: Use ChatMessage.ProtoReflect.Descriptor instead.

func (*ChatMessage) GetDestination

func (x *ChatMessage) GetDestination() *Destination

func (*ChatMessage) GetMessage

func (x *ChatMessage) GetMessage() *ChatMessage_Message

func (*ChatMessage) ProtoMessage

func (*ChatMessage) ProtoMessage()

func (*ChatMessage) ProtoReflect

func (x *ChatMessage) ProtoReflect() protoreflect.Message

func (*ChatMessage) Reset

func (x *ChatMessage) Reset()

func (*ChatMessage) String

func (x *ChatMessage) String() string

type ChatMessage_Message

type ChatMessage_Message struct {

	// user id
	ProfileId string `protobuf:"bytes,1,opt,name=profile_id,json=profileId,proto3" json:"profile_id,omitempty"`
	// who started the chat
	Nickname string `protobuf:"bytes,2,opt,name=nickname,proto3" json:"nickname,omitempty"`
	// user avatar
	Avatar string `protobuf:"bytes,3,opt,name=avatar,proto3" json:"avatar,omitempty"`
	// user avatar frame
	AvatarFrame int32 `protobuf:"varint,4,opt,name=avatar_frame,json=avatarFrame,proto3" json:"avatar_frame,omitempty"`
	// user gender
	Gender int32 `protobuf:"varint,5,opt,name=gender,proto3" json:"gender,omitempty"`
	// content
	Content string `protobuf:"bytes,6,opt,name=content,proto3" json:"content,omitempty"`
	// emoji
	Emoji int32 `protobuf:"varint,7,opt,name=emoji,proto3" json:"emoji,omitempty"`
	// send time
	Timestamp int64 `protobuf:"varint,8,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
	// contains filtered or unexported fields
}

message we send or receive chat information, It carries the necessary information

func (*ChatMessage_Message) Descriptor deprecated

func (*ChatMessage_Message) Descriptor() ([]byte, []int)

Deprecated: Use ChatMessage_Message.ProtoReflect.Descriptor instead.

func (*ChatMessage_Message) GetAvatar

func (x *ChatMessage_Message) GetAvatar() string

func (*ChatMessage_Message) GetAvatarFrame

func (x *ChatMessage_Message) GetAvatarFrame() int32

func (*ChatMessage_Message) GetContent

func (x *ChatMessage_Message) GetContent() string

func (*ChatMessage_Message) GetEmoji

func (x *ChatMessage_Message) GetEmoji() int32

func (*ChatMessage_Message) GetGender

func (x *ChatMessage_Message) GetGender() int32

func (*ChatMessage_Message) GetNickname

func (x *ChatMessage_Message) GetNickname() string

func (*ChatMessage_Message) GetProfileId

func (x *ChatMessage_Message) GetProfileId() string

func (*ChatMessage_Message) GetTimestamp

func (x *ChatMessage_Message) GetTimestamp() int64

func (*ChatMessage_Message) ProtoMessage

func (*ChatMessage_Message) ProtoMessage()

func (*ChatMessage_Message) ProtoReflect

func (x *ChatMessage_Message) ProtoReflect() protoreflect.Message

func (*ChatMessage_Message) Reset

func (x *ChatMessage_Message) Reset()

func (*ChatMessage_Message) String

func (x *ChatMessage_Message) String() string

type ChatPrivateServiceClient

type ChatPrivateServiceClient interface {
	// add blocked list
	AddBlocked(ctx context.Context, in *AddBlockedRequest, opts ...grpc.CallOption) (*AddBlockedResponse, error)
}

ChatPrivateServiceClient is the client API for ChatPrivateService 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 ChatPrivateServiceServer

type ChatPrivateServiceServer interface {
	// add blocked list
	AddBlocked(context.Context, *AddBlockedRequest) (*AddBlockedResponse, error)
}

ChatPrivateServiceServer is the server API for ChatPrivateService service. All implementations should embed UnimplementedChatPrivateServiceServer for forward compatibility

type ChatRequest

type ChatRequest struct {

	// Types that are assignable to Kind:
	//
	//	*ChatRequest_Subscribe_
	//	*ChatRequest_Unsubscribe
	//	*ChatRequest_Message
	Kind isChatRequest_Kind `protobuf_oneof:"kind"`
	// contains filtered or unexported fields
}

func (*ChatRequest) Descriptor deprecated

func (*ChatRequest) Descriptor() ([]byte, []int)

Deprecated: Use ChatRequest.ProtoReflect.Descriptor instead.

func (*ChatRequest) GetKind

func (m *ChatRequest) GetKind() isChatRequest_Kind

func (*ChatRequest) GetMessage

func (x *ChatRequest) GetMessage() *ChatMessage

func (*ChatRequest) GetSubscribe

func (x *ChatRequest) GetSubscribe() *ChatRequest_Subscribe

func (*ChatRequest) GetUnsubscribe

func (x *ChatRequest) GetUnsubscribe() *ChatRequest_UnSubscribe

func (*ChatRequest) ProtoMessage

func (*ChatRequest) ProtoMessage()

func (*ChatRequest) ProtoReflect

func (x *ChatRequest) ProtoReflect() protoreflect.Message

func (*ChatRequest) Reset

func (x *ChatRequest) Reset()

func (*ChatRequest) String

func (x *ChatRequest) String() string

type ChatRequest_Message

type ChatRequest_Message struct {
	Message *ChatMessage `protobuf:"bytes,2,opt,name=message,proto3,oneof"`
}

type ChatRequest_Subscribe

type ChatRequest_Subscribe struct {

	// who started the chat
	ProfileId string `protobuf:"bytes,1,opt,name=profile_id,json=profileId,proto3" json:"profile_id,omitempty"`
	// send where
	Destination *Destination `protobuf:"bytes,2,opt,name=destination,proto3" json:"destination,omitempty"`
	// contains filtered or unexported fields
}

func (*ChatRequest_Subscribe) Descriptor deprecated

func (*ChatRequest_Subscribe) Descriptor() ([]byte, []int)

Deprecated: Use ChatRequest_Subscribe.ProtoReflect.Descriptor instead.

func (*ChatRequest_Subscribe) GetDestination

func (x *ChatRequest_Subscribe) GetDestination() *Destination

func (*ChatRequest_Subscribe) GetProfileId

func (x *ChatRequest_Subscribe) GetProfileId() string

func (*ChatRequest_Subscribe) ProtoMessage

func (*ChatRequest_Subscribe) ProtoMessage()

func (*ChatRequest_Subscribe) ProtoReflect

func (x *ChatRequest_Subscribe) ProtoReflect() protoreflect.Message

func (*ChatRequest_Subscribe) Reset

func (x *ChatRequest_Subscribe) Reset()

func (*ChatRequest_Subscribe) String

func (x *ChatRequest_Subscribe) String() string

type ChatRequest_Subscribe_

type ChatRequest_Subscribe_ struct {
	Subscribe *ChatRequest_Subscribe `protobuf:"bytes,1,opt,name=subscribe,proto3,oneof"`
}

type ChatRequest_UnSubscribe

type ChatRequest_UnSubscribe struct {

	// who started the chat
	ProfileId string `protobuf:"bytes,1,opt,name=profile_id,json=profileId,proto3" json:"profile_id,omitempty"`
	// send where
	Destination *Destination `protobuf:"bytes,2,opt,name=destination,proto3" json:"destination,omitempty"`
	// contains filtered or unexported fields
}

func (*ChatRequest_UnSubscribe) Descriptor deprecated

func (*ChatRequest_UnSubscribe) Descriptor() ([]byte, []int)

Deprecated: Use ChatRequest_UnSubscribe.ProtoReflect.Descriptor instead.

func (*ChatRequest_UnSubscribe) GetDestination

func (x *ChatRequest_UnSubscribe) GetDestination() *Destination

func (*ChatRequest_UnSubscribe) GetProfileId

func (x *ChatRequest_UnSubscribe) GetProfileId() string

func (*ChatRequest_UnSubscribe) ProtoMessage

func (*ChatRequest_UnSubscribe) ProtoMessage()

func (*ChatRequest_UnSubscribe) ProtoReflect

func (x *ChatRequest_UnSubscribe) ProtoReflect() protoreflect.Message

func (*ChatRequest_UnSubscribe) Reset

func (x *ChatRequest_UnSubscribe) Reset()

func (*ChatRequest_UnSubscribe) String

func (x *ChatRequest_UnSubscribe) String() string

type ChatRequest_Unsubscribe

type ChatRequest_Unsubscribe struct {
	Unsubscribe *ChatRequest_UnSubscribe `protobuf:"bytes,3,opt,name=unsubscribe,proto3,oneof"`
}

type ChatResponse

type ChatResponse struct {

	// Types that are assignable to Kind:
	//
	//	*ChatResponse_Message
	//	*ChatResponse_Error
	Kind isChatResponse_Kind `protobuf_oneof:"kind"`
	// contains filtered or unexported fields
}

func (*ChatResponse) Descriptor deprecated

func (*ChatResponse) Descriptor() ([]byte, []int)

Deprecated: Use ChatResponse.ProtoReflect.Descriptor instead.

func (*ChatResponse) GetError

func (x *ChatResponse) GetError() *ChatError

func (*ChatResponse) GetKind

func (m *ChatResponse) GetKind() isChatResponse_Kind

func (*ChatResponse) GetMessage

func (x *ChatResponse) GetMessage() *ChatMessage

func (*ChatResponse) ProtoMessage

func (*ChatResponse) ProtoMessage()

func (*ChatResponse) ProtoReflect

func (x *ChatResponse) ProtoReflect() protoreflect.Message

func (*ChatResponse) Reset

func (x *ChatResponse) Reset()

func (*ChatResponse) String

func (x *ChatResponse) String() string

type ChatResponse_Error

type ChatResponse_Error struct {
	Error *ChatError `protobuf:"bytes,2,opt,name=error,proto3,oneof"`
}

type ChatResponse_Message

type ChatResponse_Message struct {
	Message *ChatMessage `protobuf:"bytes,1,opt,name=message,proto3,oneof"`
}

type ChatServiceClient

type ChatServiceClient interface {
	// Chat create a stream to send and receive chat information.
	Chat(ctx context.Context, opts ...grpc.CallOption) (ChatService_ChatClient, error)
}

ChatServiceClient is the client API for ChatService 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.

ChatService provides chat service.

type ChatServiceServer

type ChatServiceServer interface {
	// Chat create a stream to send and receive chat information.
	Chat(ChatService_ChatServer) error
}

ChatServiceServer is the server API for ChatService service. All implementations should embed UnimplementedChatServiceServer for forward compatibility

ChatService provides chat service.

type ChatService_ChatClient

type ChatService_ChatClient interface {
	Send(*ChatRequest) error
	Recv() (*ChatResponse, error)
	grpc.ClientStream
}

type ChatService_ChatServer

type ChatService_ChatServer interface {
	Send(*ChatResponse) error
	Recv() (*ChatRequest, error)
	grpc.ServerStream
}

type Destination

type Destination struct {
	Channel int32  `protobuf:"varint,1,opt,name=channel,proto3" json:"channel,omitempty"`
	Id      string `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"`
	// contains filtered or unexported fields
}

func (*Destination) Descriptor deprecated

func (*Destination) Descriptor() ([]byte, []int)

Deprecated: Use Destination.ProtoReflect.Descriptor instead.

func (*Destination) GetChannel

func (x *Destination) GetChannel() int32

func (*Destination) GetId

func (x *Destination) GetId() string

func (*Destination) ProtoMessage

func (*Destination) ProtoMessage()

func (*Destination) ProtoReflect

func (x *Destination) ProtoReflect() protoreflect.Message

func (*Destination) Reset

func (x *Destination) Reset()

func (*Destination) String

func (x *Destination) String() string

type UnimplementedChatPrivateServiceServer

type UnimplementedChatPrivateServiceServer struct {
}

UnimplementedChatPrivateServiceServer should be embedded to have forward compatible implementations.

func (UnimplementedChatPrivateServiceServer) AddBlocked

type UnimplementedChatServiceServer

type UnimplementedChatServiceServer struct {
}

UnimplementedChatServiceServer should be embedded to have forward compatible implementations.

func (UnimplementedChatServiceServer) Chat

type UnsafeChatPrivateServiceServer

type UnsafeChatPrivateServiceServer interface {
	// contains filtered or unexported methods
}

UnsafeChatPrivateServiceServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to ChatPrivateServiceServer will result in compilation errors.

type UnsafeChatServiceServer

type UnsafeChatServiceServer interface {
	// contains filtered or unexported methods
}

UnsafeChatServiceServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to ChatServiceServer will result in compilation errors.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL