MadNodeLock.Client 1.0.1

Install-Package MadNodeLock.Client -Version 1.0.1
dotnet add package MadNodeLock.Client --version 1.0.1
<PackageReference Include="MadNodeLock.Client" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MadNodeLock.Client --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: MadNodeLock.Client, 1.0.1"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install MadNodeLock.Client as a Cake Addin
#addin nuget:?package=MadNodeLock.Client&version=1.0.1

// Install MadNodeLock.Client as a Cake Tool
#tool nuget:?package=MadNodeLock.Client&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

MadNodeLock.Client

MadNodeLock.Client connect to a MadNodeLock resource using websocket to give you a superfast experience managing locks. MadNodeLock server is a Node.js component you can host in your favorite cloud or infrastructure (server module available soon).

Sample code.

Create a C# .NET Core console application and copy following code:

// ************************************
// ** MadNodeLock.Client sample code **
// ************************************

using System;
using System.Collections.Generic;
using MadNodeLock;

namespace Test
{
    class Program
    {

        private const string WELCOME_MSG = "L:lock U:unlock E:unlock-not-owned X:exit";
        private const string MAD_NODE_LOCK_DEV = "PutYourConnectionStringHere";

        static void Main(string[] args)
        {
            try
            {
                // Create an instance of MadNodeLocker
                MadNodeLocker locker = new MadNodeLocker(MAD_NODE_LOCK_DEV);

                // After first instance creation, you can create more instance 
                // of MadNodeLocker anywhere in your code without the need of 
                // specifying the MadNodeLock connection string again
                // and MadNodeLocker will use connection already created.
                //
                // Ej.:  MadNodeLocker locker2 = new MadLocker();

                                string lastLock =null;
                Console.WriteLine(WELCOME_MSG);
                string line;
                string resourceId = "Papas";
                while ((line = Console.ReadLine()) != "X")
                {
                    // Play with L, U, E commands on console (Lock timeout: 30")
                    // Hit X to exit
                    switch (line)
                    {
                        case "L":
                            string newLock = locker.TryToLock(resourceId);
                            if (newLock is null)
                            {
                                Console.WriteLine("Lock:"+false);
                            }
                            else
                            {
                                lastLock = newLock;
                                Console.WriteLine("Lock:" + lastLock);
                            }
                            break;
                        case "U":
                            Console.WriteLine("Unlock:" + locker.Unlock(resourceId, lastLock));
                            break;
                        case "E":
                            Console.WriteLine("Unlock:" + locker.Unlock(resourceId, "608160764744513118446744073709551607"));
                            break;
                        default:
                            Console.WriteLine(WELCOME_MSG);
                            break;
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }

    }
}

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.1 137 12/11/2020
1.0.0 185 12/11/2020