示例#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
}