Esempio n. 1
0
func (c *clg) sendTextResponse(ctx spec.Context, informationSequence string) error {
	// Return the calculated output to the requesting client, if the
	// current CLG is the output CLG.
	newTextResponseConfig := api.DefaultTextResponseConfig()
	newTextResponseConfig.Output = informationSequence
	newTextResponse, err := api.NewTextResponse(newTextResponseConfig)
	if err != nil {
		return maskAny(err)
	}

	c.Service().TextOutput().GetChannel() <- newTextResponse

	return nil
}
Esempio n. 2
0
func (c *client) DecodeResponse(streamTextResponse *StreamTextResponse) (servicespec.TextResponse, error) {
	if streamTextResponse.Code != api.CodeData {
		return nil, maskAnyf(invalidAPIResponseError, "API response code must be %d", api.CodeData)
	}

	textResponseConfig := api.DefaultTextResponseConfig()
	textResponseConfig.Output = streamTextResponse.Data.Output
	textResponse, err := api.NewTextResponse(textResponseConfig)
	if err != nil {
		return nil, maskAny(err)
	}

	return textResponse, nil
}