Esempio n. 1
0
        /// <summary>
        /// Processes the message.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="client">The client.</param>
        private static void ProcessMessage(string message, Socket client)
        {
            Console.WriteLine($"Message Received: {message}");

            if (message == "GET")
            {
                client.Send(Encoding.ASCII.GetBytes(_service.GetLatestVersionedSetting()));
            }
            else if (message.StartsWith("GET_VER"))
            {
                var tokens = message.Split("::");
                client.Send(Encoding.ASCII.GetBytes(_service.GetVersionedSetting(int.Parse(tokens[1]))));
            }
            else if (message.StartsWith("ADD"))
            {
                var tokens = message.Split("::");
                _service.AddVersionedSetting(tokens[1]);
            }
            else if (message.StartsWith("DEL"))
            {
                var tokens = message.Split("::");
                client.Send(Encoding.ASCII.GetBytes(_service.RemoveVersionedSetting(int.Parse(tokens[1])).ToString()));
            }
            else if (message.StartsWith("UPD"))
            {
                var tokens = message.Split("::");
                _service.UpdateVersionedSetting(int.Parse(tokens[1]), tokens[2]);
            }
        }
 public string Get(int version)
 {
     return(_demonstrationServiceImplementation.GetVersionedSetting(version));
 }