Ejemplo n.º 1
0
func (ch *CounterHandler) Handle(ctx context.Context, msg interface{}) (result interface{}, err error) {

	err = json.Unmarshal(msg.([]byte), &ch.C)
	if err != nil {
		return
	}
	ch.C.N++
	ch.C.S = strings.Repeat(ch.C.S, ch.C.N)
	contentByte, err := json.Marshal(ch.C)

	if err != nil {
		return
	}
	n := cherry.NodeValue(ctx)
	n.Send(cherry.NewMessage(ctx, contentByte))
	return
}
Ejemplo n.º 2
0
func echoHandler(ctx context.Context, msg interface{}) (result interface{}, err error) {
	n := cherry.NodeValue(ctx)
	n.Send(cherry.NewMessage(ctx, msg))
	return
}