private static string replyGetErrorMessage(SamReply reply) { if (reply == null) { throw new ArgumentNullException("reply"); } return(reply.GetErrorMessage()); }
private void privateConstructor(SamReply reply) { if (reply == null) { throw new ArgumentNullException("reply"); } this.reply = reply; }
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)); }
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)); }
public SamDestination DestGenerate(string options = null) { string requestString = GenerateDestGenerate(options); string replyString = this.Communicate(requestString); SamReply reply = SamReplyParser.Parse(replyString); return(ParseDestReply(reply)); }
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)); }
public string StreamAcceptReadPeerName() { string replyString = this.ReadLine(); if (replyString.IndexOf(' ') != -1) { SamReply reply = SamReplyParser.ParseReply(replyString, "STREAM", "STATUS"); throw new SamBridgeErrorException(reply); } return(replyString); }
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); }
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); }
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); }
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); }
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); } }
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); }
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); }
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)); }
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)); }
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); }
public SamReplyException(SamReply reply, string message) : base(message) { this.privateConstructor(reply); }
public SamReplyException(SamReply reply) { this.privateConstructor(reply); }
private static string replyGetErrorMessage(SamReply reply) { if (reply == null) throw new ArgumentNullException("reply"); return reply.GetErrorMessage(); }
public SamBridgeErrorException(SamReply reply) : base(reply, replyGetErrorMessage(reply)) { }
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); }
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; }
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); }
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; }
public SamReplyMismatchException(SamReply reply, string message) : base(reply, message) { }
private void privateConstructor(SamReply reply) { if (reply == null) throw new ArgumentNullException("reply"); this.reply = reply; }
public SamReplyMismatchException(SamReply reply) : base(reply) { }
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; }
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); }