public static Message ReceiveMessage(this NetMQSocket socket)
        {
            var identifier    = socket.ReceiveFrameIdentifier();
            var hmac          = socket.ReceiveFrameString();
            var headerFrame   = socket.ReceiveFrameString();
            var parentFrame   = socket.ReceiveFrameString();
            var metadataFrame = socket.ReceiveFrameString();
            var contentFrame  = socket.ReceiveFrameString();

            if (!Validator.IsValidSignature(hmac, headerFrame, parentFrame, metadataFrame, contentFrame))
            {
                return(null);
            }

            var     header = JsonConvert.DeserializeObject <Header>(headerFrame);
            Content content;

            switch (header.MessageType)
            {
            case MessageType.ExecuteRequest:
                content = JsonConvert.DeserializeObject <ExecuteRequestContent>(contentFrame);
                break;

            case MessageType.CompleteRequest:
                content = JsonConvert.DeserializeObject <CompleteRequestContent>(contentFrame);
                break;

            case MessageType.ShutDownRequest:
                content = JsonConvert.DeserializeObject <ShutdownContent>(contentFrame);
                break;

            case MessageType.KernelInfoRequest:
                content = JsonConvert.DeserializeObject <Content>(contentFrame);
                break;
            //case MessageType.ExecuteInput:
            //case MessageType.ExecuteReply:
            //case MessageType.ExecuteResult:
            //case MessageType.CompleteReply:
            //case MessageType.ShutDownReply:
            //case MessageType.KernelInfoReply:

            //case MessageType.Status:
            //case MessageType.Output:
            //case MessageType.Input:
            //case MessageType.Error:
            //case MessageType.Stream:
            default:
                Logger?.LogWarning(header.MessageType + " message not handled.");
                content = new Content();
                break;
            }

            // Update the static session
            SessionId = header.Session;

            return(new Message(header.MessageType, content, JsonConvert.DeserializeObject <Header>(parentFrame),
                               identifier, header, hmac, JsonConvert.DeserializeObject <Dictionary <string, object> >(metadataFrame)));
        }