Signals disconnection. If no endpoint is specified, disconnects the entire socket.
Disconnect a socket connected to the /test endpoint: 0::/test
Inheritance: Message
        public static DisconnectMessage Deserialize(string rawMessage)
        {
            DisconnectMessage msg = new DisconnectMessage();
            //  0::
            //  0::/test
            msg.RawMessage = rawMessage;

            string[] args = rawMessage.Split(SPLITCHARS, 3);
            if (args.Length == 3)
            {
                if (!string.IsNullOrWhiteSpace(args[2]))
                    msg.Endpoint = args[2];
            }
            return msg;
        }
Beispiel #2
0
        public static IMessage Factory(string rawMessage)
        {
            if (reMessageType.IsMatch(rawMessage))
            {
                char id = rawMessage.First();
                switch (id)
                {
                case '0':
                    return(DisconnectMessage.Deserialize(rawMessage));

                case '1':
                    return(ConnectMessage.Deserialize(rawMessage));

                case '2':
                    return(new Heartbeat());

                case '3':
                    return(TextMessage.Deserialize(rawMessage));

                case '4':
                    return(JSONMessage.Deserialize(rawMessage));

                case '5':
                    return(EventMessage.Deserialize(rawMessage));

                case '6':
                    return(AckMessage.Deserialize(rawMessage));

                case '7':
                    return(ErrorMessage.Deserialize(rawMessage));

                case '8':
                    return(new NoopMessage());

                default:
                    Trace.WriteLine(string.Format("Message.Factory undetermined message: {0}", rawMessage));
                    return(new TextMessage());
                }
            }
            else
            {
                Trace.WriteLine(string.Format("Message.Factory did not find matching message type: {0}", rawMessage));
                return(new NoopMessage());
            }
        }
        public static DisconnectMessage Deserialize(string rawMessage)
        {
            DisconnectMessage msg = new DisconnectMessage();

            //  0::
            //  0::/test
            msg.RawMessage = rawMessage;

            string[] args = rawMessage.Split(SPLITCHARS, 3);
            if (args.Length == 3)
            {
                if (!string.IsNullOrWhiteSpace(args[2]))
                {
                    msg.Endpoint = args[2];
                }
            }
            return(msg);
        }
Beispiel #4
0
        public static IMessage Factory(string rawMessage)
        {
            if (reMessageType.IsMatch(rawMessage))
            {
                char id = rawMessage.First();
                switch (id)
                {
                case '0':
                    return(DisconnectMessage.Deserialize(rawMessage));

                case '1':
                    return(ConnectMessage.Deserialize(rawMessage));

                case '2':
                    return(new Heartbeat());

                case '3':
                    return(TextMessage.Deserialize(rawMessage));

                case '4':
                    return(null);

                case '5':
                    return(EventMessage.Deserialize(rawMessage));

                case '6':
                    return(AckMessage.Deserialize(rawMessage));

                case '7':
                    return(ErrorMessage.Deserialize(rawMessage));

                case '8':
                    return(new NoopMessage());

                default:
                    return(new TextMessage());
                }
            }
            else
            {
                return(new NoopMessage());
            }
        }
        public static DisconnectMessage Deserialize(string rawMessage)
        {
            DisconnectMessage msg = new DisconnectMessage();

            //  0::
            //  0::/test
            msg.RawMessage = rawMessage;

            IList <string> args = rawMessage.Split(Separator, 3);

            if (args.Count == 3)
            {
                if (!string.IsNullOrWhiteSpace(args[2]))
                {
                    msg.Endpoint = args[2];
                }
            }
            return(msg);
        }
Beispiel #6
0
        public static IMessage Factory(string rawMessage)
        {
            if (Check(rawMessage))
            {
                string message = rawMessage.TrimStart('0');

                return(ConnectMessage.Deserialize(message));
            }

            if (ReMessageType.IsMatch(rawMessage))
            {
                char id = rawMessage.First();
                switch (id)
                {
                case '0':
                    return(DisconnectMessage.Deserialize(rawMessage));

                case '1':
                    return(ConnectMessage.Deserialize(rawMessage));

                case '2':
                    return(new Heartbeat());

                case '3':
                    return(TextMessage.Deserialize(rawMessage));

                case '4':
                    return(JSONMessage.Deserialize(rawMessage));

                case '5':
                    return(EventMessage.Deserialize(rawMessage));

                case '6':
                    return(AckMessage.Deserialize(rawMessage));

                case '7':
                    return(ErrorMessage.Deserialize(rawMessage));

                case '8':
                    return(new NoopMessage());

                default:
                    Trace.WriteLine(string.Format("Message.Factory undetermined message: {0}", rawMessage));
                    return(new TextMessage());
                }
            }

            if (rawMessage.IndexOf("[") > 0)
            {
                // int index = rawMessage.IndexOf("[");

                return(AckMessage.Deserialize(rawMessage));
            }
            //if (rawMessage == "3")
            //{
            //    return new Heartbeat();
            //}
            else
            {
                Trace.WriteLine(string.Format("Message.Factory did not find matching message type: {0}", rawMessage));
                return(new NoopMessage());
            }
        }