Example #1
0
// Internal control command.
// DelSlot deletes one slot data.
func (c *CtrlContext) DelSlot(slotId uint16) error {
	call := c.cli.newCall(proto.CmdDelSlot, nil)
	if call.err != nil {
		return call.err
	}

	var p ctrl.PkgDelSlot
	p.SlotId = slotId

	pkg, err := ctrl.Encode(call.cmd, c.dbId, call.seq, &p)
	if err != nil {
		c.cli.errCall(call, err)
		return call.err
	}

	call.pkg = pkg
	c.cli.sending <- call

	r, err := (<-call.Done).Reply()
	if err != nil {
		return call.err
	}

	t := r.(*ctrl.PkgDelSlot)
	if t.ErrMsg != "" {
		return errors.New(t.ErrMsg)
	}
	return nil
}