Ejemplo n.º 1
0
 private static string replyGetErrorMessage(SamReply reply)
 {
     if (reply == null)
     {
         throw new ArgumentNullException("reply");
     }
     return(reply.GetErrorMessage());
 }
Ejemplo n.º 2
0
 private void privateConstructor(SamReply reply)
 {
     if (reply == null)
     {
         throw new ArgumentNullException("reply");
     }
     this.reply = reply;
 }
Ejemplo n.º 3
0
        public string SessionCreate(string style, string id, string destination = null, string options = null)
        {
            string requestString = GenerateSessionCreate(style, id, destination, options);
            string replyString   = this.Communicate(requestString);

            SamReply reply = SamReplyParser.Parse(replyString);

            return(ParseSessionStatus(reply));
        }
Ejemplo n.º 4
0
        public SamLookupResult NamingLookup(string name = null, string options = null)
        {
            string requestString = GenerateNamingLookup(name, options);
            string replyString   = this.Communicate(requestString);

            SamReply reply = SamReplyParser.Parse(replyString);

            return(ParseNamingReply(reply));
        }
Ejemplo n.º 5
0
        public SamDestination DestGenerate(string options = null)
        {
            string requestString = GenerateDestGenerate(options);
            string replyString   = this.Communicate(requestString);

            SamReply reply = SamReplyParser.Parse(replyString);

            return(ParseDestReply(reply));
        }
Ejemplo n.º 6
0
        public string HelloVersion(string minVersion, string maxVersion, string options = null)
        {
            string requestString = GenerateHelloVersion(minVersion, maxVersion, options);
            string replyString   = this.Communicate(requestString);

            SamReply reply = SamReplyParser.Parse(replyString);

            return(ParseHelloReply(reply));
        }
Ejemplo n.º 7
0
        public string StreamAcceptReadPeerName()
        {
            string replyString = this.ReadLine();

            if (replyString.IndexOf(' ') != -1)
            {
                SamReply reply = SamReplyParser.ParseReply(replyString, "STREAM", "STATUS");
                throw new SamBridgeErrorException(reply);
            }

            return(replyString);
        }
Ejemplo n.º 8
0
        public static SamReply Parse(string input)
        {
            if (input == null)
            {
                throw new ArgumentNullException("input");
            }

            string[] tokens = UnescapeAndTokenize(input);
            if (tokens.Length < 2)
            {
                throw new SamBadReplyException();
            }

            string major      = tokens[0];
            string minor      = tokens[1];
            var    parameters = new Dictionary <string, List <SamTokenValue> >();

            for (int i = 0; i != tokens.Length; ++i)
            {
                string pair = tokens[i];
                if (pair.Length == 0)
                {
                    continue;
                }

                int equalsPosition = pair.IndexOf('=');

                string key;
                string valueString;
                if (equalsPosition == -1)
                {
                    key         = pair;
                    valueString = null;
                }
                else
                {
                    key         = pair.Substring(0, equalsPosition);
                    valueString = pair.Substring(equalsPosition + 1);
                }

                if (!parameters.ContainsKey(key))
                {
                    parameters.Add(key, new List <SamTokenValue>());
                }
                parameters[key].Add(new SamTokenValue(valueString, i));
            }

            SamReply result = new SamReply(major, minor, parameters);

            return(result);
        }
Ejemplo n.º 9
0
        public void StreamForward(string id, int port, string host = null, bool?silence = null, string options = null)
        {
            bool   silenceBool   = silence ?? false;
            string requestString = GenerateStreamForward(id, port, host, silence, options);
            string replyString   = this.Communicate(requestString, silenceBool);

            if (silenceBool)
            {
                return;
            }
            SamReply reply = SamReplyParser.Parse(replyString);

            ParseStreamStatus(reply);
        }
Ejemplo n.º 10
0
        public void StreamAcceptWithoutPeerName(string id, bool?silence = null, string options = null)
        {
            bool   silenceBool   = silence ?? false;
            string requestString = GenerateStreamAccept(id, silence, options);
            string replyString   = this.Communicate(requestString, silenceBool);

            if (silenceBool)
            {
                return;
            }
            SamReply reply = SamReplyParser.Parse(replyString);

            ParseStreamStatus(reply);
        }
Ejemplo n.º 11
0
        public void StreamConnect(string id, string destination, bool?silence = null, string options = null)
        {
            bool   silenceBool   = silence ?? false;
            string requestString = GenerateStreamConnect(id, destination, silence, options);
            string replyString   = this.Communicate(requestString, silenceBool);

            if (silenceBool)
            {
                return;
            }
            SamReply reply = SamReplyParser.Parse(replyString);

            ParseStreamStatus(reply);
        }
Ejemplo n.º 12
0
 public static void ParseStreamStatus(SamReply reply)
 {
     if (reply == null)
     {
         throw new ArgumentNullException("reply");
     }
     if (!reply.Check("STREAM", "STATUS"))
     {
         throw new SamReplyMismatchException(reply);
     }
     if (reply.ResultString != SamBridgeErrorMessage.OK)
     {
         throw new SamBridgeErrorException(reply);
     }
 }
Ejemplo n.º 13
0
        public static string ParseSessionStatus(SamReply reply)
        {
            if (reply == null)
            {
                throw new ArgumentNullException("reply");
            }
            if (!reply.Check("SESSION", "STATUS"))
            {
                throw new SamReplyMismatchException(reply);
            }
            if (reply.ResultString != SamBridgeErrorMessage.OK)
            {
                throw new SamBridgeErrorException(reply);
            }

            string destination = reply.UniqueValue("DESTINATION").Value;

            return(destination);
        }
Ejemplo n.º 14
0
        public static string ParseHelloReply(SamReply reply)
        {
            if (reply == null)
            {
                throw new ArgumentNullException("reply");
            }
            if (!reply.Check("HELLO", "REPLY"))
            {
                throw new SamReplyMismatchException(reply);
            }
            if (reply.ResultString != SamBridgeErrorMessage.OK)
            {
                throw new SamBridgeErrorException(reply);
            }

            string version = reply.UniqueValue("VERSION").Value;

            return(version);
        }
Ejemplo n.º 15
0
        public static SamDestination ParseDestReply(SamReply reply)
        {
            if (reply == null)
            {
                throw new ArgumentNullException("reply");
            }
            if (!reply.Check("DEST", "REPLY"))
            {
                throw new SamReplyMismatchException(reply);
            }
            if (reply.ResultString != SamBridgeErrorMessage.OK)
            {
                throw new SamBridgeErrorException(reply);
            }

            string pubBase64  = reply.UniqueValue("PUB").Value;
            string privBase64 = reply.UniqueValue("PRIV").Value;

            return(new SamDestination(pubBase64, privBase64));
        }
Ejemplo n.º 16
0
        public static SamLookupResult ParseNamingReply(SamReply reply)
        {
            if (reply == null)
            {
                throw new ArgumentNullException("reply");
            }
            if (!reply.Check("NAMING", "REPLY"))
            {
                throw new SamReplyMismatchException(reply);
            }
            if (reply.ResultString != SamBridgeErrorMessage.OK)
            {
                throw new SamBridgeErrorException(reply);
            }

            string nameInReply = reply.UniqueValue("NAME").Value;
            string valueBase64 = reply.UniqueValue("VALUE").Value;

            return(new SamLookupResult(nameInReply, valueBase64));
        }
Ejemplo n.º 17
0
        public static SamReply ParseReply(string input, string major, string minor)
        {
            if (input == null)
            {
                throw new ArgumentNullException("input");
            }
            if (major == null)
            {
                throw new ArgumentNullException("major");
            }
            if (minor == null)
            {
                throw new ArgumentNullException("minor");
            }

            SamReply reply = Parse(input);

            if (!reply.Check(major, minor))
            {
                throw new SamReplyMismatchException(reply);
            }
            return(reply);
        }
Ejemplo n.º 18
0
 public SamReplyException(SamReply reply, string message)
     : base(message)
 {
     this.privateConstructor(reply);
 }
Ejemplo n.º 19
0
 public SamReplyException(SamReply reply)
 {
     this.privateConstructor(reply);
 }
Ejemplo n.º 20
0
 private static string replyGetErrorMessage(SamReply reply)
 {
     if (reply == null)
         throw new ArgumentNullException("reply");
     return reply.GetErrorMessage();
 }
Ejemplo n.º 21
0
 public SamBridgeErrorException(SamReply reply)
     : base(reply, replyGetErrorMessage(reply))
 {
 }
Ejemplo n.º 22
0
 public static void ParseStreamStatus(SamReply reply)
 {
     if (reply == null)
         throw new ArgumentNullException("reply");
     if (!reply.Check("STREAM", "STATUS"))
         throw new SamReplyMismatchException(reply);
     if (reply.ResultString != SamBridgeErrorMessage.OK)
         throw new SamBridgeErrorException(reply);
 }
Ejemplo n.º 23
0
        public static string ParseSessionStatus(SamReply reply)
        {
            if (reply == null)
                throw new ArgumentNullException("reply");
            if (!reply.Check("SESSION", "STATUS"))
                throw new SamReplyMismatchException(reply);
            if (reply.ResultString != SamBridgeErrorMessage.OK)
                throw new SamBridgeErrorException(reply);

            string destination = reply.UniqueValue("DESTINATION").Value;
            return destination;
        }
Ejemplo n.º 24
0
        public static SamLookupResult ParseNamingReply(SamReply reply)
        {
            if (reply == null)
                throw new ArgumentNullException("reply");
            if (!reply.Check("NAMING", "REPLY"))
                throw new SamReplyMismatchException(reply);
            if (reply.ResultString != SamBridgeErrorMessage.OK)
                throw new SamBridgeErrorException(reply);

            string nameInReply = reply.UniqueValue("NAME").Value;
            string valueBase64 = reply.UniqueValue("VALUE").Value;
            return new SamLookupResult(nameInReply, valueBase64);
        }
Ejemplo n.º 25
0
        public static string ParseHelloReply(SamReply reply)
        {
            if (reply == null)
                throw new ArgumentNullException("reply");
            if (!reply.Check("HELLO", "REPLY"))
                throw new SamReplyMismatchException(reply);
            if (reply.ResultString != SamBridgeErrorMessage.OK)
                throw new SamBridgeErrorException(reply);

            string version = reply.UniqueValue("VERSION").Value;
            return version;
        }
Ejemplo n.º 26
0
 public SamReplyMismatchException(SamReply reply, string message)
     : base(reply, message)
 {
 }
Ejemplo n.º 27
0
 private void privateConstructor(SamReply reply)
 {
     if (reply == null)
         throw new ArgumentNullException("reply");
     this.reply = reply;
 }
Ejemplo n.º 28
0
 public SamReplyMismatchException(SamReply reply) :
     base(reply)
 {
 }
Ejemplo n.º 29
0
 public SamReplyException(SamReply reply)
 {
     this.privateConstructor(reply);
 }
Ejemplo n.º 30
0
 public SamReplyMismatchException(SamReply reply, string message) :
     base(reply, message)
 {
 }
Ejemplo n.º 31
0
 public SamBridgeErrorException(SamReply reply) :
     base(reply, replyGetErrorMessage(reply))
 {
 }
Ejemplo n.º 32
0
 public SamReplyMismatchException(SamReply reply)
     : base(reply)
 {
 }
Ejemplo n.º 33
0
 public SamReplyException(SamReply reply, string message) :
     base(message)
 {
     this.privateConstructor(reply);
 }
Ejemplo n.º 34
0
        public static SamReply Parse(string input)
        {
            if (input == null)
                throw new ArgumentNullException("input");

            string[] tokens = UnescapeAndTokenize(input);
            if (tokens.Length < 2)
                throw new SamBadReplyException();

            string major = tokens[0];
            string minor = tokens[1];
            var parameters = new Dictionary<string, List<SamTokenValue>>();

            for (int i = 0; i != tokens.Length; ++i)
            {
                string pair = tokens[i];
                if (pair.Length == 0)
                    continue;

                int equalsPosition = pair.IndexOf('=');

                string key;
                string valueString;
                if (equalsPosition == -1)
                {
                    key = pair;
                    valueString = null;
                }
                else
                {
                    key = pair.Substring(0, equalsPosition);
                    valueString = pair.Substring(equalsPosition + 1);
                }

                if (!parameters.ContainsKey(key))
                    parameters.Add(key, new List<SamTokenValue>());
                parameters[key].Add(new SamTokenValue(valueString, i));
            }

            SamReply result = new SamReply(major, minor, parameters);
            return result;
        }
Ejemplo n.º 35
0
        public static SamDestination ParseDestReply(SamReply reply)
        {
            if (reply == null)
                throw new ArgumentNullException("reply");
            if (!reply.Check("DEST", "REPLY"))
                throw new SamReplyMismatchException(reply);
            if (reply.ResultString != SamBridgeErrorMessage.OK)
                throw new SamBridgeErrorException(reply);

            string pubBase64 = reply.UniqueValue("PUB").Value;
            string privBase64 = reply.UniqueValue("PRIV").Value;
            return new SamDestination(pubBase64, privBase64);
        }