コード例 #1
0
        public static Frame CreateConnect(
            string acceptVersion,
            string host = null,
            string login = null,
            string passcode = null,
            Heartbeat heartbeat = null,
            IEnumerable<KeyValuePair<string, string>> extraHeaders = null)
        {
            // This should be commented when multiversion is implemented.
            if (host == null)
                throw new ArgumentNullException("host");

            var headers = new List<KeyValuePair<string, string>>(5);
            headers.Add(new KeyValuePair<string, string>(StompHeaders.AcceptVersion, acceptVersion));
            /*if (host != null)*/ headers.Add(new KeyValuePair<string, string>(StompHeaders.Host, host));
            if (login != null) headers.Add(new KeyValuePair<string, string>(StompHeaders.Login, login));
            if (passcode != null) headers.Add(new KeyValuePair<string, string>(StompHeaders.Passcode, passcode));
            if (heartbeat != null) headers.Add(new KeyValuePair<string, string>(StompHeaders.Heartbeat, heartbeat.RawHeartbeat));

            return new Frame(StompCommands.Connect, extraHeaders == null ? headers : headers.Concat(extraHeaders));
        }
コード例 #2
0
 public static Task WriteConnectAsync(
     this IStompFrameWriter writer,
     string host = null,
     string login = null,
     string passcode = null,
     Heartbeat heartbeat = null,
     IEnumerable<KeyValuePair<string, string>> extraHeaders = null,
     CancellationToken? cancellationToken = null)
 {
     CancellationToken cancelToken = cancellationToken ?? CancellationToken.None;
     Frame frame = StompFrameFactory.CreateConnect(writer.ProtocolVersion, host, login, passcode, heartbeat, extraHeaders);
     return writer.WriteAsync(frame, cancelToken);
 }