Ejemplo n.º 1
0
        private void HandlePutAsset(Guid assetId, byte[] data, Request req)
        {
            if (assetId == Guid.Empty)
            {
                req.ResponseHandler(new ServerResponseMsg(ServerResponseMsg.ResponseCode.RC_ERROR, assetId, "Zero UUID not allowed."), req.Context);
                return;
            }

            StratusAsset asset;

            try {
                asset = StratusAsset.FromWHIPSerialized(data);
            }
            catch (Exception e) {
                LOG.Debug($"Exception reading data for asset {assetId}", e);
                req.ResponseHandler(new ServerResponseMsg(ServerResponseMsg.ResponseCode.RC_ERROR, assetId, "Error processing request."), req.Context);
                return;
            }

            _storageManager.StoreAsset(asset, result => {
                switch (result)
                {
                case StorageManager.PutResult.DONE:
                    req.ResponseHandler(new ServerResponseMsg(ServerResponseMsg.ResponseCode.RC_OK, assetId), req.Context);
                    break;

                case StorageManager.PutResult.DUPLICATE:
                    req.ResponseHandler(new ServerResponseMsg(ServerResponseMsg.ResponseCode.RC_ERROR, assetId, "Duplicate assets are not allowed."), req.Context);
                    break;

                default:
                    req.ResponseHandler(new ServerResponseMsg(ServerResponseMsg.ResponseCode.RC_ERROR, assetId), req.Context);
                    break;
                }
            });
        }
Ejemplo n.º 2
0
 public static void TestStratusAsset_FromWHIPSerialized_Correct()
 {
     Assert.AreEqual(STRATUS_ASSET, StratusAsset.FromWHIPSerialized(WHIP_ASSET.Serialize().data));
 }