Esempio n. 1
0
        public Interfaces.ICommand <byte> Decode(ArraySegment <byte> input)
        {
            if (input.Count != 0)
            {
                Helpers.ArraySegmentStream segstream = new Helpers.ArraySegmentStream(input);
                int size = segstream.GetInt32();
                if (input.Count == size)
                {
                    int code = segstream.GetInt16();
                    if (code == Code | code == Code + 1)
                    {
                        var    strlen   = segstream.GetInt32();
                        var    hashcode = segstream.GetInt64();
                        string s        = null;
                        if (code == Code + 1)
                        {
                            s = segstream.GetUnicode(strlen);
                        }
                        else
                        {
                            s = segstream.GetASCII(strlen);
                        }

                        return(new SendString(s));
                    }
                }
            }
            return(null);
        }
Esempio n. 2
0
 public Interfaces.ICommand <byte> Decode(ArraySegment <byte> input)
 {
     if (input.Count != 0)
     {
         Helpers.ArraySegmentStream segstream = new Helpers.ArraySegmentStream(input);
         int size = segstream.GetInt32();
         if (input.Count == size)
         {
             short code = segstream.GetInt16();
             if (code == Code)
             {
                 var function = segstream.GetInt64();
                 var thread   = segstream.GetInt64();
                 var term     = segstream.GetInt16();
                 if (term != 0)
                 {
                     throw new System.Runtime.Serialization.SerializationException("Terminator is a non zero value. Please check the incoming byte stream for possible errors.");
                 }
                 return(new FunctionsToProfile(new List <string>()));
             }
             else
             {
                 throw new System.Runtime.Serialization.SerializationException("Invalid command code detected. Please check the incoming byte stream for possible errors.");
             }
         }
         else
         {
             throw new System.Runtime.Serialization.SerializationException("Size of message does not match size of byte stream. Please check the incoming byte stream for possible errors.");
         }
     }
     else
     {
         throw new System.Runtime.Serialization.SerializationException("Size of message is zero. Please check the incoming byte stream for possible errors. ");
     }
 }
Esempio n. 3
0
        public Interfaces.ICommand <byte> Decode(ArraySegment <byte> input)
        {
            if (input.Count != 0)
            {
                Helpers.ArraySegmentStream segstream = new Helpers.ArraySegmentStream(input);
                int size = segstream.GetInt32();
                if (input.Count == size)
                {
                    short code = segstream.GetInt16();
                    if (code == Code)
                    {
                        var decodeAgentCapabilities = (Capabilities)segstream.GetInt32();

                        var decodeAgentMajor       = segstream.GetByte();
                        var decodeAgentMinor       = segstream.GetByte();
                        var decodeAgentIncremental = segstream.GetByte();

                        var stringlenmachineName  = segstream.GetInt32();
                        var decodeMachineNameHash = segstream.GetInt32();
                        var decodeMachineName     = segstream.GetUnicode(stringlenmachineName);

                        var stringlen           = segstream.GetInt32();
                        var decodeAgentNameHash = segstream.GetInt32();
                        var decodeAgentName     = segstream.GetUnicode(stringlen);
                        var term = segstream.GetInt16();
                        if (term != 0)
                        {
                            throw new System.Runtime.Serialization.SerializationException("Terminator is a non zero value. Please check the incoming byte stream for possible errors.");
                        }
                        return(new AgentInformation(decodeAgentCapabilities, decodeAgentMajor, decodeAgentMinor, decodeAgentIncremental, decodeAgentName, decodeAgentNameHash, decodeMachineName, decodeMachineNameHash));
                    }
                    else
                    {
                        throw new System.Runtime.Serialization.SerializationException("Invalid command code detected. Please check the incoming byte stream for possible errors.");
                    }
                }
                else
                {
                    throw new System.Runtime.Serialization.SerializationException("Size of message does not match size of byte stream. Please check the incoming byte stream for possible errors.");
                }
            }
            else
            {
                throw new System.Runtime.Serialization.SerializationException("Size of message is zero. Please check the incoming byte stream for possible errors. ");
            }
        }