Exemplo n.º 1
0
        void ProcGet()
        {
            OutputManager.Ui.Write("What is the name the resource to get?");
            string resourceName = Console.ReadLine();
            string resourceId   = EZHash.GetHashString(resourceName);

            Messages.GetResourceRequest  grr         = new GetResourceRequest(this.localNode, resourceId);
            Messages.Message             tmpResponse = this.localNode.SendMessage(grr);
            Messages.GetResourceResponse rep         = new GetResourceResponse(tmpResponse.ToString());
            if (rep.resourceFoundSuccessfully)
            {
                OutputManager.Ui.Write(rep.resourceContent);
            }
            else
            {
                OutputManager.Ui.Write("A resource with that name could not be found.");
            }
        }
Exemplo n.º 2
0
        void ProcAddResource()
        {
            OutputManager.Ui.Write("What is the name of this new resouce?");
            string resourceName = Console.ReadLine();

            OutputManager.Ui.Write("What is the contents of this new resouce?");
            string resourceContent = Console.ReadLine();
            string resourceId      = EZHash.GetHashString(resourceName);

            Messages.AddResourceRequest  addResourceReq      = new AddResourceRequest(this.localNode, resourceId, resourceName, resourceContent);
            Messages.Message             tmpResponse         = localNode.SendMessage(addResourceReq);
            Messages.AddResourceResponse addResourceResponse = new AddResourceResponse(tmpResponse.ToString());
            if (addResourceResponse.resourceAddedSuccessfully)
            {
                OutputManager.Ui.Write($"The resource \"{resourceName}\" was added successfully.");
            }
            else
            {
                OutputManager.Ui.Write($"Failed to add the resource \"{resourceName}\"");
            }
        }