examples: Regenerate protocol files
This commit is contained in:
@@ -57,6 +57,20 @@ func boolInt(input bool) int {
|
||||
// ensure ucontainer is always imported
|
||||
var _ hopp.Option[int]
|
||||
|
||||
// ReceivedMessage is a sealed interface representing the value of a
|
||||
// message in this package. To determine what kind of message it is,
|
||||
// use a type switch like this:
|
||||
//
|
||||
// switch message := message.(type) {
|
||||
// case MessagePing:
|
||||
// doSomething()
|
||||
// case MessagePong:
|
||||
// doSomething()
|
||||
// }
|
||||
type ReceivedMessage interface {
|
||||
isReceivedMessage()
|
||||
}
|
||||
|
||||
// Ping is sent by the client to the server. It may contain any number. This
|
||||
// number will be returned to the client via a [Pong] message.
|
||||
type MessagePing int32
|
||||
@@ -88,6 +102,7 @@ func(this *MessagePing) Decode(decoder *tape.Decoder) (n int, err error) {
|
||||
*this = MessagePing(destination_2)
|
||||
return n, nil
|
||||
}
|
||||
func (this MessagePing) isReceivedMessage() { }
|
||||
|
||||
// Pong is sent by the server to the client in response to a [Ping] message, It
|
||||
// will contain the same number as that message.
|
||||
@@ -120,10 +135,11 @@ func(this *MessagePong) Decode(decoder *tape.Decoder) (n int, err error) {
|
||||
*this = MessagePong(destination_4)
|
||||
return n, nil
|
||||
}
|
||||
func (this MessagePong) isReceivedMessage() { }
|
||||
|
||||
// Receive decodes a message from a transaction and returns it as a value.
|
||||
// Use a type switch to determine what type of message it is.
|
||||
func Receive(trans hopp.Trans) (message any, n int, err error) {
|
||||
func Receive(trans hopp.Trans) (message ReceivedMessage, n int, err error) {
|
||||
method, reader, err := trans.ReceiveReader()
|
||||
if err != nil { return nil, n, err }
|
||||
decoder := tape.NewDecoder(reader)
|
||||
|
||||
Reference in New Issue
Block a user