func (c *_Conn) onKeyGen(payload []byte) (interface{}, bool) {
	// Deserialize the payload.
	req := []types.KeyGenRequest{}
	if err := json.Unmarshal(payload, &req); err != nil {
		return types.ErrBadRequest, false
	}

	var resp []*types.KeyGenResponse
	// Use the cipher to generate the key
	for _, m := range req {
		key, err := security.GenerateKey(c.clientID.Contract(), m.Topic, m.Access())
		if err != nil {
			switch err {
			case security.ErrTargetTooLong:
				return types.ErrTargetTooLong, false
			default:
				return types.ErrServerError, false
			}
		}
		r := &types.KeyGenResponse{
			Status: 200,
			Key:    key,
			Topic:  m.Topic,
		}

		resp = append(resp, r)
	}

	// Success, return the response
	return resp, true
}
// onKeyGen processes a keygen request.
onKeyGen processes a keygen request.
// onKeyGen processes a keygen request .
func (c *_Conn) onKeyGen(payload []byte) (interface{}, bool) {
	req := []types.KeyGenRequest{}
	if err := json.Unmarshal(payload, &req); err != nil {
		return types.ErrBadRequest, false
	}
	var resp []*types.KeyGenResponse
	for _, m := range req {
		key, err := security.GenerateKey(c.clientID.Contract(), m.Topic, m.Access())
		if err != nil {
			switch err {
			case security.ErrTargetTooLong:
				return types.ErrTargetTooLong, false
			default:
				return types.ErrServerError, false
			}
		}
		r := &types.KeyGenResponse{
			Status: 200,
			Key:    key,
			Topic:  m.Topic,
		}
		resp = append(resp, r)
	}
	return resp, true
}
func ( c * _Conn ) onKeyGen ( payload [ ] byte ) ( interface { } , bool ) { req := [ ] types . KeyGenRequest { } if err := json . Unmarshal ( payload , & req ) ; err != nil { return types . ErrBadRequest , false } var resp [ ] * types . KeyGenResponse for _ , m := range req { key , err := security . GenerateKey ( c . clientID . Contract ( ) , m . Topic , m . Access ( ) ) if err != nil { switch err { case security . ErrTargetTooLong : return types . ErrTargetTooLong , false default : return types . ErrServerError , false } } r := & types . KeyGenResponse { Status : 200 , Key : key , Topic : m . Topic , } resp = append ( resp , r ) } return resp , true }
onKeyGen processes a keygen request.
onKeyGen processes a keygen request .
// Deserialize the payload. // Use the cipher to generate the key // Success, return the response