I'm trying to find a concrete example where that type is used, I can't find any on the whole internet, the documentation of the package is very advanced or doesn't give details.
It all started from trying to find an error that was "goneException" when using postToConnectionInput to a client that doesn't exist, well it's like that by default, but I thought I could find a more specific error message. That's when I got to postToConnectionOutput. How can I see it? How can I use it? Can it be used in my code example?
Note: I'm not asking about how to fix the goneException, it's an error by the way, I want to know more. Can I apply the postToConnectionOutput to my example and what would it do for me?
I mention that I don't know the language to the maximum, there are some things that I don't understand well, then I put a function that what it does is send a message to all the connected clients, everything works fine, except that I INTENTIONALLY put an ID that doesn't exist, and I would like to know if I can get more information about what happens, not just a "goneException" Can postToConnectionOutput be used, what would it be for? I also leave below the types of goolang and the associated documentation.
My code, use postToConnectionInput:
All errors: goneException (correct!) ¿I can see more with postToConnectionOutput What does postToConnectionOutput? and And how is it implemented?
https://pkg.go.dev/github.com/aws/aws-sdk-go-v2/service/apigatewaymanagementapi#PostToConnectionInput
I don't understand what the function of postToConnectionOutput is and how it is implemented, I tried, I searched many places, I couldn't. Can postToConnectionOutput be applied to my code? What good would it do me? What do I do with that?
Thank you very much if someone could explain or tell me, or give me an example, or what it is for. Grateful.
func sendAll(r events.APIGatewayWebsocketProxyRequest) (interface{}, error) {
idCon := r.RequestContext.ConnectionID
cantidadClientes := strconv.Itoa(len(ListaClientes))
fmt.Println("sendAll ejecutada, ID DE CONEXIÓN (emisor): ", idCon, "cantidad de clientes: ["+cantidadClientes+"]")
mensaje := "Este es un mensaje para todos"
mySession := session.Must(session.NewSession())
api := apigatewaymanagementapi.New(mySession, aws.NewConfig().WithEndpoint("xxxxxxxxxxxxxxxxxxxxx"))
for _, idcliente := range ListaClientes {
structRes := &apigatewaymanagementapi.PostToConnectionInput{
ConnectionId: aws.String(idcliente),
Data: []byte(mensaje),
}
_, err := api.PostToConnection(structRes)
if err != nil {
fmt.Println("WARNING, sendAll(), idconexión: ["+idcliente+"]->", err, "<-")
if awsErr, ok := err.(awserr.Error); ok {
log.Println("Error:", awsErr.Code(), awsErr.Message())
log.Println("Error:", awsErr)
fmt.Println("ee: ", errors.Unwrap(awsErr))
if origErr := errors.Unwrap(awsErr); origErr != nil {
fmt.Println(origErr)
}
}
x := fmt.Errorf("%w", err)
fmt.Println(x)
fmt.Println(fmt.Printf("%v", x))
var gne *apitypes.GoneException
if errors.As(err, &gne) {
log.Println("error:", gne.Error())
}
}
}
return events.APIGatewayProxyResponse{
StatusCode: 200,
}, nil
}