예제 #1
0
 private static string replyGetErrorMessage(SamReply reply)
 {
     if (reply == null)
     {
         throw new ArgumentNullException("reply");
     }
     return(reply.GetErrorMessage());
 }
예제 #2
0
 private void privateConstructor(SamReply reply)
 {
     if (reply == null)
     {
         throw new ArgumentNullException("reply");
     }
     this.reply = reply;
 }
예제 #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));
        }
예제 #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));
        }
예제 #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));
        }
예제 #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));
        }
예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #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);
     }
 }
예제 #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);
        }
예제 #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);
        }
예제 #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));
        }
예제 #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));
        }
예제 #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);
        }
예제 #18
0
 public SamReplyException(SamReply reply, string message)
     : base(message)
 {
     this.privateConstructor(reply);
 }
예제 #19
0
 public SamReplyException(SamReply reply)
 {
     this.privateConstructor(reply);
 }
예제 #20
0
 private static string replyGetErrorMessage(SamReply reply)
 {
     if (reply == null)
         throw new ArgumentNullException("reply");
     return reply.GetErrorMessage();
 }
예제 #21
0
 public SamBridgeErrorException(SamReply reply)
     : base(reply, replyGetErrorMessage(reply))
 {
 }
예제 #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);
 }
예제 #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;
        }
예제 #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);
        }
예제 #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;
        }
예제 #26
0
 public SamReplyMismatchException(SamReply reply, string message)
     : base(reply, message)
 {
 }
예제 #27
0
 private void privateConstructor(SamReply reply)
 {
     if (reply == null)
         throw new ArgumentNullException("reply");
     this.reply = reply;
 }
예제 #28
0
 public SamReplyMismatchException(SamReply reply) :
     base(reply)
 {
 }
예제 #29
0
 public SamReplyException(SamReply reply)
 {
     this.privateConstructor(reply);
 }
예제 #30
0
 public SamReplyMismatchException(SamReply reply, string message) :
     base(reply, message)
 {
 }
예제 #31
0
 public SamBridgeErrorException(SamReply reply) :
     base(reply, replyGetErrorMessage(reply))
 {
 }
예제 #32
0
 public SamReplyMismatchException(SamReply reply)
     : base(reply)
 {
 }
예제 #33
0
 public SamReplyException(SamReply reply, string message) :
     base(message)
 {
     this.privateConstructor(reply);
 }
예제 #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;
        }
예제 #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);
        }