diff --git a/client/go.mod b/client/go.mod new file mode 100644 index 0000000..5c3053e --- /dev/null +++ b/client/go.mod @@ -0,0 +1,15 @@ +module bb-hackathon/tcp-chat.git + +go 1.22.3 + +require google.golang.org/protobuf v1.34.1 + +require ( + github.com/google/go-cmp v0.6.0 // indirect + golang.org/x/net v0.22.0 // indirect + golang.org/x/sys v0.18.0 // indirect + golang.org/x/text v0.14.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 // indirect + google.golang.org/grpc v1.64.0 // indirect + google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.2.0 // indirect +) diff --git a/client/go.sum b/client/go.sum new file mode 100644 index 0000000..26d10e0 --- /dev/null +++ b/client/go.sum @@ -0,0 +1,23 @@ +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc= +golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 h1:NnYq6UN9ReLM9/Y01KWNOWyI5xQ9kbIms5GGJVwS/Yc= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY= +google.golang.org/grpc v1.64.0 h1:KH3VH9y/MgNQg1dE7b3XfVK0GsPSIzJwdF617gUSbvY= +google.golang.org/grpc v1.64.0/go.mod h1:oxjF8E3FBnjp+/gVFYdWacaLDx9na1aqy9oovLpxQYg= +google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.2.0 h1:TLkBREm4nIsEcexnCjgQd5GQWaHcqMzwQV0TX9pq8S0= +google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.2.0/go.mod h1:DNq5QpG7LJqD2AamLZ7zvKE0DEpVl2BSEVjFycAAjRY= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= +google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg= +google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= diff --git a/client/proto/entities.pb.go b/client/proto/entities.pb.go new file mode 100644 index 0000000..1eec8eb --- /dev/null +++ b/client/proto/entities.pb.go @@ -0,0 +1,808 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.25.0-devel +// protoc v3.14.0 +// source: entities.proto + +package proto + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + timestamppb "google.golang.org/protobuf/types/known/timestamppb" + reflect "reflect" + sync "sync" +) + +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) +) + +// A unique identifier of any entity. +// +// UUIDs should only be created or looked up by the server and sent +// back in a response to a creation/lookup request made by a client. +type UUID struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Uuid string `protobuf:"bytes,1,opt,name=uuid,proto3" json:"uuid,omitempty"` +} + +func (x *UUID) Reset() { + *x = UUID{} + if protoimpl.UnsafeEnabled { + mi := &file_entities_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UUID) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UUID) ProtoMessage() {} + +func (x *UUID) ProtoReflect() protoreflect.Message { + mi := &file_entities_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) +} + +// Deprecated: Use UUID.ProtoReflect.Descriptor instead. +func (*UUID) Descriptor() ([]byte, []int) { + return file_entities_proto_rawDescGZIP(), []int{0} +} + +func (x *UUID) GetUuid() string { + if x != nil { + return x.Uuid + } + return "" +} + +// An authentication token. WARN: Sensitive! +// +// Is used in par with a UUID (see above and below). The only way to acquire +// the token is to get it back in a response from the LoginAsUser() RPC call. +type AuthToken struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` +} + +func (x *AuthToken) Reset() { + *x = AuthToken{} + if protoimpl.UnsafeEnabled { + mi := &file_entities_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AuthToken) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AuthToken) ProtoMessage() {} + +func (x *AuthToken) ProtoReflect() protoreflect.Message { + mi := &file_entities_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) +} + +// Deprecated: Use AuthToken.ProtoReflect.Descriptor instead. +func (*AuthToken) Descriptor() ([]byte, []int) { + return file_entities_proto_rawDescGZIP(), []int{1} +} + +func (x *AuthToken) GetToken() string { + if x != nil { + return x.Token + } + return "" +} + +// A UUID+token pair that's used for user authentication after logging in. +// +// UUIDs are *not* sensitive information (the client throws those around all the +// time while fetching room members, receiving messages, etc.), but the only way +// to acquire a token is to log in as a user (and get it back in the response). +// +// The same pair (but not in form of a message) should be added to any requests +// to the server as metadata attributes, those will be inspected by the server's +// request interceptor and either allowed in or early-dropped. +type AuthPair struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + UserUuid *UUID `protobuf:"bytes,1,opt,name=user_uuid,json=userUuid,proto3" json:"user_uuid,omitempty"` + Token *AuthToken `protobuf:"bytes,2,opt,name=token,proto3" json:"token,omitempty"` +} + +func (x *AuthPair) Reset() { + *x = AuthPair{} + if protoimpl.UnsafeEnabled { + mi := &file_entities_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AuthPair) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AuthPair) ProtoMessage() {} + +func (x *AuthPair) ProtoReflect() protoreflect.Message { + mi := &file_entities_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) +} + +// Deprecated: Use AuthPair.ProtoReflect.Descriptor instead. +func (*AuthPair) Descriptor() ([]byte, []int) { + return file_entities_proto_rawDescGZIP(), []int{2} +} + +func (x *AuthPair) GetUserUuid() *UUID { + if x != nil { + return x.UserUuid + } + return nil +} + +func (x *AuthPair) GetToken() *AuthToken { + if x != nil { + return x.Token + } + return nil +} + +// A username+password pair that's used to authenticate with the server. +// +// TODO: Send the password hashed, not in plaintext. +type UserCredentials struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"` + Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` +} + +func (x *UserCredentials) Reset() { + *x = UserCredentials{} + if protoimpl.UnsafeEnabled { + mi := &file_entities_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UserCredentials) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UserCredentials) ProtoMessage() {} + +func (x *UserCredentials) ProtoReflect() protoreflect.Message { + mi := &file_entities_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) +} + +// Deprecated: Use UserCredentials.ProtoReflect.Descriptor instead. +func (*UserCredentials) Descriptor() ([]byte, []int) { + return file_entities_proto_rawDescGZIP(), []int{3} +} + +func (x *UserCredentials) GetUsername() string { + if x != nil { + return x.Username + } + return "" +} + +func (x *UserCredentials) GetPassword() string { + if x != nil { + return x.Password + } + return "" +} + +// A user account entity that the client may request from the server. +// +// For example, when the client needs to list the members of the room or display +// the profile of the user you're about to send a message to, it looks up a user +// in the server's database by using the Chat::LookupUser() RPC. +type User struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Uuid *UUID `protobuf:"bytes,1,opt,name=uuid,proto3" json:"uuid,omitempty"` + Username string `protobuf:"bytes,2,opt,name=username,proto3" json:"username,omitempty"` +} + +func (x *User) Reset() { + *x = User{} + if protoimpl.UnsafeEnabled { + mi := &file_entities_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *User) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*User) ProtoMessage() {} + +func (x *User) ProtoReflect() protoreflect.Message { + mi := &file_entities_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 mi.MessageOf(x) +} + +// Deprecated: Use User.ProtoReflect.Descriptor instead. +func (*User) Descriptor() ([]byte, []int) { + return file_entities_proto_rawDescGZIP(), []int{4} +} + +func (x *User) GetUuid() *UUID { + if x != nil { + return x.Uuid + } + return nil +} + +func (x *User) GetUsername() string { + if x != nil { + return x.Username + } + return "" +} + +// The entity that the client sends to the server whenever the user sends a new +// message. The UUID of the user is embedded in the requests metadata, so all we +// need to know are the contents of the message and the UUID of the room that +// this message belongs to. +// +// The server's job is to generate a UUID of the message and store it, along +// with a timestamp and the UUID of the sender (see below). +type ClientsideMessage struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + RoomUuid *UUID `protobuf:"bytes,1,opt,name=room_uuid,json=roomUuid,proto3" json:"room_uuid,omitempty"` + Text string `protobuf:"bytes,2,opt,name=text,proto3" json:"text,omitempty"` +} + +func (x *ClientsideMessage) Reset() { + *x = ClientsideMessage{} + if protoimpl.UnsafeEnabled { + mi := &file_entities_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ClientsideMessage) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ClientsideMessage) ProtoMessage() {} + +func (x *ClientsideMessage) ProtoReflect() protoreflect.Message { + mi := &file_entities_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) +} + +// Deprecated: Use ClientsideMessage.ProtoReflect.Descriptor instead. +func (*ClientsideMessage) Descriptor() ([]byte, []int) { + return file_entities_proto_rawDescGZIP(), []int{5} +} + +func (x *ClientsideMessage) GetRoomUuid() *UUID { + if x != nil { + return x.RoomUuid + } + return nil +} + +func (x *ClientsideMessage) GetText() string { + if x != nil { + return x.Text + } + return "" +} + +type ServersideMessage struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Uuid *UUID `protobuf:"bytes,1,opt,name=uuid,proto3" json:"uuid,omitempty"` + SenderUuid *UUID `protobuf:"bytes,2,opt,name=sender_uuid,json=senderUuid,proto3" json:"sender_uuid,omitempty"` + RoomUuid *UUID `protobuf:"bytes,3,opt,name=room_uuid,json=roomUuid,proto3" json:"room_uuid,omitempty"` + Text string `protobuf:"bytes,4,opt,name=text,proto3" json:"text,omitempty"` + Timestamp *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=timestamp,proto3" json:"timestamp,omitempty"` +} + +func (x *ServersideMessage) Reset() { + *x = ServersideMessage{} + if protoimpl.UnsafeEnabled { + mi := &file_entities_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ServersideMessage) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ServersideMessage) ProtoMessage() {} + +func (x *ServersideMessage) ProtoReflect() protoreflect.Message { + mi := &file_entities_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 mi.MessageOf(x) +} + +// Deprecated: Use ServersideMessage.ProtoReflect.Descriptor instead. +func (*ServersideMessage) Descriptor() ([]byte, []int) { + return file_entities_proto_rawDescGZIP(), []int{6} +} + +func (x *ServersideMessage) GetUuid() *UUID { + if x != nil { + return x.Uuid + } + return nil +} + +func (x *ServersideMessage) GetSenderUuid() *UUID { + if x != nil { + return x.SenderUuid + } + return nil +} + +func (x *ServersideMessage) GetRoomUuid() *UUID { + if x != nil { + return x.RoomUuid + } + return nil +} + +func (x *ServersideMessage) GetText() string { + if x != nil { + return x.Text + } + return "" +} + +func (x *ServersideMessage) GetTimestamp() *timestamppb.Timestamp { + if x != nil { + return x.Timestamp + } + return nil +} + +type ClientsideRoom struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Members []*UUID `protobuf:"bytes,2,rep,name=members,proto3" json:"members,omitempty"` +} + +func (x *ClientsideRoom) Reset() { + *x = ClientsideRoom{} + if protoimpl.UnsafeEnabled { + mi := &file_entities_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ClientsideRoom) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ClientsideRoom) ProtoMessage() {} + +func (x *ClientsideRoom) ProtoReflect() protoreflect.Message { + mi := &file_entities_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 mi.MessageOf(x) +} + +// Deprecated: Use ClientsideRoom.ProtoReflect.Descriptor instead. +func (*ClientsideRoom) Descriptor() ([]byte, []int) { + return file_entities_proto_rawDescGZIP(), []int{7} +} + +func (x *ClientsideRoom) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *ClientsideRoom) GetMembers() []*UUID { + if x != nil { + return x.Members + } + return nil +} + +type ServersideRoom struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Uuid *UUID `protobuf:"bytes,1,opt,name=uuid,proto3" json:"uuid,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + Members []*UUID `protobuf:"bytes,3,rep,name=members,proto3" json:"members,omitempty"` +} + +func (x *ServersideRoom) Reset() { + *x = ServersideRoom{} + if protoimpl.UnsafeEnabled { + mi := &file_entities_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ServersideRoom) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ServersideRoom) ProtoMessage() {} + +func (x *ServersideRoom) ProtoReflect() protoreflect.Message { + mi := &file_entities_proto_msgTypes[8] + 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) +} + +// Deprecated: Use ServersideRoom.ProtoReflect.Descriptor instead. +func (*ServersideRoom) Descriptor() ([]byte, []int) { + return file_entities_proto_rawDescGZIP(), []int{8} +} + +func (x *ServersideRoom) GetUuid() *UUID { + if x != nil { + return x.Uuid + } + return nil +} + +func (x *ServersideRoom) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *ServersideRoom) GetMembers() []*UUID { + if x != nil { + return x.Members + } + return nil +} + +var File_entities_proto protoreflect.FileDescriptor + +var file_entities_proto_rawDesc = []byte{ + 0x0a, 0x0e, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x69, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x12, 0x08, 0x74, 0x63, 0x70, 0x5f, 0x63, 0x68, 0x61, 0x74, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, + 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, + 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x1a, 0x0a, 0x04, 0x55, + 0x55, 0x49, 0x44, 0x12, 0x12, 0x0a, 0x04, 0x75, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x04, 0x75, 0x75, 0x69, 0x64, 0x22, 0x21, 0x0a, 0x09, 0x41, 0x75, 0x74, 0x68, 0x54, + 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x62, 0x0a, 0x08, 0x41, 0x75, + 0x74, 0x68, 0x50, 0x61, 0x69, 0x72, 0x12, 0x2b, 0x0a, 0x09, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x75, + 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x74, 0x63, 0x70, 0x5f, + 0x63, 0x68, 0x61, 0x74, 0x2e, 0x55, 0x55, 0x49, 0x44, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x55, + 0x75, 0x69, 0x64, 0x12, 0x29, 0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x74, 0x63, 0x70, 0x5f, 0x63, 0x68, 0x61, 0x74, 0x2e, 0x41, 0x75, + 0x74, 0x68, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x49, + 0x0a, 0x0f, 0x55, 0x73, 0x65, 0x72, 0x43, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, + 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, + 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x22, 0x46, 0x0a, 0x04, 0x55, 0x73, 0x65, + 0x72, 0x12, 0x22, 0x0a, 0x04, 0x75, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x0e, 0x2e, 0x74, 0x63, 0x70, 0x5f, 0x63, 0x68, 0x61, 0x74, 0x2e, 0x55, 0x55, 0x49, 0x44, 0x52, + 0x04, 0x75, 0x75, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, + 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, + 0x65, 0x22, 0x54, 0x0a, 0x11, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x73, 0x69, 0x64, 0x65, 0x4d, + 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x2b, 0x0a, 0x09, 0x72, 0x6f, 0x6f, 0x6d, 0x5f, 0x75, + 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x74, 0x63, 0x70, 0x5f, + 0x63, 0x68, 0x61, 0x74, 0x2e, 0x55, 0x55, 0x49, 0x44, 0x52, 0x08, 0x72, 0x6f, 0x6f, 0x6d, 0x55, + 0x75, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x04, 0x74, 0x65, 0x78, 0x74, 0x22, 0xe3, 0x01, 0x0a, 0x11, 0x53, 0x65, 0x72, 0x76, + 0x65, 0x72, 0x73, 0x69, 0x64, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x22, 0x0a, + 0x04, 0x75, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x74, 0x63, + 0x70, 0x5f, 0x63, 0x68, 0x61, 0x74, 0x2e, 0x55, 0x55, 0x49, 0x44, 0x52, 0x04, 0x75, 0x75, 0x69, + 0x64, 0x12, 0x2f, 0x0a, 0x0b, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x5f, 0x75, 0x75, 0x69, 0x64, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x74, 0x63, 0x70, 0x5f, 0x63, 0x68, 0x61, + 0x74, 0x2e, 0x55, 0x55, 0x49, 0x44, 0x52, 0x0a, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x55, 0x75, + 0x69, 0x64, 0x12, 0x2b, 0x0a, 0x09, 0x72, 0x6f, 0x6f, 0x6d, 0x5f, 0x75, 0x75, 0x69, 0x64, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x74, 0x63, 0x70, 0x5f, 0x63, 0x68, 0x61, 0x74, + 0x2e, 0x55, 0x55, 0x49, 0x44, 0x52, 0x08, 0x72, 0x6f, 0x6f, 0x6d, 0x55, 0x75, 0x69, 0x64, 0x12, + 0x12, 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, + 0x65, 0x78, 0x74, 0x12, 0x38, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, + 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, + 0x6d, 0x70, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x22, 0x4e, 0x0a, + 0x0e, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x73, 0x69, 0x64, 0x65, 0x52, 0x6f, 0x6f, 0x6d, 0x12, + 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, + 0x61, 0x6d, 0x65, 0x12, 0x28, 0x0a, 0x07, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x18, 0x02, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x74, 0x63, 0x70, 0x5f, 0x63, 0x68, 0x61, 0x74, 0x2e, + 0x55, 0x55, 0x49, 0x44, 0x52, 0x07, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x22, 0x72, 0x0a, + 0x0e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x73, 0x69, 0x64, 0x65, 0x52, 0x6f, 0x6f, 0x6d, 0x12, + 0x22, 0x0a, 0x04, 0x75, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, + 0x74, 0x63, 0x70, 0x5f, 0x63, 0x68, 0x61, 0x74, 0x2e, 0x55, 0x55, 0x49, 0x44, 0x52, 0x04, 0x75, + 0x75, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x28, 0x0a, 0x07, 0x6d, 0x65, 0x6d, 0x62, 0x65, + 0x72, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x74, 0x63, 0x70, 0x5f, 0x63, + 0x68, 0x61, 0x74, 0x2e, 0x55, 0x55, 0x49, 0x44, 0x52, 0x07, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, + 0x73, 0x42, 0x33, 0x5a, 0x31, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x67, 0x6f, 0x6c, 0x61, + 0x6e, 0x67, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x62, 0x62, 0x2d, 0x68, 0x61, 0x63, 0x6b, 0x61, 0x74, + 0x68, 0x6f, 0x6e, 0x2f, 0x74, 0x63, 0x70, 0x2d, 0x63, 0x68, 0x61, 0x74, 0x2e, 0x67, 0x69, 0x74, + 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_entities_proto_rawDescOnce sync.Once + file_entities_proto_rawDescData = file_entities_proto_rawDesc +) + +func file_entities_proto_rawDescGZIP() []byte { + file_entities_proto_rawDescOnce.Do(func() { + file_entities_proto_rawDescData = protoimpl.X.CompressGZIP(file_entities_proto_rawDescData) + }) + return file_entities_proto_rawDescData +} + +var file_entities_proto_msgTypes = make([]protoimpl.MessageInfo, 9) +var file_entities_proto_goTypes = []interface{}{ + (*UUID)(nil), // 0: tcp_chat.UUID + (*AuthToken)(nil), // 1: tcp_chat.AuthToken + (*AuthPair)(nil), // 2: tcp_chat.AuthPair + (*UserCredentials)(nil), // 3: tcp_chat.UserCredentials + (*User)(nil), // 4: tcp_chat.User + (*ClientsideMessage)(nil), // 5: tcp_chat.ClientsideMessage + (*ServersideMessage)(nil), // 6: tcp_chat.ServersideMessage + (*ClientsideRoom)(nil), // 7: tcp_chat.ClientsideRoom + (*ServersideRoom)(nil), // 8: tcp_chat.ServersideRoom + (*timestamppb.Timestamp)(nil), // 9: google.protobuf.Timestamp +} +var file_entities_proto_depIdxs = []int32{ + 0, // 0: tcp_chat.AuthPair.user_uuid:type_name -> tcp_chat.UUID + 1, // 1: tcp_chat.AuthPair.token:type_name -> tcp_chat.AuthToken + 0, // 2: tcp_chat.User.uuid:type_name -> tcp_chat.UUID + 0, // 3: tcp_chat.ClientsideMessage.room_uuid:type_name -> tcp_chat.UUID + 0, // 4: tcp_chat.ServersideMessage.uuid:type_name -> tcp_chat.UUID + 0, // 5: tcp_chat.ServersideMessage.sender_uuid:type_name -> tcp_chat.UUID + 0, // 6: tcp_chat.ServersideMessage.room_uuid:type_name -> tcp_chat.UUID + 9, // 7: tcp_chat.ServersideMessage.timestamp:type_name -> google.protobuf.Timestamp + 0, // 8: tcp_chat.ClientsideRoom.members:type_name -> tcp_chat.UUID + 0, // 9: tcp_chat.ServersideRoom.uuid:type_name -> tcp_chat.UUID + 0, // 10: tcp_chat.ServersideRoom.members:type_name -> tcp_chat.UUID + 11, // [11:11] is the sub-list for method output_type + 11, // [11:11] is the sub-list for method input_type + 11, // [11:11] is the sub-list for extension type_name + 11, // [11:11] is the sub-list for extension extendee + 0, // [0:11] is the sub-list for field type_name +} + +func init() { file_entities_proto_init() } +func file_entities_proto_init() { + if File_entities_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_entities_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UUID); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_entities_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AuthToken); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_entities_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AuthPair); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_entities_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UserCredentials); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_entities_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*User); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_entities_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ClientsideMessage); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_entities_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ServersideMessage); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_entities_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ClientsideRoom); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_entities_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ServersideRoom); 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_entities_proto_rawDesc, + NumEnums: 0, + NumMessages: 9, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_entities_proto_goTypes, + DependencyIndexes: file_entities_proto_depIdxs, + MessageInfos: file_entities_proto_msgTypes, + }.Build() + File_entities_proto = out.File + file_entities_proto_rawDesc = nil + file_entities_proto_goTypes = nil + file_entities_proto_depIdxs = nil +} diff --git a/client/proto/events.pb.go b/client/proto/events.pb.go new file mode 100644 index 0000000..1fc68ca --- /dev/null +++ b/client/proto/events.pb.go @@ -0,0 +1,288 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.25.0-devel +// protoc v3.14.0 +// source: events.proto + +package proto + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +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) +) + +type ServersideRoomEvent struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + RoomUuid *UUID `protobuf:"bytes,1,opt,name=room_uuid,json=roomUuid,proto3" json:"room_uuid,omitempty"` + // Types that are assignable to Event: + // *ServersideRoomEvent_NewMessage + Event isServersideRoomEvent_Event `protobuf_oneof:"event"` +} + +func (x *ServersideRoomEvent) Reset() { + *x = ServersideRoomEvent{} + if protoimpl.UnsafeEnabled { + mi := &file_events_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ServersideRoomEvent) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ServersideRoomEvent) ProtoMessage() {} + +func (x *ServersideRoomEvent) ProtoReflect() protoreflect.Message { + mi := &file_events_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) +} + +// Deprecated: Use ServersideRoomEvent.ProtoReflect.Descriptor instead. +func (*ServersideRoomEvent) Descriptor() ([]byte, []int) { + return file_events_proto_rawDescGZIP(), []int{0} +} + +func (x *ServersideRoomEvent) GetRoomUuid() *UUID { + if x != nil { + return x.RoomUuid + } + return nil +} + +func (m *ServersideRoomEvent) GetEvent() isServersideRoomEvent_Event { + if m != nil { + return m.Event + } + return nil +} + +func (x *ServersideRoomEvent) GetNewMessage() *ServersideMessage { + if x, ok := x.GetEvent().(*ServersideRoomEvent_NewMessage); ok { + return x.NewMessage + } + return nil +} + +type isServersideRoomEvent_Event interface { + isServersideRoomEvent_Event() +} + +type ServersideRoomEvent_NewMessage struct { + // Someone sent a new message in this chat room. + NewMessage *ServersideMessage `protobuf:"bytes,2,opt,name=new_message,json=newMessage,proto3,oneof"` +} + +func (*ServersideRoomEvent_NewMessage) isServersideRoomEvent_Event() {} + +type ServersideUserEvent struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + UserUuid *UUID `protobuf:"bytes,1,opt,name=user_uuid,json=userUuid,proto3" json:"user_uuid,omitempty"` + // Types that are assignable to Event: + // *ServersideUserEvent_AddedToRoom + Event isServersideUserEvent_Event `protobuf_oneof:"event"` +} + +func (x *ServersideUserEvent) Reset() { + *x = ServersideUserEvent{} + if protoimpl.UnsafeEnabled { + mi := &file_events_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ServersideUserEvent) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ServersideUserEvent) ProtoMessage() {} + +func (x *ServersideUserEvent) ProtoReflect() protoreflect.Message { + mi := &file_events_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) +} + +// Deprecated: Use ServersideUserEvent.ProtoReflect.Descriptor instead. +func (*ServersideUserEvent) Descriptor() ([]byte, []int) { + return file_events_proto_rawDescGZIP(), []int{1} +} + +func (x *ServersideUserEvent) GetUserUuid() *UUID { + if x != nil { + return x.UserUuid + } + return nil +} + +func (m *ServersideUserEvent) GetEvent() isServersideUserEvent_Event { + if m != nil { + return m.Event + } + return nil +} + +func (x *ServersideUserEvent) GetAddedToRoom() *UUID { + if x, ok := x.GetEvent().(*ServersideUserEvent_AddedToRoom); ok { + return x.AddedToRoom + } + return nil +} + +type isServersideUserEvent_Event interface { + isServersideUserEvent_Event() +} + +type ServersideUserEvent_AddedToRoom struct { + AddedToRoom *UUID `protobuf:"bytes,2,opt,name=added_to_room,json=addedToRoom,proto3,oneof"` // UUID kicked_from_room = 3; +} + +func (*ServersideUserEvent_AddedToRoom) isServersideUserEvent_Event() {} + +var File_events_proto protoreflect.FileDescriptor + +var file_events_proto_rawDesc = []byte{ + 0x0a, 0x0c, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x08, + 0x74, 0x63, 0x70, 0x5f, 0x63, 0x68, 0x61, 0x74, 0x1a, 0x0e, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x69, + 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x8b, 0x01, 0x0a, 0x13, 0x53, 0x65, 0x72, + 0x76, 0x65, 0x72, 0x73, 0x69, 0x64, 0x65, 0x52, 0x6f, 0x6f, 0x6d, 0x45, 0x76, 0x65, 0x6e, 0x74, + 0x12, 0x2b, 0x0a, 0x09, 0x72, 0x6f, 0x6f, 0x6d, 0x5f, 0x75, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x74, 0x63, 0x70, 0x5f, 0x63, 0x68, 0x61, 0x74, 0x2e, 0x55, + 0x55, 0x49, 0x44, 0x52, 0x08, 0x72, 0x6f, 0x6f, 0x6d, 0x55, 0x75, 0x69, 0x64, 0x12, 0x3e, 0x0a, + 0x0b, 0x6e, 0x65, 0x77, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x74, 0x63, 0x70, 0x5f, 0x63, 0x68, 0x61, 0x74, 0x2e, 0x53, 0x65, + 0x72, 0x76, 0x65, 0x72, 0x73, 0x69, 0x64, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x48, + 0x00, 0x52, 0x0a, 0x6e, 0x65, 0x77, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x42, 0x07, 0x0a, + 0x05, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x22, 0x81, 0x01, 0x0a, 0x13, 0x53, 0x65, 0x72, 0x76, 0x65, + 0x72, 0x73, 0x69, 0x64, 0x65, 0x55, 0x73, 0x65, 0x72, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x2b, + 0x0a, 0x09, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x75, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x0e, 0x2e, 0x74, 0x63, 0x70, 0x5f, 0x63, 0x68, 0x61, 0x74, 0x2e, 0x55, 0x55, 0x49, + 0x44, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x55, 0x75, 0x69, 0x64, 0x12, 0x34, 0x0a, 0x0d, 0x61, + 0x64, 0x64, 0x65, 0x64, 0x5f, 0x74, 0x6f, 0x5f, 0x72, 0x6f, 0x6f, 0x6d, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x74, 0x63, 0x70, 0x5f, 0x63, 0x68, 0x61, 0x74, 0x2e, 0x55, 0x55, + 0x49, 0x44, 0x48, 0x00, 0x52, 0x0b, 0x61, 0x64, 0x64, 0x65, 0x64, 0x54, 0x6f, 0x52, 0x6f, 0x6f, + 0x6d, 0x42, 0x07, 0x0a, 0x05, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x42, 0x33, 0x5a, 0x31, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x67, 0x6f, 0x6c, 0x61, 0x6e, 0x67, 0x2e, 0x6f, 0x72, 0x67, 0x2f, + 0x62, 0x62, 0x2d, 0x68, 0x61, 0x63, 0x6b, 0x61, 0x74, 0x68, 0x6f, 0x6e, 0x2f, 0x74, 0x63, 0x70, + 0x2d, 0x63, 0x68, 0x61, 0x74, 0x2e, 0x67, 0x69, 0x74, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, + 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_events_proto_rawDescOnce sync.Once + file_events_proto_rawDescData = file_events_proto_rawDesc +) + +func file_events_proto_rawDescGZIP() []byte { + file_events_proto_rawDescOnce.Do(func() { + file_events_proto_rawDescData = protoimpl.X.CompressGZIP(file_events_proto_rawDescData) + }) + return file_events_proto_rawDescData +} + +var file_events_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_events_proto_goTypes = []interface{}{ + (*ServersideRoomEvent)(nil), // 0: tcp_chat.ServersideRoomEvent + (*ServersideUserEvent)(nil), // 1: tcp_chat.ServersideUserEvent + (*UUID)(nil), // 2: tcp_chat.UUID + (*ServersideMessage)(nil), // 3: tcp_chat.ServersideMessage +} +var file_events_proto_depIdxs = []int32{ + 2, // 0: tcp_chat.ServersideRoomEvent.room_uuid:type_name -> tcp_chat.UUID + 3, // 1: tcp_chat.ServersideRoomEvent.new_message:type_name -> tcp_chat.ServersideMessage + 2, // 2: tcp_chat.ServersideUserEvent.user_uuid:type_name -> tcp_chat.UUID + 2, // 3: tcp_chat.ServersideUserEvent.added_to_room:type_name -> tcp_chat.UUID + 4, // [4:4] is the sub-list for method output_type + 4, // [4:4] is the sub-list for method input_type + 4, // [4:4] is the sub-list for extension type_name + 4, // [4:4] is the sub-list for extension extendee + 0, // [0:4] is the sub-list for field type_name +} + +func init() { file_events_proto_init() } +func file_events_proto_init() { + if File_events_proto != nil { + return + } + file_entities_proto_init() + if !protoimpl.UnsafeEnabled { + file_events_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ServersideRoomEvent); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_events_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ServersideUserEvent); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + file_events_proto_msgTypes[0].OneofWrappers = []interface{}{ + (*ServersideRoomEvent_NewMessage)(nil), + } + file_events_proto_msgTypes[1].OneofWrappers = []interface{}{ + (*ServersideUserEvent_AddedToRoom)(nil), + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_events_proto_rawDesc, + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_events_proto_goTypes, + DependencyIndexes: file_events_proto_depIdxs, + MessageInfos: file_events_proto_msgTypes, + }.Build() + File_events_proto = out.File + file_events_proto_rawDesc = nil + file_events_proto_goTypes = nil + file_events_proto_depIdxs = nil +} diff --git a/client/proto/requests.pb.go b/client/proto/requests.pb.go new file mode 100644 index 0000000..29d8e03 --- /dev/null +++ b/client/proto/requests.pb.go @@ -0,0 +1,462 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.25.0-devel +// protoc v3.14.0 +// source: requests.proto + +package proto + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +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) +) + +type UserLookupRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Types that are assignable to Identifier: + // *UserLookupRequest_Uuid + // *UserLookupRequest_Username + Identifier isUserLookupRequest_Identifier `protobuf_oneof:"identifier"` +} + +func (x *UserLookupRequest) Reset() { + *x = UserLookupRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_requests_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UserLookupRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UserLookupRequest) ProtoMessage() {} + +func (x *UserLookupRequest) ProtoReflect() protoreflect.Message { + mi := &file_requests_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) +} + +// Deprecated: Use UserLookupRequest.ProtoReflect.Descriptor instead. +func (*UserLookupRequest) Descriptor() ([]byte, []int) { + return file_requests_proto_rawDescGZIP(), []int{0} +} + +func (m *UserLookupRequest) GetIdentifier() isUserLookupRequest_Identifier { + if m != nil { + return m.Identifier + } + return nil +} + +func (x *UserLookupRequest) GetUuid() *UUID { + if x, ok := x.GetIdentifier().(*UserLookupRequest_Uuid); ok { + return x.Uuid + } + return nil +} + +func (x *UserLookupRequest) GetUsername() string { + if x, ok := x.GetIdentifier().(*UserLookupRequest_Username); ok { + return x.Username + } + return "" +} + +type isUserLookupRequest_Identifier interface { + isUserLookupRequest_Identifier() +} + +type UserLookupRequest_Uuid struct { + Uuid *UUID `protobuf:"bytes,2,opt,name=uuid,proto3,oneof"` +} + +type UserLookupRequest_Username struct { + Username string `protobuf:"bytes,1,opt,name=username,proto3,oneof"` +} + +func (*UserLookupRequest_Uuid) isUserLookupRequest_Identifier() {} + +func (*UserLookupRequest_Username) isUserLookupRequest_Identifier() {} + +type RoomCreationRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + UserUuids []*UUID `protobuf:"bytes,2,rep,name=user_uuids,json=userUuids,proto3" json:"user_uuids,omitempty"` +} + +func (x *RoomCreationRequest) Reset() { + *x = RoomCreationRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_requests_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RoomCreationRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RoomCreationRequest) ProtoMessage() {} + +func (x *RoomCreationRequest) ProtoReflect() protoreflect.Message { + mi := &file_requests_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) +} + +// Deprecated: Use RoomCreationRequest.ProtoReflect.Descriptor instead. +func (*RoomCreationRequest) Descriptor() ([]byte, []int) { + return file_requests_proto_rawDescGZIP(), []int{1} +} + +func (x *RoomCreationRequest) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *RoomCreationRequest) GetUserUuids() []*UUID { + if x != nil { + return x.UserUuids + } + return nil +} + +type RoomWithUserCreationRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + UserUuid *UUID `protobuf:"bytes,1,opt,name=user_uuid,json=userUuid,proto3" json:"user_uuid,omitempty"` +} + +func (x *RoomWithUserCreationRequest) Reset() { + *x = RoomWithUserCreationRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_requests_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RoomWithUserCreationRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RoomWithUserCreationRequest) ProtoMessage() {} + +func (x *RoomWithUserCreationRequest) ProtoReflect() protoreflect.Message { + mi := &file_requests_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) +} + +// Deprecated: Use RoomWithUserCreationRequest.ProtoReflect.Descriptor instead. +func (*RoomWithUserCreationRequest) Descriptor() ([]byte, []int) { + return file_requests_proto_rawDescGZIP(), []int{2} +} + +func (x *RoomWithUserCreationRequest) GetUserUuid() *UUID { + if x != nil { + return x.UserUuid + } + return nil +} + +type RoomList struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Rooms []*ServersideRoom `protobuf:"bytes,1,rep,name=rooms,proto3" json:"rooms,omitempty"` +} + +func (x *RoomList) Reset() { + *x = RoomList{} + if protoimpl.UnsafeEnabled { + mi := &file_requests_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RoomList) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RoomList) ProtoMessage() {} + +func (x *RoomList) ProtoReflect() protoreflect.Message { + mi := &file_requests_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) +} + +// Deprecated: Use RoomList.ProtoReflect.Descriptor instead. +func (*RoomList) Descriptor() ([]byte, []int) { + return file_requests_proto_rawDescGZIP(), []int{3} +} + +func (x *RoomList) GetRooms() []*ServersideRoom { + if x != nil { + return x.Rooms + } + return nil +} + +type MessageList struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Messages []*ServersideMessage `protobuf:"bytes,1,rep,name=messages,proto3" json:"messages,omitempty"` +} + +func (x *MessageList) Reset() { + *x = MessageList{} + if protoimpl.UnsafeEnabled { + mi := &file_requests_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *MessageList) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*MessageList) ProtoMessage() {} + +func (x *MessageList) ProtoReflect() protoreflect.Message { + mi := &file_requests_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 mi.MessageOf(x) +} + +// Deprecated: Use MessageList.ProtoReflect.Descriptor instead. +func (*MessageList) Descriptor() ([]byte, []int) { + return file_requests_proto_rawDescGZIP(), []int{4} +} + +func (x *MessageList) GetMessages() []*ServersideMessage { + if x != nil { + return x.Messages + } + return nil +} + +var File_requests_proto protoreflect.FileDescriptor + +var file_requests_proto_rawDesc = []byte{ + 0x0a, 0x0e, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x12, 0x08, 0x74, 0x63, 0x70, 0x5f, 0x63, 0x68, 0x61, 0x74, 0x1a, 0x0e, 0x65, 0x6e, 0x74, 0x69, + 0x74, 0x69, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x65, 0x0a, 0x11, 0x55, 0x73, + 0x65, 0x72, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, + 0x24, 0x0a, 0x04, 0x75, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, + 0x74, 0x63, 0x70, 0x5f, 0x63, 0x68, 0x61, 0x74, 0x2e, 0x55, 0x55, 0x49, 0x44, 0x48, 0x00, 0x52, + 0x04, 0x75, 0x75, 0x69, 0x64, 0x12, 0x1c, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, + 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, + 0x61, 0x6d, 0x65, 0x42, 0x0c, 0x0a, 0x0a, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, + 0x72, 0x22, 0x58, 0x0a, 0x13, 0x52, 0x6f, 0x6f, 0x6d, 0x43, 0x72, 0x65, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x2d, 0x0a, 0x0a, + 0x75, 0x73, 0x65, 0x72, 0x5f, 0x75, 0x75, 0x69, 0x64, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x0e, 0x2e, 0x74, 0x63, 0x70, 0x5f, 0x63, 0x68, 0x61, 0x74, 0x2e, 0x55, 0x55, 0x49, 0x44, + 0x52, 0x09, 0x75, 0x73, 0x65, 0x72, 0x55, 0x75, 0x69, 0x64, 0x73, 0x22, 0x4a, 0x0a, 0x1b, 0x52, + 0x6f, 0x6f, 0x6d, 0x57, 0x69, 0x74, 0x68, 0x55, 0x73, 0x65, 0x72, 0x43, 0x72, 0x65, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2b, 0x0a, 0x09, 0x75, 0x73, + 0x65, 0x72, 0x5f, 0x75, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, + 0x74, 0x63, 0x70, 0x5f, 0x63, 0x68, 0x61, 0x74, 0x2e, 0x55, 0x55, 0x49, 0x44, 0x52, 0x08, 0x75, + 0x73, 0x65, 0x72, 0x55, 0x75, 0x69, 0x64, 0x22, 0x3a, 0x0a, 0x08, 0x52, 0x6f, 0x6f, 0x6d, 0x4c, + 0x69, 0x73, 0x74, 0x12, 0x2e, 0x0a, 0x05, 0x72, 0x6f, 0x6f, 0x6d, 0x73, 0x18, 0x01, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x74, 0x63, 0x70, 0x5f, 0x63, 0x68, 0x61, 0x74, 0x2e, 0x53, 0x65, + 0x72, 0x76, 0x65, 0x72, 0x73, 0x69, 0x64, 0x65, 0x52, 0x6f, 0x6f, 0x6d, 0x52, 0x05, 0x72, 0x6f, + 0x6f, 0x6d, 0x73, 0x22, 0x46, 0x0a, 0x0b, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x4c, 0x69, + 0x73, 0x74, 0x12, 0x37, 0x0a, 0x08, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x18, 0x01, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x74, 0x63, 0x70, 0x5f, 0x63, 0x68, 0x61, 0x74, 0x2e, + 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x73, 0x69, 0x64, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, + 0x65, 0x52, 0x08, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x42, 0x33, 0x5a, 0x31, 0x67, + 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x67, 0x6f, 0x6c, 0x61, 0x6e, 0x67, 0x2e, 0x6f, 0x72, 0x67, + 0x2f, 0x62, 0x62, 0x2d, 0x68, 0x61, 0x63, 0x6b, 0x61, 0x74, 0x68, 0x6f, 0x6e, 0x2f, 0x74, 0x63, + 0x70, 0x2d, 0x63, 0x68, 0x61, 0x74, 0x2e, 0x67, 0x69, 0x74, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_requests_proto_rawDescOnce sync.Once + file_requests_proto_rawDescData = file_requests_proto_rawDesc +) + +func file_requests_proto_rawDescGZIP() []byte { + file_requests_proto_rawDescOnce.Do(func() { + file_requests_proto_rawDescData = protoimpl.X.CompressGZIP(file_requests_proto_rawDescData) + }) + return file_requests_proto_rawDescData +} + +var file_requests_proto_msgTypes = make([]protoimpl.MessageInfo, 5) +var file_requests_proto_goTypes = []interface{}{ + (*UserLookupRequest)(nil), // 0: tcp_chat.UserLookupRequest + (*RoomCreationRequest)(nil), // 1: tcp_chat.RoomCreationRequest + (*RoomWithUserCreationRequest)(nil), // 2: tcp_chat.RoomWithUserCreationRequest + (*RoomList)(nil), // 3: tcp_chat.RoomList + (*MessageList)(nil), // 4: tcp_chat.MessageList + (*UUID)(nil), // 5: tcp_chat.UUID + (*ServersideRoom)(nil), // 6: tcp_chat.ServersideRoom + (*ServersideMessage)(nil), // 7: tcp_chat.ServersideMessage +} +var file_requests_proto_depIdxs = []int32{ + 5, // 0: tcp_chat.UserLookupRequest.uuid:type_name -> tcp_chat.UUID + 5, // 1: tcp_chat.RoomCreationRequest.user_uuids:type_name -> tcp_chat.UUID + 5, // 2: tcp_chat.RoomWithUserCreationRequest.user_uuid:type_name -> tcp_chat.UUID + 6, // 3: tcp_chat.RoomList.rooms:type_name -> tcp_chat.ServersideRoom + 7, // 4: tcp_chat.MessageList.messages:type_name -> tcp_chat.ServersideMessage + 5, // [5:5] is the sub-list for method output_type + 5, // [5:5] is the sub-list for method input_type + 5, // [5:5] is the sub-list for extension type_name + 5, // [5:5] is the sub-list for extension extendee + 0, // [0:5] is the sub-list for field type_name +} + +func init() { file_requests_proto_init() } +func file_requests_proto_init() { + if File_requests_proto != nil { + return + } + file_entities_proto_init() + if !protoimpl.UnsafeEnabled { + file_requests_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UserLookupRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_requests_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RoomCreationRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_requests_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RoomWithUserCreationRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_requests_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RoomList); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_requests_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*MessageList); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + file_requests_proto_msgTypes[0].OneofWrappers = []interface{}{ + (*UserLookupRequest_Uuid)(nil), + (*UserLookupRequest_Username)(nil), + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_requests_proto_rawDesc, + NumEnums: 0, + NumMessages: 5, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_requests_proto_goTypes, + DependencyIndexes: file_requests_proto_depIdxs, + MessageInfos: file_requests_proto_msgTypes, + }.Build() + File_requests_proto = out.File + file_requests_proto_rawDesc = nil + file_requests_proto_goTypes = nil + file_requests_proto_depIdxs = nil +} diff --git a/client/proto/service.pb.go b/client/proto/service.pb.go new file mode 100644 index 0000000..a1a4983 --- /dev/null +++ b/client/proto/service.pb.go @@ -0,0 +1,155 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.25.0-devel +// protoc v3.14.0 +// source: service.proto + +package proto + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + emptypb "google.golang.org/protobuf/types/known/emptypb" + reflect "reflect" +) + +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) +) + +var File_service_proto protoreflect.FileDescriptor + +var file_service_proto_rawDesc = []byte{ + 0x0a, 0x0d, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, + 0x08, 0x74, 0x63, 0x70, 0x5f, 0x63, 0x68, 0x61, 0x74, 0x1a, 0x0e, 0x65, 0x6e, 0x74, 0x69, 0x74, + 0x69, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0e, 0x72, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0c, 0x65, 0x76, 0x65, 0x6e, 0x74, + 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x32, 0x8e, 0x01, 0x0a, 0x08, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, + 0x79, 0x12, 0x44, 0x0a, 0x0f, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x4e, 0x65, 0x77, + 0x55, 0x73, 0x65, 0x72, 0x12, 0x19, 0x2e, 0x74, 0x63, 0x70, 0x5f, 0x63, 0x68, 0x61, 0x74, 0x2e, + 0x55, 0x73, 0x65, 0x72, 0x43, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x73, 0x1a, + 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, + 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x3c, 0x0a, 0x0b, 0x4c, 0x6f, 0x67, 0x69, 0x6e, + 0x41, 0x73, 0x55, 0x73, 0x65, 0x72, 0x12, 0x19, 0x2e, 0x74, 0x63, 0x70, 0x5f, 0x63, 0x68, 0x61, + 0x74, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x43, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, + 0x73, 0x1a, 0x12, 0x2e, 0x74, 0x63, 0x70, 0x5f, 0x63, 0x68, 0x61, 0x74, 0x2e, 0x41, 0x75, 0x74, + 0x68, 0x50, 0x61, 0x69, 0x72, 0x32, 0xc2, 0x04, 0x0a, 0x04, 0x43, 0x68, 0x61, 0x74, 0x12, 0x39, + 0x0a, 0x0a, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x55, 0x73, 0x65, 0x72, 0x12, 0x1b, 0x2e, 0x74, + 0x63, 0x70, 0x5f, 0x63, 0x68, 0x61, 0x74, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x4c, 0x6f, 0x6f, 0x6b, + 0x75, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0e, 0x2e, 0x74, 0x63, 0x70, 0x5f, + 0x63, 0x68, 0x61, 0x74, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x12, 0x36, 0x0a, 0x0a, 0x4c, 0x6f, 0x6f, + 0x6b, 0x75, 0x70, 0x52, 0x6f, 0x6f, 0x6d, 0x12, 0x0e, 0x2e, 0x74, 0x63, 0x70, 0x5f, 0x63, 0x68, + 0x61, 0x74, 0x2e, 0x55, 0x55, 0x49, 0x44, 0x1a, 0x18, 0x2e, 0x74, 0x63, 0x70, 0x5f, 0x63, 0x68, + 0x61, 0x74, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x73, 0x69, 0x64, 0x65, 0x52, 0x6f, 0x6f, + 0x6d, 0x12, 0x37, 0x0a, 0x09, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x6f, 0x6f, 0x6d, 0x73, 0x12, 0x16, + 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, + 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x12, 0x2e, 0x74, 0x63, 0x70, 0x5f, 0x63, 0x68, 0x61, + 0x74, 0x2e, 0x52, 0x6f, 0x6f, 0x6d, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x35, 0x0a, 0x0c, 0x4c, 0x69, + 0x73, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x12, 0x0e, 0x2e, 0x74, 0x63, 0x70, + 0x5f, 0x63, 0x68, 0x61, 0x74, 0x2e, 0x55, 0x55, 0x49, 0x44, 0x1a, 0x15, 0x2e, 0x74, 0x63, 0x70, + 0x5f, 0x63, 0x68, 0x61, 0x74, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x4c, 0x69, 0x73, + 0x74, 0x12, 0x42, 0x0a, 0x0b, 0x53, 0x65, 0x6e, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, + 0x12, 0x1b, 0x2e, 0x74, 0x63, 0x70, 0x5f, 0x63, 0x68, 0x61, 0x74, 0x2e, 0x43, 0x6c, 0x69, 0x65, + 0x6e, 0x74, 0x73, 0x69, 0x64, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x1a, 0x16, 0x2e, + 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, + 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x36, 0x0a, 0x0a, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, + 0x6f, 0x6f, 0x6d, 0x12, 0x18, 0x2e, 0x74, 0x63, 0x70, 0x5f, 0x63, 0x68, 0x61, 0x74, 0x2e, 0x43, + 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x73, 0x69, 0x64, 0x65, 0x52, 0x6f, 0x6f, 0x6d, 0x1a, 0x0e, 0x2e, + 0x74, 0x63, 0x70, 0x5f, 0x63, 0x68, 0x61, 0x74, 0x2e, 0x55, 0x55, 0x49, 0x44, 0x12, 0x4b, 0x0a, + 0x12, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x6f, 0x6f, 0x6d, 0x57, 0x69, 0x74, 0x68, 0x55, + 0x73, 0x65, 0x72, 0x12, 0x25, 0x2e, 0x74, 0x63, 0x70, 0x5f, 0x63, 0x68, 0x61, 0x74, 0x2e, 0x52, + 0x6f, 0x6f, 0x6d, 0x57, 0x69, 0x74, 0x68, 0x55, 0x73, 0x65, 0x72, 0x43, 0x72, 0x65, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0e, 0x2e, 0x74, 0x63, 0x70, + 0x5f, 0x63, 0x68, 0x61, 0x74, 0x2e, 0x55, 0x55, 0x49, 0x44, 0x12, 0x42, 0x0a, 0x0f, 0x53, 0x75, + 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x54, 0x6f, 0x52, 0x6f, 0x6f, 0x6d, 0x12, 0x0e, 0x2e, + 0x74, 0x63, 0x70, 0x5f, 0x63, 0x68, 0x61, 0x74, 0x2e, 0x55, 0x55, 0x49, 0x44, 0x1a, 0x1d, 0x2e, + 0x74, 0x63, 0x70, 0x5f, 0x63, 0x68, 0x61, 0x74, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x73, + 0x69, 0x64, 0x65, 0x52, 0x6f, 0x6f, 0x6d, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x30, 0x01, 0x12, 0x4a, + 0x0a, 0x0f, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x54, 0x6f, 0x55, 0x73, 0x65, + 0x72, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x1d, 0x2e, 0x74, 0x63, 0x70, 0x5f, + 0x63, 0x68, 0x61, 0x74, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x73, 0x69, 0x64, 0x65, 0x55, + 0x73, 0x65, 0x72, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x30, 0x01, 0x42, 0x33, 0x5a, 0x31, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x67, 0x6f, 0x6c, 0x61, 0x6e, 0x67, 0x2e, 0x6f, 0x72, 0x67, 0x2f, + 0x62, 0x62, 0x2d, 0x68, 0x61, 0x63, 0x6b, 0x61, 0x74, 0x68, 0x6f, 0x6e, 0x2f, 0x74, 0x63, 0x70, + 0x2d, 0x63, 0x68, 0x61, 0x74, 0x2e, 0x67, 0x69, 0x74, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, + 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var file_service_proto_goTypes = []interface{}{ + (*UserCredentials)(nil), // 0: tcp_chat.UserCredentials + (*UserLookupRequest)(nil), // 1: tcp_chat.UserLookupRequest + (*UUID)(nil), // 2: tcp_chat.UUID + (*emptypb.Empty)(nil), // 3: google.protobuf.Empty + (*ClientsideMessage)(nil), // 4: tcp_chat.ClientsideMessage + (*ClientsideRoom)(nil), // 5: tcp_chat.ClientsideRoom + (*RoomWithUserCreationRequest)(nil), // 6: tcp_chat.RoomWithUserCreationRequest + (*AuthPair)(nil), // 7: tcp_chat.AuthPair + (*User)(nil), // 8: tcp_chat.User + (*ServersideRoom)(nil), // 9: tcp_chat.ServersideRoom + (*RoomList)(nil), // 10: tcp_chat.RoomList + (*MessageList)(nil), // 11: tcp_chat.MessageList + (*ServersideRoomEvent)(nil), // 12: tcp_chat.ServersideRoomEvent + (*ServersideUserEvent)(nil), // 13: tcp_chat.ServersideUserEvent +} +var file_service_proto_depIdxs = []int32{ + 0, // 0: tcp_chat.Registry.RegisterNewUser:input_type -> tcp_chat.UserCredentials + 0, // 1: tcp_chat.Registry.LoginAsUser:input_type -> tcp_chat.UserCredentials + 1, // 2: tcp_chat.Chat.LookupUser:input_type -> tcp_chat.UserLookupRequest + 2, // 3: tcp_chat.Chat.LookupRoom:input_type -> tcp_chat.UUID + 3, // 4: tcp_chat.Chat.ListRooms:input_type -> google.protobuf.Empty + 2, // 5: tcp_chat.Chat.ListMessages:input_type -> tcp_chat.UUID + 4, // 6: tcp_chat.Chat.SendMessage:input_type -> tcp_chat.ClientsideMessage + 5, // 7: tcp_chat.Chat.CreateRoom:input_type -> tcp_chat.ClientsideRoom + 6, // 8: tcp_chat.Chat.CreateRoomWithUser:input_type -> tcp_chat.RoomWithUserCreationRequest + 2, // 9: tcp_chat.Chat.SubscribeToRoom:input_type -> tcp_chat.UUID + 3, // 10: tcp_chat.Chat.SubscribeToUser:input_type -> google.protobuf.Empty + 3, // 11: tcp_chat.Registry.RegisterNewUser:output_type -> google.protobuf.Empty + 7, // 12: tcp_chat.Registry.LoginAsUser:output_type -> tcp_chat.AuthPair + 8, // 13: tcp_chat.Chat.LookupUser:output_type -> tcp_chat.User + 9, // 14: tcp_chat.Chat.LookupRoom:output_type -> tcp_chat.ServersideRoom + 10, // 15: tcp_chat.Chat.ListRooms:output_type -> tcp_chat.RoomList + 11, // 16: tcp_chat.Chat.ListMessages:output_type -> tcp_chat.MessageList + 3, // 17: tcp_chat.Chat.SendMessage:output_type -> google.protobuf.Empty + 2, // 18: tcp_chat.Chat.CreateRoom:output_type -> tcp_chat.UUID + 2, // 19: tcp_chat.Chat.CreateRoomWithUser:output_type -> tcp_chat.UUID + 12, // 20: tcp_chat.Chat.SubscribeToRoom:output_type -> tcp_chat.ServersideRoomEvent + 13, // 21: tcp_chat.Chat.SubscribeToUser:output_type -> tcp_chat.ServersideUserEvent + 11, // [11:22] is the sub-list for method output_type + 0, // [0:11] 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_service_proto_init() } +func file_service_proto_init() { + if File_service_proto != nil { + return + } + file_entities_proto_init() + file_requests_proto_init() + file_events_proto_init() + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_service_proto_rawDesc, + NumEnums: 0, + NumMessages: 0, + NumExtensions: 0, + NumServices: 2, + }, + GoTypes: file_service_proto_goTypes, + DependencyIndexes: file_service_proto_depIdxs, + }.Build() + File_service_proto = out.File + file_service_proto_rawDesc = nil + file_service_proto_goTypes = nil + file_service_proto_depIdxs = nil +} diff --git a/client/proto/service_grpc.pb.go b/client/proto/service_grpc.pb.go new file mode 100644 index 0000000..6c32191 --- /dev/null +++ b/client/proto/service_grpc.pb.go @@ -0,0 +1,619 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. + +package proto + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + emptypb "google.golang.org/protobuf/types/known/emptypb" +) + +// 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 + +// RegistryClient is the client API for Registry 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 RegistryClient interface { + // Attempt to register a new user with the provided credentials. + // + // If a user with such username already exists, produce an error. + RegisterNewUser(ctx context.Context, in *UserCredentials, opts ...grpc.CallOption) (*emptypb.Empty, error) + // Attempt to log in as an existing user with the provided credentials. + // + // If a matching account is found, return an AuthPair for subscriptions. + // If no such user exists or the password is incorrect, return an error. + LoginAsUser(ctx context.Context, in *UserCredentials, opts ...grpc.CallOption) (*AuthPair, error) +} + +type registryClient struct { + cc grpc.ClientConnInterface +} + +func NewRegistryClient(cc grpc.ClientConnInterface) RegistryClient { + return ®istryClient{cc} +} + +func (c *registryClient) RegisterNewUser(ctx context.Context, in *UserCredentials, opts ...grpc.CallOption) (*emptypb.Empty, error) { + out := new(emptypb.Empty) + err := c.cc.Invoke(ctx, "/tcp_chat.Registry/RegisterNewUser", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *registryClient) LoginAsUser(ctx context.Context, in *UserCredentials, opts ...grpc.CallOption) (*AuthPair, error) { + out := new(AuthPair) + err := c.cc.Invoke(ctx, "/tcp_chat.Registry/LoginAsUser", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// RegistryServer is the server API for Registry service. +// All implementations must embed UnimplementedRegistryServer +// for forward compatibility +type RegistryServer interface { + // Attempt to register a new user with the provided credentials. + // + // If a user with such username already exists, produce an error. + RegisterNewUser(context.Context, *UserCredentials) (*emptypb.Empty, error) + // Attempt to log in as an existing user with the provided credentials. + // + // If a matching account is found, return an AuthPair for subscriptions. + // If no such user exists or the password is incorrect, return an error. + LoginAsUser(context.Context, *UserCredentials) (*AuthPair, error) + mustEmbedUnimplementedRegistryServer() +} + +// UnimplementedRegistryServer must be embedded to have forward compatible implementations. +type UnimplementedRegistryServer struct { +} + +func (UnimplementedRegistryServer) RegisterNewUser(context.Context, *UserCredentials) (*emptypb.Empty, error) { + return nil, status.Errorf(codes.Unimplemented, "method RegisterNewUser not implemented") +} +func (UnimplementedRegistryServer) LoginAsUser(context.Context, *UserCredentials) (*AuthPair, error) { + return nil, status.Errorf(codes.Unimplemented, "method LoginAsUser not implemented") +} +func (UnimplementedRegistryServer) mustEmbedUnimplementedRegistryServer() {} + +// UnsafeRegistryServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to RegistryServer will +// result in compilation errors. +type UnsafeRegistryServer interface { + mustEmbedUnimplementedRegistryServer() +} + +func RegisterRegistryServer(s grpc.ServiceRegistrar, srv RegistryServer) { + s.RegisterService(&Registry_ServiceDesc, srv) +} + +func _Registry_RegisterNewUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UserCredentials) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(RegistryServer).RegisterNewUser(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/tcp_chat.Registry/RegisterNewUser", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(RegistryServer).RegisterNewUser(ctx, req.(*UserCredentials)) + } + return interceptor(ctx, in, info, handler) +} + +func _Registry_LoginAsUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UserCredentials) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(RegistryServer).LoginAsUser(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/tcp_chat.Registry/LoginAsUser", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(RegistryServer).LoginAsUser(ctx, req.(*UserCredentials)) + } + return interceptor(ctx, in, info, handler) +} + +// Registry_ServiceDesc is the grpc.ServiceDesc for Registry service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var Registry_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "tcp_chat.Registry", + HandlerType: (*RegistryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "RegisterNewUser", + Handler: _Registry_RegisterNewUser_Handler, + }, + { + MethodName: "LoginAsUser", + Handler: _Registry_LoginAsUser_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "service.proto", +} + +// ChatClient is the client API for Chat 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 ChatClient interface { + // Look up a user account by username or UUID. + LookupUser(ctx context.Context, in *UserLookupRequest, opts ...grpc.CallOption) (*User, error) + // Look up a room by UUID. + LookupRoom(ctx context.Context, in *UUID, opts ...grpc.CallOption) (*ServersideRoom, error) + // List all rooms the currently logged in user is a member of. + ListRooms(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*RoomList, error) + // List all messages in a certain room. + ListMessages(ctx context.Context, in *UUID, opts ...grpc.CallOption) (*MessageList, error) + // Send a new message to a room. + // + // The sent message will be mirrored to all clients with a running + // SubscribeToRoom handle (if it has the same room UUID), including + // the sender of the message. + SendMessage(ctx context.Context, in *ClientsideMessage, opts ...grpc.CallOption) (*emptypb.Empty, error) + // Create a new room with however many users. + CreateRoom(ctx context.Context, in *ClientsideRoom, opts ...grpc.CallOption) (*UUID, error) + // Create a new chat (1x1 room) with a user. + CreateRoomWithUser(ctx context.Context, in *RoomWithUserCreationRequest, opts ...grpc.CallOption) (*UUID, error) + // Subscribe to events inside a room. + // + // This RPC will yield any new messages that are sent to the provided room, + // along with special events when another user joins or leaves the room. + SubscribeToRoom(ctx context.Context, in *UUID, opts ...grpc.CallOption) (Chat_SubscribeToRoomClient, error) + // Subscribe to personal events. + // + // This RPC will yield event when the currently logged in user gets added + // to a room he's not a member of or kicked out of a room. + SubscribeToUser(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (Chat_SubscribeToUserClient, error) +} + +type chatClient struct { + cc grpc.ClientConnInterface +} + +func NewChatClient(cc grpc.ClientConnInterface) ChatClient { + return &chatClient{cc} +} + +func (c *chatClient) LookupUser(ctx context.Context, in *UserLookupRequest, opts ...grpc.CallOption) (*User, error) { + out := new(User) + err := c.cc.Invoke(ctx, "/tcp_chat.Chat/LookupUser", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *chatClient) LookupRoom(ctx context.Context, in *UUID, opts ...grpc.CallOption) (*ServersideRoom, error) { + out := new(ServersideRoom) + err := c.cc.Invoke(ctx, "/tcp_chat.Chat/LookupRoom", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *chatClient) ListRooms(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*RoomList, error) { + out := new(RoomList) + err := c.cc.Invoke(ctx, "/tcp_chat.Chat/ListRooms", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *chatClient) ListMessages(ctx context.Context, in *UUID, opts ...grpc.CallOption) (*MessageList, error) { + out := new(MessageList) + err := c.cc.Invoke(ctx, "/tcp_chat.Chat/ListMessages", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *chatClient) SendMessage(ctx context.Context, in *ClientsideMessage, opts ...grpc.CallOption) (*emptypb.Empty, error) { + out := new(emptypb.Empty) + err := c.cc.Invoke(ctx, "/tcp_chat.Chat/SendMessage", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *chatClient) CreateRoom(ctx context.Context, in *ClientsideRoom, opts ...grpc.CallOption) (*UUID, error) { + out := new(UUID) + err := c.cc.Invoke(ctx, "/tcp_chat.Chat/CreateRoom", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *chatClient) CreateRoomWithUser(ctx context.Context, in *RoomWithUserCreationRequest, opts ...grpc.CallOption) (*UUID, error) { + out := new(UUID) + err := c.cc.Invoke(ctx, "/tcp_chat.Chat/CreateRoomWithUser", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *chatClient) SubscribeToRoom(ctx context.Context, in *UUID, opts ...grpc.CallOption) (Chat_SubscribeToRoomClient, error) { + stream, err := c.cc.NewStream(ctx, &Chat_ServiceDesc.Streams[0], "/tcp_chat.Chat/SubscribeToRoom", opts...) + if err != nil { + return nil, err + } + x := &chatSubscribeToRoomClient{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +type Chat_SubscribeToRoomClient interface { + Recv() (*ServersideRoomEvent, error) + grpc.ClientStream +} + +type chatSubscribeToRoomClient struct { + grpc.ClientStream +} + +func (x *chatSubscribeToRoomClient) Recv() (*ServersideRoomEvent, error) { + m := new(ServersideRoomEvent) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func (c *chatClient) SubscribeToUser(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (Chat_SubscribeToUserClient, error) { + stream, err := c.cc.NewStream(ctx, &Chat_ServiceDesc.Streams[1], "/tcp_chat.Chat/SubscribeToUser", opts...) + if err != nil { + return nil, err + } + x := &chatSubscribeToUserClient{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +type Chat_SubscribeToUserClient interface { + Recv() (*ServersideUserEvent, error) + grpc.ClientStream +} + +type chatSubscribeToUserClient struct { + grpc.ClientStream +} + +func (x *chatSubscribeToUserClient) Recv() (*ServersideUserEvent, error) { + m := new(ServersideUserEvent) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +// ChatServer is the server API for Chat service. +// All implementations must embed UnimplementedChatServer +// for forward compatibility +type ChatServer interface { + // Look up a user account by username or UUID. + LookupUser(context.Context, *UserLookupRequest) (*User, error) + // Look up a room by UUID. + LookupRoom(context.Context, *UUID) (*ServersideRoom, error) + // List all rooms the currently logged in user is a member of. + ListRooms(context.Context, *emptypb.Empty) (*RoomList, error) + // List all messages in a certain room. + ListMessages(context.Context, *UUID) (*MessageList, error) + // Send a new message to a room. + // + // The sent message will be mirrored to all clients with a running + // SubscribeToRoom handle (if it has the same room UUID), including + // the sender of the message. + SendMessage(context.Context, *ClientsideMessage) (*emptypb.Empty, error) + // Create a new room with however many users. + CreateRoom(context.Context, *ClientsideRoom) (*UUID, error) + // Create a new chat (1x1 room) with a user. + CreateRoomWithUser(context.Context, *RoomWithUserCreationRequest) (*UUID, error) + // Subscribe to events inside a room. + // + // This RPC will yield any new messages that are sent to the provided room, + // along with special events when another user joins or leaves the room. + SubscribeToRoom(*UUID, Chat_SubscribeToRoomServer) error + // Subscribe to personal events. + // + // This RPC will yield event when the currently logged in user gets added + // to a room he's not a member of or kicked out of a room. + SubscribeToUser(*emptypb.Empty, Chat_SubscribeToUserServer) error + mustEmbedUnimplementedChatServer() +} + +// UnimplementedChatServer must be embedded to have forward compatible implementations. +type UnimplementedChatServer struct { +} + +func (UnimplementedChatServer) LookupUser(context.Context, *UserLookupRequest) (*User, error) { + return nil, status.Errorf(codes.Unimplemented, "method LookupUser not implemented") +} +func (UnimplementedChatServer) LookupRoom(context.Context, *UUID) (*ServersideRoom, error) { + return nil, status.Errorf(codes.Unimplemented, "method LookupRoom not implemented") +} +func (UnimplementedChatServer) ListRooms(context.Context, *emptypb.Empty) (*RoomList, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListRooms not implemented") +} +func (UnimplementedChatServer) ListMessages(context.Context, *UUID) (*MessageList, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListMessages not implemented") +} +func (UnimplementedChatServer) SendMessage(context.Context, *ClientsideMessage) (*emptypb.Empty, error) { + return nil, status.Errorf(codes.Unimplemented, "method SendMessage not implemented") +} +func (UnimplementedChatServer) CreateRoom(context.Context, *ClientsideRoom) (*UUID, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreateRoom not implemented") +} +func (UnimplementedChatServer) CreateRoomWithUser(context.Context, *RoomWithUserCreationRequest) (*UUID, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreateRoomWithUser not implemented") +} +func (UnimplementedChatServer) SubscribeToRoom(*UUID, Chat_SubscribeToRoomServer) error { + return status.Errorf(codes.Unimplemented, "method SubscribeToRoom not implemented") +} +func (UnimplementedChatServer) SubscribeToUser(*emptypb.Empty, Chat_SubscribeToUserServer) error { + return status.Errorf(codes.Unimplemented, "method SubscribeToUser not implemented") +} +func (UnimplementedChatServer) mustEmbedUnimplementedChatServer() {} + +// UnsafeChatServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to ChatServer will +// result in compilation errors. +type UnsafeChatServer interface { + mustEmbedUnimplementedChatServer() +} + +func RegisterChatServer(s grpc.ServiceRegistrar, srv ChatServer) { + s.RegisterService(&Chat_ServiceDesc, srv) +} + +func _Chat_LookupUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UserLookupRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ChatServer).LookupUser(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/tcp_chat.Chat/LookupUser", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ChatServer).LookupUser(ctx, req.(*UserLookupRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Chat_LookupRoom_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UUID) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ChatServer).LookupRoom(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/tcp_chat.Chat/LookupRoom", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ChatServer).LookupRoom(ctx, req.(*UUID)) + } + return interceptor(ctx, in, info, handler) +} + +func _Chat_ListRooms_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(emptypb.Empty) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ChatServer).ListRooms(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/tcp_chat.Chat/ListRooms", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ChatServer).ListRooms(ctx, req.(*emptypb.Empty)) + } + return interceptor(ctx, in, info, handler) +} + +func _Chat_ListMessages_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UUID) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ChatServer).ListMessages(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/tcp_chat.Chat/ListMessages", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ChatServer).ListMessages(ctx, req.(*UUID)) + } + return interceptor(ctx, in, info, handler) +} + +func _Chat_SendMessage_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ClientsideMessage) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ChatServer).SendMessage(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/tcp_chat.Chat/SendMessage", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ChatServer).SendMessage(ctx, req.(*ClientsideMessage)) + } + return interceptor(ctx, in, info, handler) +} + +func _Chat_CreateRoom_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ClientsideRoom) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ChatServer).CreateRoom(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/tcp_chat.Chat/CreateRoom", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ChatServer).CreateRoom(ctx, req.(*ClientsideRoom)) + } + return interceptor(ctx, in, info, handler) +} + +func _Chat_CreateRoomWithUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(RoomWithUserCreationRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ChatServer).CreateRoomWithUser(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/tcp_chat.Chat/CreateRoomWithUser", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ChatServer).CreateRoomWithUser(ctx, req.(*RoomWithUserCreationRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Chat_SubscribeToRoom_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(UUID) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(ChatServer).SubscribeToRoom(m, &chatSubscribeToRoomServer{stream}) +} + +type Chat_SubscribeToRoomServer interface { + Send(*ServersideRoomEvent) error + grpc.ServerStream +} + +type chatSubscribeToRoomServer struct { + grpc.ServerStream +} + +func (x *chatSubscribeToRoomServer) Send(m *ServersideRoomEvent) error { + return x.ServerStream.SendMsg(m) +} + +func _Chat_SubscribeToUser_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(emptypb.Empty) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(ChatServer).SubscribeToUser(m, &chatSubscribeToUserServer{stream}) +} + +type Chat_SubscribeToUserServer interface { + Send(*ServersideUserEvent) error + grpc.ServerStream +} + +type chatSubscribeToUserServer struct { + grpc.ServerStream +} + +func (x *chatSubscribeToUserServer) Send(m *ServersideUserEvent) error { + return x.ServerStream.SendMsg(m) +} + +// Chat_ServiceDesc is the grpc.ServiceDesc for Chat service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var Chat_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "tcp_chat.Chat", + HandlerType: (*ChatServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "LookupUser", + Handler: _Chat_LookupUser_Handler, + }, + { + MethodName: "LookupRoom", + Handler: _Chat_LookupRoom_Handler, + }, + { + MethodName: "ListRooms", + Handler: _Chat_ListRooms_Handler, + }, + { + MethodName: "ListMessages", + Handler: _Chat_ListMessages_Handler, + }, + { + MethodName: "SendMessage", + Handler: _Chat_SendMessage_Handler, + }, + { + MethodName: "CreateRoom", + Handler: _Chat_CreateRoom_Handler, + }, + { + MethodName: "CreateRoomWithUser", + Handler: _Chat_CreateRoomWithUser_Handler, + }, + }, + Streams: []grpc.StreamDesc{ + { + StreamName: "SubscribeToRoom", + Handler: _Chat_SubscribeToRoom_Handler, + ServerStreams: true, + }, + { + StreamName: "SubscribeToUser", + Handler: _Chat_SubscribeToUser_Handler, + ServerStreams: true, + }, + }, + Metadata: "service.proto", +} diff --git a/client/src/create_room/create_room.go b/client/src/create_room/create_room.go new file mode 100644 index 0000000..cf512a3 --- /dev/null +++ b/client/src/create_room/create_room.go @@ -0,0 +1,42 @@ +package main + +import ( + "context" + "fmt" + "log" + + proto "bb-hackathon/tcp-chat.git/proto" + + "google.golang.org/grpc" + "google.golang.org/grpc/metadata" +) + +func main() { + conn, err := grpc.Dial("luna:9001", grpc.WithInsecure()) + if err != nil { + log.Fatalf("did not connect: %v", err) + } + defer conn.Close() + + client := proto.NewChatClient(conn) + + ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs( + "user_uuid", "d9890202-a129-4044-8736-e7770fcae7f5", + "auth_token", "f94ee0212842c6434f019eb42bfcdc63", + )) + + roomReq := &proto.ClientsideRoom{ + Name: "Room2", + Members: []*proto.UUID{ + &proto.UUID{Uuid: "d9890202-a129-4044-8736-e7770fcae7f5"}, + }, + } + + response, err := client.CreateRoom(ctx, roomReq) + if err != nil { + log.Fatalf("CreateRoom failed: %v", err) + } else { + log.Println("Room created successfully") + fmt.Println(response) + } +} diff --git a/client/src/login/login.go b/client/src/login/login.go new file mode 100644 index 0000000..31249d3 --- /dev/null +++ b/client/src/login/login.go @@ -0,0 +1,35 @@ +package main + +import ( + "context" + "fmt" + "log" + + proto "bb-hackathon/tcp-chat.git/proto" + + "google.golang.org/grpc" +) + +func main() { + conn, err := grpc.Dial("luna:9001", grpc.WithInsecure()) + if err != nil { + log.Fatalf("did not connect: %v", err) + } + defer conn.Close() + + client := proto.NewRegistryClient(conn) + + ctx := context.Background() + userCredentials := &proto.UserCredentials{ + Username: "user2", + Password: "password", + } + + response, err := client.LoginAsUser(ctx, userCredentials) + if err != nil { + log.Fatalf("could not login: %v", err) + } + + fmt.Println(response) + log.Printf("Logged in successfully") +} diff --git a/client/src/register/register.go b/client/src/register/register.go new file mode 100644 index 0000000..fac1e81 --- /dev/null +++ b/client/src/register/register.go @@ -0,0 +1,33 @@ +package main + +import ( + "context" + "log" + + proto "bb-hackathon/tcp-chat.git/proto" + + "google.golang.org/grpc" +) + +func main() { + conn, err := grpc.Dial("luna:9001", grpc.WithInsecure()) + if err != nil { + log.Fatalf("did not connect: %v", err) + } + defer conn.Close() + + client := proto.NewRegistryClient(conn) + + ctx := context.Background() + userCredentials := &proto.UserCredentials{ + Username: "user2", + Password: "password", + } + + _, err = client.RegisterNewUser(ctx, userCredentials) + if err != nil { + log.Fatalf("could not register new user: %v", err) + } + + log.Printf("Registered new user successfully") +} diff --git a/client/src/send_message/send_message.go b/client/src/send_message/send_message.go new file mode 100644 index 0000000..fe22f50 --- /dev/null +++ b/client/src/send_message/send_message.go @@ -0,0 +1,40 @@ +package main + +import ( + "context" + "log" + + "google.golang.org/grpc" + "google.golang.org/grpc/metadata" + + "bb-hackathon/tcp-chat.git/proto" +) + +func main() { + conn, err := grpc.Dial("luna:9001", grpc.WithInsecure()) + if err != nil { + log.Fatalf("Failed to connect: %v", err) + } + defer conn.Close() + + client := proto.NewChatClient(conn) + + md := metadata.Pairs( + "user_uuid", "d9890202-a129-4044-8736-e7770fcae7f5", + "auth_token", "f94ee0212842c6434f019eb42bfcdc63", + ) + + ctx := metadata.NewOutgoingContext(context.Background(), md) + + messageReq := &proto.ClientsideMessage{ + RoomUuid: &proto.UUID{Uuid: "36537ef0-ee3e-44fa-aaa1-6547e466dd4a"}, + Text: "Hello, BOBR!", + } + + _, err = client.SendMessage(ctx, messageReq) + if err != nil { + log.Fatalf("SendMessage failed: %v", err) + } else { + log.Println("Message sent successfully") + } +} diff --git a/client/src/subscribe_room/subscribe_room.go b/client/src/subscribe_room/subscribe_room.go new file mode 100644 index 0000000..3af1082 --- /dev/null +++ b/client/src/subscribe_room/subscribe_room.go @@ -0,0 +1,42 @@ +package main + +import ( + "context" + "log" + + "google.golang.org/grpc" + "google.golang.org/grpc/metadata" + + proto "bb-hackathon/tcp-chat.git/proto" +) + +func main() { + conn, err := grpc.Dial("luna:9001", grpc.WithInsecure()) + if err != nil { + log.Fatalf("Failed to connect: %v", err) + } + defer conn.Close() + + client := proto.NewChatClient(conn) + + md := metadata.Pairs( + "user_uuid", "d9890202-a129-4044-8736-e7770fcae7f5", + "auth_token", "f94ee0212842c6434f019eb42bfcdc63", + ) + + ctx := metadata.NewOutgoingContext(context.Background(), md) + + roomUUID := "36537ef0-ee3e-44fa-aaa1-6547e466dd4a" + stream, err := client.SubscribeToRoom(ctx, &proto.UUID{Uuid: roomUUID}) + if err != nil { + log.Fatalf("SubscribeToRoom failed: %v", err) + } + + for { + event, err := stream.Recv() + if err != nil { + log.Fatalf("Error receiving event: %v", err) + } + log.Printf("Received event: %v", event) + } +}