This commit is contained in:
Daniel Ponte 2024-10-19 23:09:31 -04:00
parent 2928009e3e
commit 5131da0451
3 changed files with 103 additions and 78 deletions

View file

@ -95,10 +95,14 @@ func (c *client) Talkgroup(ctx context.Context, tg *pb.Talkgroup) error {
SystemName: tgi.SystemName,
}
c.Send(&pb.Response{
CommandId: CommandID(ctx),
CommandResponse: &pb.Response_TgInfo{
TgInfo: resp,
c.Send(&pb.Message{
ToClientMessage: &pb.Message_Response{
Response: &pb.CommandResponse{
CommandId: CommandID(ctx),
CommandResponse: &pb.CommandResponse_TgInfo{
TgInfo: resp,
},
},
},
})

View file

@ -78,6 +78,7 @@ type Message struct {
// Types that are assignable to ToClientMessage:
//
// *Message_Response
// *Message_Call
// *Message_Notification
// *Message_Popup
@ -125,6 +126,13 @@ func (m *Message) GetToClientMessage() isMessage_ToClientMessage {
return nil
}
func (x *Message) GetResponse() *CommandResponse {
if x, ok := x.GetToClientMessage().(*Message_Response); ok {
return x.Response
}
return nil
}
func (x *Message) GetCall() *Call {
if x, ok := x.GetToClientMessage().(*Message_Call); ok {
return x.Call
@ -164,26 +172,32 @@ type isMessage_ToClientMessage interface {
isMessage_ToClientMessage()
}
type Message_Response struct {
Response *CommandResponse `protobuf:"bytes,1,opt,name=response,proto3,oneof"`
}
type Message_Call struct {
Call *Call `protobuf:"bytes,1,opt,name=call,proto3,oneof"`
Call *Call `protobuf:"bytes,2,opt,name=call,proto3,oneof"`
}
type Message_Notification struct {
Notification *Notification `protobuf:"bytes,2,opt,name=notification,proto3,oneof"`
Notification *Notification `protobuf:"bytes,3,opt,name=notification,proto3,oneof"`
}
type Message_Popup struct {
Popup *UserPopup `protobuf:"bytes,3,opt,name=popup,proto3,oneof"`
Popup *UserPopup `protobuf:"bytes,4,opt,name=popup,proto3,oneof"`
}
type Message_Error struct {
Error *Error `protobuf:"bytes,4,opt,name=error,proto3,oneof"`
Error *Error `protobuf:"bytes,5,opt,name=error,proto3,oneof"`
}
type Message_Hello struct {
Hello *Hello `protobuf:"bytes,5,opt,name=hello,proto3,oneof"`
Hello *Hello `protobuf:"bytes,6,opt,name=hello,proto3,oneof"`
}
func (*Message_Response) isMessage_ToClientMessage() {}
func (*Message_Call) isMessage_ToClientMessage() {}
func (*Message_Notification) isMessage_ToClientMessage() {}
@ -194,7 +208,7 @@ func (*Message_Error) isMessage_ToClientMessage() {}
func (*Message_Hello) isMessage_ToClientMessage() {}
type Response struct {
type CommandResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
@ -202,12 +216,12 @@ type Response struct {
CommandId *int64 `protobuf:"varint,1,opt,name=command_id,json=commandId,proto3,oneof" json:"command_id,omitempty"`
// Types that are assignable to CommandResponse:
//
// *Response_TgInfo
CommandResponse isResponse_CommandResponse `protobuf_oneof:"command_response"`
// *CommandResponse_TgInfo
CommandResponse isCommandResponse_CommandResponse `protobuf_oneof:"command_response"`
}
func (x *Response) Reset() {
*x = Response{}
func (x *CommandResponse) Reset() {
*x = CommandResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_stillbox_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@ -215,13 +229,13 @@ func (x *Response) Reset() {
}
}
func (x *Response) String() string {
func (x *CommandResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Response) ProtoMessage() {}
func (*CommandResponse) ProtoMessage() {}
func (x *Response) ProtoReflect() protoreflect.Message {
func (x *CommandResponse) ProtoReflect() protoreflect.Message {
mi := &file_stillbox_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@ -233,41 +247,41 @@ func (x *Response) ProtoReflect() protoreflect.Message {
return mi.MessageOf(x)
}
// Deprecated: Use Response.ProtoReflect.Descriptor instead.
func (*Response) Descriptor() ([]byte, []int) {
// Deprecated: Use CommandResponse.ProtoReflect.Descriptor instead.
func (*CommandResponse) Descriptor() ([]byte, []int) {
return file_stillbox_proto_rawDescGZIP(), []int{1}
}
func (x *Response) GetCommandId() int64 {
func (x *CommandResponse) GetCommandId() int64 {
if x != nil && x.CommandId != nil {
return *x.CommandId
}
return 0
}
func (m *Response) GetCommandResponse() isResponse_CommandResponse {
func (m *CommandResponse) GetCommandResponse() isCommandResponse_CommandResponse {
if m != nil {
return m.CommandResponse
}
return nil
}
func (x *Response) GetTgInfo() *TalkgroupInfo {
if x, ok := x.GetCommandResponse().(*Response_TgInfo); ok {
func (x *CommandResponse) GetTgInfo() *TalkgroupInfo {
if x, ok := x.GetCommandResponse().(*CommandResponse_TgInfo); ok {
return x.TgInfo
}
return nil
}
type isResponse_CommandResponse interface {
isResponse_CommandResponse()
type isCommandResponse_CommandResponse interface {
isCommandResponse_CommandResponse()
}
type Response_TgInfo struct {
type CommandResponse_TgInfo struct {
TgInfo *TalkgroupInfo `protobuf:"bytes,2,opt,name=tg_info,json=tgInfo,proto3,oneof"`
}
func (*Response_TgInfo) isResponse_CommandResponse() {}
func (*CommandResponse_TgInfo) isCommandResponse_CommandResponse() {}
type Call struct {
state protoimpl.MessageState
@ -1136,24 +1150,28 @@ var file_stillbox_proto_rawDesc = []byte{
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, 0x1a, 0x1c, 0x67, 0x6f, 0x6f,
0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x73, 0x74, 0x72,
0x75, 0x63, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x80, 0x02, 0x0a, 0x07, 0x4d, 0x65,
0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x24, 0x0a, 0x04, 0x63, 0x61, 0x6c, 0x6c, 0x18, 0x01, 0x20,
0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x73, 0x74, 0x69, 0x6c, 0x6c, 0x62, 0x6f, 0x78, 0x2e, 0x43,
0x61, 0x6c, 0x6c, 0x48, 0x00, 0x52, 0x04, 0x63, 0x61, 0x6c, 0x6c, 0x12, 0x3c, 0x0a, 0x0c, 0x6e,
0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28,
0x0b, 0x32, 0x16, 0x2e, 0x73, 0x74, 0x69, 0x6c, 0x6c, 0x62, 0x6f, 0x78, 0x2e, 0x4e, 0x6f, 0x74,
0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x48, 0x00, 0x52, 0x0c, 0x6e, 0x6f, 0x74,
0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2b, 0x0a, 0x05, 0x70, 0x6f, 0x70,
0x75, 0x70, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x73, 0x74, 0x69, 0x6c, 0x6c,
0x62, 0x6f, 0x78, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x50, 0x6f, 0x70, 0x75, 0x70, 0x48, 0x00, 0x52,
0x05, 0x70, 0x6f, 0x70, 0x75, 0x70, 0x12, 0x27, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18,
0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x73, 0x74, 0x69, 0x6c, 0x6c, 0x62, 0x6f, 0x78,
0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x48, 0x00, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x12,
0x27, 0x0a, 0x05, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f,
0x2e, 0x73, 0x74, 0x69, 0x6c, 0x6c, 0x62, 0x6f, 0x78, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x48,
0x00, 0x52, 0x05, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x42, 0x12, 0x0a, 0x10, 0x74, 0x6f, 0x43, 0x6c,
0x69, 0x65, 0x6e, 0x74, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x85, 0x01, 0x0a,
0x08, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x22, 0x0a, 0x0a, 0x63, 0x6f, 0x6d,
0x75, 0x63, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xb9, 0x02, 0x0a, 0x07, 0x4d, 0x65,
0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x37, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x73, 0x74, 0x69, 0x6c, 0x6c, 0x62,
0x6f, 0x78, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
0x73, 0x65, 0x48, 0x00, 0x52, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x24,
0x0a, 0x04, 0x63, 0x61, 0x6c, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x73,
0x74, 0x69, 0x6c, 0x6c, 0x62, 0x6f, 0x78, 0x2e, 0x43, 0x61, 0x6c, 0x6c, 0x48, 0x00, 0x52, 0x04,
0x63, 0x61, 0x6c, 0x6c, 0x12, 0x3c, 0x0a, 0x0c, 0x6e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61,
0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x73, 0x74, 0x69,
0x6c, 0x6c, 0x62, 0x6f, 0x78, 0x2e, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69,
0x6f, 0x6e, 0x48, 0x00, 0x52, 0x0c, 0x6e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69,
0x6f, 0x6e, 0x12, 0x2b, 0x0a, 0x05, 0x70, 0x6f, 0x70, 0x75, 0x70, 0x18, 0x04, 0x20, 0x01, 0x28,
0x0b, 0x32, 0x13, 0x2e, 0x73, 0x74, 0x69, 0x6c, 0x6c, 0x62, 0x6f, 0x78, 0x2e, 0x55, 0x73, 0x65,
0x72, 0x50, 0x6f, 0x70, 0x75, 0x70, 0x48, 0x00, 0x52, 0x05, 0x70, 0x6f, 0x70, 0x75, 0x70, 0x12,
0x27, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f,
0x2e, 0x73, 0x74, 0x69, 0x6c, 0x6c, 0x62, 0x6f, 0x78, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x48,
0x00, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x27, 0x0a, 0x05, 0x68, 0x65, 0x6c, 0x6c,
0x6f, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x73, 0x74, 0x69, 0x6c, 0x6c, 0x62,
0x6f, 0x78, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x48, 0x00, 0x52, 0x05, 0x68, 0x65, 0x6c, 0x6c,
0x6f, 0x42, 0x12, 0x0a, 0x10, 0x74, 0x6f, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x6d, 0x65,
0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x8c, 0x01, 0x0a, 0x0f, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e,
0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x22, 0x0a, 0x0a, 0x63, 0x6f, 0x6d,
0x6d, 0x61, 0x6e, 0x64, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x48, 0x01, 0x52,
0x09, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x49, 0x64, 0x88, 0x01, 0x01, 0x12, 0x32, 0x0a,
0x07, 0x74, 0x67, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17,
@ -1302,7 +1320,7 @@ var file_stillbox_proto_msgTypes = make([]protoimpl.MessageInfo, 14)
var file_stillbox_proto_goTypes = []interface{}{
(LiveState)(0), // 0: stillbox.LiveState
(*Message)(nil), // 1: stillbox.Message
(*Response)(nil), // 2: stillbox.Response
(*CommandResponse)(nil), // 2: stillbox.CommandResponse
(*Call)(nil), // 3: stillbox.Call
(*Hello)(nil), // 4: stillbox.Hello
(*UserPopup)(nil), // 5: stillbox.UserPopup
@ -1319,30 +1337,31 @@ var file_stillbox_proto_goTypes = []interface{}{
(*structpb.Struct)(nil), // 16: google.protobuf.Struct
}
var file_stillbox_proto_depIdxs = []int32{
3, // 0: stillbox.Message.call:type_name -> stillbox.Call
7, // 1: stillbox.Message.notification:type_name -> stillbox.Notification
5, // 2: stillbox.Message.popup:type_name -> stillbox.UserPopup
6, // 3: stillbox.Message.error:type_name -> stillbox.Error
4, // 4: stillbox.Message.hello:type_name -> stillbox.Hello
9, // 5: stillbox.Response.tg_info:type_name -> stillbox.TalkgroupInfo
15, // 6: stillbox.Call.date_time:type_name -> google.protobuf.Timestamp
14, // 7: stillbox.Hello.version:type_name -> stillbox.Version
8, // 8: stillbox.Error.command:type_name -> stillbox.Command
15, // 9: stillbox.Notification.date_time:type_name -> google.protobuf.Timestamp
10, // 10: stillbox.Command.live_command:type_name -> stillbox.Live
13, // 11: stillbox.Command.search_command:type_name -> stillbox.Search
11, // 12: stillbox.Command.tg_command:type_name -> stillbox.Talkgroup
11, // 13: stillbox.TalkgroupInfo.tg:type_name -> stillbox.Talkgroup
16, // 14: stillbox.TalkgroupInfo.metadata:type_name -> google.protobuf.Struct
0, // 15: stillbox.Live.state:type_name -> stillbox.LiveState
12, // 16: stillbox.Live.filter:type_name -> stillbox.Filter
11, // 17: stillbox.Filter.talkgroups:type_name -> stillbox.Talkgroup
11, // 18: stillbox.Filter.talkgroups_not:type_name -> stillbox.Talkgroup
19, // [19:19] is the sub-list for method output_type
19, // [19:19] is the sub-list for method input_type
19, // [19:19] is the sub-list for extension type_name
19, // [19:19] is the sub-list for extension extendee
0, // [0:19] is the sub-list for field type_name
2, // 0: stillbox.Message.response:type_name -> stillbox.CommandResponse
3, // 1: stillbox.Message.call:type_name -> stillbox.Call
7, // 2: stillbox.Message.notification:type_name -> stillbox.Notification
5, // 3: stillbox.Message.popup:type_name -> stillbox.UserPopup
6, // 4: stillbox.Message.error:type_name -> stillbox.Error
4, // 5: stillbox.Message.hello:type_name -> stillbox.Hello
9, // 6: stillbox.CommandResponse.tg_info:type_name -> stillbox.TalkgroupInfo
15, // 7: stillbox.Call.date_time:type_name -> google.protobuf.Timestamp
14, // 8: stillbox.Hello.version:type_name -> stillbox.Version
8, // 9: stillbox.Error.command:type_name -> stillbox.Command
15, // 10: stillbox.Notification.date_time:type_name -> google.protobuf.Timestamp
10, // 11: stillbox.Command.live_command:type_name -> stillbox.Live
13, // 12: stillbox.Command.search_command:type_name -> stillbox.Search
11, // 13: stillbox.Command.tg_command:type_name -> stillbox.Talkgroup
11, // 14: stillbox.TalkgroupInfo.tg:type_name -> stillbox.Talkgroup
16, // 15: stillbox.TalkgroupInfo.metadata:type_name -> google.protobuf.Struct
0, // 16: stillbox.Live.state:type_name -> stillbox.LiveState
12, // 17: stillbox.Live.filter:type_name -> stillbox.Filter
11, // 18: stillbox.Filter.talkgroups:type_name -> stillbox.Talkgroup
11, // 19: stillbox.Filter.talkgroups_not:type_name -> stillbox.Talkgroup
20, // [20:20] is the sub-list for method output_type
20, // [20:20] is the sub-list for method input_type
20, // [20:20] is the sub-list for extension type_name
20, // [20:20] is the sub-list for extension extendee
0, // [0:20] is the sub-list for field type_name
}
func init() { file_stillbox_proto_init() }
@ -1364,7 +1383,7 @@ func file_stillbox_proto_init() {
}
}
file_stillbox_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Response); i {
switch v := v.(*CommandResponse); i {
case 0:
return &v.state
case 1:
@ -1521,6 +1540,7 @@ func file_stillbox_proto_init() {
}
}
file_stillbox_proto_msgTypes[0].OneofWrappers = []interface{}{
(*Message_Response)(nil),
(*Message_Call)(nil),
(*Message_Notification)(nil),
(*Message_Popup)(nil),
@ -1528,7 +1548,7 @@ func file_stillbox_proto_init() {
(*Message_Hello)(nil),
}
file_stillbox_proto_msgTypes[1].OneofWrappers = []interface{}{
(*Response_TgInfo)(nil),
(*CommandResponse_TgInfo)(nil),
}
file_stillbox_proto_msgTypes[2].OneofWrappers = []interface{}{}
file_stillbox_proto_msgTypes[7].OneofWrappers = []interface{}{

View file

@ -7,15 +7,16 @@ import "google/protobuf/struct.proto";
message Message {
oneof toClient_message {
Call call = 1;
Notification notification = 2;
UserPopup popup = 3;
Error error = 4;
Hello hello = 5;
CommandResponse response = 1;
Call call = 2;
Notification notification = 3;
UserPopup popup = 4;
Error error = 5;
Hello hello = 6;
}
}
message Response {
message CommandResponse {
optional int64 command_id = 1;
oneof command_response {
TalkgroupInfo tg_info = 2;