public static OperationalMessage MessageFrom(string content)
        {
            if (content.StartsWith(APP))
            {
                return(ApplicationSays.From(content));
            }

            if (content.StartsWith(DIR))
            {
                return(Directory.From(content));
            }

            if (content.StartsWith(ELECT))
            {
                return(Elect.From(content));
            }

            if (content.StartsWith(JOIN))
            {
                return(Join.From(content));
            }

            if (content.StartsWith(LEADER))
            {
                return(Leader.From(content));
            }

            if (content.StartsWith(LEAVE))
            {
                return(Leave.From(content));
            }

            if (content.StartsWith(PING))
            {
                return(Ping.From(content));
            }

            if (content.StartsWith(PULSE))
            {
                return(Pulse.From(content));
            }

            if (content.StartsWith(SPLIT))
            {
                return(Split.From(content));
            }

            if (content.StartsWith(VOTE))
            {
                return(Vote.From(content));
            }

            return(null);
        }
示例#2
0
 public static void MessageToBytes(Pulse pulse, Stream buffer) => BasicMessageToBytes(pulse, OperationalMessage.PULSE, buffer);