/
voice.hrpc.go
28 lines (28 loc) · 1.03 KB
/
voice.hrpc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package voicev1
import (
"context"
goserver "github.com/harmony-development/hrpc/pkg/go-server"
)
type VoiceService[T context.Context] interface {
StreamMessage(T, chan *StreamMessageRequest, chan *StreamMessageResponse) error
}
type VoiceServiceHandler[T context.Context] struct {
Impl VoiceService[T]
}
func (h *VoiceServiceHandler[T]) Routes() map[string]goserver.UnaryMethodData[T] {
return map[string]goserver.UnaryMethodData[T]{
}
}
func (h *VoiceServiceHandler[T]) StreamRoutes() map[string]goserver.StreamMethodData[T] {
return map[string]goserver.StreamMethodData[T]{
"protocol.voice.v1.VoiceService/StreamMessage": {
MethodData: goserver.MethodData{Input: &StreamMessageRequest{}, Output: &StreamMessageResponse{}},
Handler: func(c T, msg chan goserver.VTProtoMessage, res chan goserver.VTProtoMessage) (error) {
ch := make(chan *StreamMessageResponse)
goserver.ToProtoChannel(ch, res)
err := h.Impl.StreamMessage(c, goserver.FromProtoChannel[*StreamMessageRequest](msg), ch)
return err
},
},
}
}