예제 #1
0
파일: calculate.go 프로젝트: xh3b4sd/anna
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
}
예제 #2
0
파일: client.go 프로젝트: xh3b4sd/anna
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
}