github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/protocol/gregor1/outgoing.go (about) 1 // Auto-generated to Go types and interfaces using avdl-compiler v1.4.10 (https://github.com/keybase/node-avdl-compiler) 2 // Input file: avdl/gregor1/outgoing.avdl 3 4 package gregor1 5 6 import ( 7 "github.com/keybase/go-framed-msgpack-rpc/rpc" 8 context "golang.org/x/net/context" 9 "time" 10 ) 11 12 type BroadcastMessageArg struct { 13 M Message `codec:"m" json:"m"` 14 } 15 16 type OutgoingInterface interface { 17 BroadcastMessage(context.Context, Message) error 18 } 19 20 func OutgoingProtocol(i OutgoingInterface) rpc.Protocol { 21 return rpc.Protocol{ 22 Name: "gregor.1.outgoing", 23 Methods: map[string]rpc.ServeHandlerDescription{ 24 "broadcastMessage": { 25 MakeArg: func() interface{} { 26 var ret [1]BroadcastMessageArg 27 return &ret 28 }, 29 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 30 typedArgs, ok := args.(*[1]BroadcastMessageArg) 31 if !ok { 32 err = rpc.NewTypeError((*[1]BroadcastMessageArg)(nil), args) 33 return 34 } 35 err = i.BroadcastMessage(ctx, typedArgs[0].M) 36 return 37 }, 38 }, 39 }, 40 } 41 } 42 43 type OutgoingClient struct { 44 Cli rpc.GenericClient 45 } 46 47 func (c OutgoingClient) BroadcastMessage(ctx context.Context, m Message) (err error) { 48 __arg := BroadcastMessageArg{M: m} 49 err = c.Cli.CallCompressed(ctx, "gregor.1.outgoing.broadcastMessage", []interface{}{__arg}, nil, rpc.CompressionGzip, 0*time.Millisecond) 50 return 51 }