/// <summary> /// Initializes a new instance of the <see cref="MessageBase"/> class /// that is used for direct response messages. /// </summary> /// <param name="version">The version.</param> protected MessageBase(Version version) { Requires.NotNull(version, "version"); this.messageTransport = MessageTransport.Direct; this.version = version; this.HttpMethods = HttpDeliveryMethods.GetRequest; }
protected void btnJoinRoom_Click(object sender, EventArgs e) { try { MessageTransport objMessageTransport = new MessageTransport(); objMessageTransport._typeObject = Enums.TypeObject.NewUser; objMessageTransport.NickName = this.txtNickName.Text; if (string.IsNullOrEmpty(this.txtSala.Text)) { if (string.IsNullOrEmpty(this.lstRooms.SelectedValue)) { objMessageTransport.Room = "Home"; } else { objMessageTransport.Room = this.lstRooms.SelectedValue; } } else { objMessageTransport.Room = this.txtSala.Text; } SendInformationToServer(MessageTransportToByte(objMessageTransport)); } catch (Exception ex) { Console.WriteLine($"Error. {ex.Message}"); EscribirMensaje(ex.Message); } }
public static async Task <Device> PowerOnAsync(string liveId, int times = 5, int delay = 1000, string addressOrHostname = null) { using (var messageTransport = new MessageTransport(addressOrHostname)) { var poweronRequestMessage = new PowerOnMessage { LiveId = liveId }; for (var i = 0; i < times; i++) { await messageTransport.SendAsync(poweronRequestMessage); await Task.Delay(delay); } var presenceRequestMessage = new PresenceRequestMessage(); var response = await TaskExtensions.WithRetries(() => messageTransport.WaitForMessageAsync <PresenceResponseMessage>(pingTimeout, () => messageTransport.SendAsync(presenceRequestMessage).GetAwaiter().GetResult()), pingRetries); return(new Device(response)); } }
/// <summary> /// Initializes a new instance of the <see cref="MessageBase"/> class /// that is used for directed messages. /// </summary> /// <param name="version">The version.</param> /// <param name="messageTransport">The message transport.</param> /// <param name="recipient">The recipient.</param> protected MessageBase(Version version, MessageTransport messageTransport, Uri recipient) { this.version = version; this.messageTransport = messageTransport; this.Recipient = recipient; this.HttpMethods = HttpDeliveryMethods.GetRequest | HttpDeliveryMethods.PostRequest; }
/// <summary> /// Initializes a new instance of the <see cref="SignedMessageBase"/> class. /// </summary> /// <param name="transport">A value indicating whether this message requires a direct or indirect transport.</param> /// <param name="recipient">The URI that a directed message will be delivered to.</param> /// <param name="version">The OAuth version.</param> internal SignedMessageBase(MessageTransport transport, MessageReceivingEndpoint recipient, Version version) : base(MessageProtections.All, transport, recipient, version) { ITamperResistantOAuthMessage self = (ITamperResistantOAuthMessage)this; HttpDeliveryMethods methods = ((IDirectedProtocolMessage)this).HttpMethods; self.HttpMethod = MessagingUtilities.GetHttpVerb(methods); }
/// <summary> /// CAUTION: YOU MUST <see langword="await"/> <see cref="_InitTask"/> BEFORE USING THIS OBJECT! /// </summary> /// <param name="device"></param> /// <param name="connectResponse"></param> /// <param name="cryptoContext"></param> private SmartGlassClient( Device device, ConnectResponseMessage connectResponse, CryptoContext cryptoContext, bool connectedAuthenticated) { this.connectedAuthenticated = connectedAuthenticated; _messageTransport = new MessageTransport(device.Address.ToString(), cryptoContext); _sessionMessageTransport = new SessionMessageTransport( _messageTransport, new SessionInfo() { ParticipantId = connectResponse.ParticipantId }); _sessionMessageTransport.MessageReceived += (s, e) => { var consoleStatusMessage = e.Message as ConsoleStatusMessage; if (consoleStatusMessage != null) { CurrentConsoleStatus = new ConsoleStatus() { Configuration = consoleStatusMessage.Configuration, ActiveTitles = consoleStatusMessage.ActiveTitles }; ConsoleStatusChanged?.Invoke(this, new ConsoleStatusChangedEventArgs( CurrentConsoleStatus )); } }; _InitTask = InitializeAsync(); }
/// <summary> /// Initializes a new instance of the <see cref="SignedMessageBase"/> class. /// </summary> /// <param name="transport">A value indicating whether this message requires a direct or indirect transport.</param> /// <param name="recipient">The URI that a directed message will be delivered to.</param> internal SignedMessageBase(MessageTransport transport, MessageReceivingEndpoint recipient) : base(MessageProtections.All, transport, recipient) { ITamperResistantOAuthMessage self = (ITamperResistantOAuthMessage)this; HttpDeliveryMethods methods = ((IDirectedProtocolMessage)this).HttpMethods; self.HttpMethod = (methods & HttpDeliveryMethods.PostRequest) != 0 ? "POST" : "GET"; }
private static void DisconnetUser(string nickName) { SessionCurrent sessionDisconnect = GetSessionByNickName(nickName); MessageTransport objMessageUser = new MessageTransport(); try { objMessageUser._typeObject = Enums.TypeObject.FromServer; objMessageUser.Message = "Ud será desconectado"; sessionDisconnect.ObjSocket.Send(MessageTransportToByte(objMessageUser)); Thread.Sleep(3000); sessionDisconnect.ObjSocket.Shutdown(SocketShutdown.Both); sessionDisconnect.ObjSocket.Close(); } catch { sessionDisconnect.ObjSocket.Close(); } finally { clientSockets.Remove(sessionDisconnect); } }
public void Connect(string host, int port, Action <int> action) { if (socket != null && socket.Connected) { DisConnect(); } socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); IPEndPoint ie = new IPEndPoint(IPAddress.Parse(host), port); socket.BeginConnect(ie, (result) => { try { //记得end socket.EndConnect(result); //实际发送和接受的处理类 transport = new MessageTransport(socket); SetConnectAction(action, 0); } catch (SocketException ex) { Debug.LogError(ex.Message); SetConnectAction(action, 1); } }, socket); }
private async Task ProccessMessage() { TcpMessage requestMessage = await MessageTransport.ReadAsync(this._connectionInfo); if (requestMessage == null) { throw new Exception("Сообщение имеет некорректный формат"); } Command = requestMessage.Header.Command; bool isNeedExeLog = ServerCommands.IsNeedExeLog(Command); Stopwatch stopwatch = null; if (isNeedExeLog) { stopwatch = new Stopwatch(); stopwatch.Start(); } using (CommandContext commandContext = new CommandContext(this, requestMessage, _bufferManager)) { this._commandContext = commandContext; await CommandDispatcher.Instance.ExecuteAsync(commandContext); this._commandContext = null; } if (isNeedExeLog) { stopwatch.Stop(); ServerLog.AddFBLog(ExecuteFolder, string.Format("| {0,8} | {1,8} | {2}", Command, stopwatch.ElapsedMilliseconds, ClientAddress)); } }
private SmartGlassClient( Device device, ConnectResponseMessage connectResponse, CryptoContext cryptoContext) { _messageTransport = new MessageTransport(device.Address.ToString(), cryptoContext); _sessionMessageTransport = new SessionMessageTransport( _messageTransport, new SessionInfo() { ParticipantId = connectResponse.ParticipantId }); _sessionMessageTransport.MessageReceived += (s, e) => { var consoleStatusMessage = e.Message as ConsoleStatusMessage; if (consoleStatusMessage != null) { ConsoleStatusChanged?.Invoke(this, new ConsoleStatusChangedEventArgs( new ConsoleStatus() { Configuration = consoleStatusMessage.Configuration, ActiveTitles = consoleStatusMessage.ActiveTitles } )); } }; _sessionMessageTransport.SendAsync(new LocalJoinMessage()); _inputChannel = new DisposableAsyncLazy <InputChannel>(async() => { return(new InputChannel(await StartChannelAsync(ServiceType.SystemInput))); }); }
public void DisconnectsMessaging() { Client.Shutdown(); MessagingClient.Received(1).Dispose(); MessageTransport.Received(1).Dispose(); }
protected void btnSend_Click(object sender, EventArgs e) { try { MessageTransport messageTransport = new MessageTransport(); messageTransport._typeObject = Enums.TypeObject.NormalMessage; messageTransport.Message = this.txtMensaje.Text; SendInformationToServer(MessageTransportToByte(messageTransport)); } catch (SocketException ex) { Console.WriteLine($"Error. {ex.Message}"); EscribirMensaje(ex.Message); } catch (ObjectDisposedException ex) { Console.WriteLine($"Error. {ex.Message}"); EscribirMensaje(ex.Message); } catch (Exception ex) { Console.WriteLine($"Error. {ex.Message}"); EscribirMensaje(ex.Message); } }
/// <summary> /// CAUTION: YOU MUST <see langword="await"/> <see cref="_InitTask"/> BEFORE USING THIS OBJECT! /// </summary> /// <param name="device"></param> /// <param name="connectResponse"></param> /// <param name="cryptoContext"></param> private SmartGlassClient( Device device, ConnectResponseMessage connectResponse, CryptoContext cryptoContext) { _messageTransport = new MessageTransport(device.Address.ToString(), cryptoContext); _sessionMessageTransport = new SessionMessageTransport( _messageTransport, new SessionInfo() { ParticipantId = connectResponse.ParticipantId }); _sessionMessageTransport.ProtocolTimeoutOccured += (_, e) => ProtocolTimeoutOccured?.Invoke(this, e); _sessionMessageTransport.MessageReceived += (s, e) => { if (e.Message is ConsoleStatusMessage consoleStatusMessage) { CurrentConsoleStatus = new ConsoleStatus() { Configuration = consoleStatusMessage.Configuration, ActiveTitles = consoleStatusMessage.ActiveTitles }; ConsoleStatusChanged?.Invoke(this, new ConsoleStatusChangedEventArgs( CurrentConsoleStatus )); } }; _InitTask = InitializeAsync(); }
private static MessageTransport ByteToMessageTransport(byte[] data) { string strMessageTransport = Encoding.ASCII.GetString(data); MessageTransport objMessageTransport = JsonConvert.DeserializeObject <MessageTransport>(strMessageTransport); return(objMessageTransport); }
private void ManageMessages() { byte[] bufferTransport; if (manageArrayAll != null && manageArrayAll.Count > 0) { var man = manageArrayAll.FirstOrDefault(p => p.MessageTransport != null && p.MessageTransport._typeObject == Enums.TypeObject.ConnectedUsers); if (man != null) { man.InUse = true; bufferTransport = man.buffer; if (bufferTransport != null) { MessageTransport objMessageTransport = man.MessageTransport; if (objMessageTransport != null) { switch (objMessageTransport._typeObject) { case Enums.TypeObject.ConnectedUsers: this.grvUsers.DataSource = objMessageTransport.ConnectedUsers; this.grvUsers.DataBind(); break; } } } //manageArrayAll.Remove(man); } } }
private static byte[] MessageTransportToByte(MessageTransport messageTransport) { string strobjMessageUser = JsonConvert.SerializeObject(messageTransport); byte[] bM = Encoding.ASCII.GetBytes(strobjMessageUser); return(bM); }
private SmartGlassClient( Device device, ConnectResponseMessage connectResponse, CryptoContext cryptoContext) { Device = device; _messageTransport = new MessageTransport(device.Address.ToString(), cryptoContext); _sessionMessageTransport = new SessionMessageTransport( _messageTransport, new SessionInfo() { ParticipantId = connectResponse.ParticipantId }); _sessionMessageTransport.MessageReceived += (s, e) => { var consoleStatusMessage = e.Message as ConsoleStatusMessage; if (consoleStatusMessage != null) { CurrentConsoleStatus = new ConsoleStatus() { Configuration = consoleStatusMessage.Configuration, ActiveTitles = consoleStatusMessage.ActiveTitles }; ConsoleStatusChanged?.Invoke(this, new ConsoleStatusChangedEventArgs( CurrentConsoleStatus )); } }; _sessionMessageTransport.SendAsync(new LocalJoinMessage()).Wait(); OpenChannels().Wait(); _sessionMessageTransport.StartHeartbeat(); }
/// <summary> /// Send messages using underlying transport. /// Serializes message bodies, adds unique ids /// </summary> /// <param name="lst"></param> /// <param name="dbTran">External transaction to be used for sending messages (optional)</param> internal void SendMessages(IList <MessageContainer> lst, object dbTran) { if (lst == null || lst.Count == 0) { return; } object prevbody = null; string prevstr = null; foreach (MessageContainer mc in lst) { if (string.IsNullOrEmpty(mc.To)) { throw new Exception("Message destination missing"); } if (mc.Body == null) { throw new NullReferenceException("Message body is null"); } if (mc.From == null) { mc.From = MessageTransport.Endpoint; } if (mc.UniqueId == null || mc.UniqueId.Length == 0) { mc.UniqueId = CreateNewMessageUniqueId(); } if (mc.Body == prevbody) { mc.BodyStr = prevstr; } else { prevbody = mc.Body; StringWriter sw = new StringWriter(); MessageSerializer.Serialize(mc.Body, sw); //MessageSerializer.Serialize(mc.Body, sw); mc.BodyStr = sw.ToString(); prevstr = mc.BodyStr; } } if (Transaction.Current == null || BatchOutgoingMessagesInTransaction == false) { MessageTransport.SendBatch(lst, dbTran); } else { MessageBatchingRM rm = GetCreateMessageBatchForCurrentTransaction(); if (!rm.TransactionOpen) { throw new Exception("Transaction is not open: " + rm.TransactionId); } foreach (MessageContainer mw in lst) { rm.Messages.Add(mw); } } }
/// <summary> /// Initializes a new instance of the <see cref="MessageBase"/> class. /// </summary> /// <param name="request">The originating request.</param> /// <param name="recipient">The recipient of the directed message. Null if not applicable.</param> protected MessageBase(IDirectedProtocolMessage request, Uri recipient = null) { Contract.Requires<ArgumentNullException>(request != null); this.originatingRequest = request; this.messageTransport = request.Transport; this.version = request.Version; this.Recipient = recipient; this.HttpMethods = HttpDeliveryMethods.GetRequest; }
/// <summary> /// Initializes a new instance of the <see cref="MessageBase"/> class. /// </summary> /// <param name="request">The originating request.</param> /// <param name="recipient">The recipient of the directed message. Null if not applicable.</param> protected MessageBase(IDirectedProtocolMessage request, Uri recipient = null) { Requires.NotNull(request, "request"); this.originatingRequest = request; this.messageTransport = request.Transport; this.version = request.Version; this.Recipient = recipient; this.HttpMethods = HttpDeliveryMethods.GetRequest; }
/// <summary> /// Initializes a new instance of the <see cref="MessageBase"/> class for direct response messages. /// </summary> /// <param name="protectionRequired">The level of protection the message requires.</param> /// <param name="originatingRequest">The request that asked for this direct response.</param> protected MessageBase(MessageProtections protectionRequired, IDirectedProtocolMessage originatingRequest) { ErrorUtilities.VerifyArgumentNotNull(originatingRequest, "originatingRequest"); this.protectionRequired = protectionRequired; this.transport = MessageTransport.Direct; this.originatingRequest = originatingRequest; }
/// <summary> /// Initializes a new instance of the <see cref="MessageBase"/> class. /// </summary> /// <param name="request">The originating request.</param> /// <param name="recipient">The recipient of the directed message. Null if not applicable.</param> protected MessageBase(IDirectedProtocolMessage request, Uri recipient = null) { this.originatingRequest = request; this.messageTransport = request.Transport; this.version = request.Version; this.Recipient = recipient; this.HttpMethods = HttpDeliveryMethods.GetRequest; }
public IContainerHostClient StartContainerHost(string containerId, IContainerDirectory directory, JobObject jobObject, NetworkCredential credentials) { CopyHostToContainer(directory); var hostRunSpec = new ProcessRunSpec { ExecutablePath = directory.MapBinPath(dependencyHelper.ContainerHostExe), Arguments = new[] { containerId }, BufferedInputOutput = true, WorkingDirectory = directory.UserPath, Credentials = credentials, }; // Order here is important. // - Start the process // - Add the process to the job object // - Verify that the process is healthy // - Start the RPC message pump // // We need to ensure that the host process cannot create any new processes before // it's added to the job object. var hostProcess = processRunner.Run(hostRunSpec); jobObject.AssignProcessToJob(hostProcess.Handle); WaitForProcessToStart(hostProcess, HostProcessStartTimeout); var messageTransport = MessageTransport.Create(hostProcess.StandardOutput, hostProcess.StandardInput); var messagingClient = MessagingClient.Create(async message => { await messageTransport.PublishRequestAsync(message); }); messageTransport.SubscribeResponse(message => { messagingClient.PublishResponse(message); return(Task.FromResult(0)); }); messageTransport.SubscribeEvent(@event => { try { messagingClient.PublishEvent(@event); } catch (Exception e) { log.Log(LogLevel.Error, e.ToString(), e); } return(Task.FromResult(0)); }); var containerHostClient = new ContainerHostClient(hostProcess, messageTransport, messagingClient, jobObject); messageTransport.Start(); return(containerHostClient); }
/// <summary> /// Initializes a new instance of the <see cref="RequestBase"/> class. /// </summary> /// <param name="version">The OpenID version this message must comply with.</param> /// <param name="providerEndpoint">The OpenID Provider endpoint.</param> /// <param name="mode">The value for the openid.mode parameter.</param> /// <param name="transport">A value indicating whether the message will be transmitted directly or indirectly.</param> protected RequestBase(Version version, Uri providerEndpoint, string mode, MessageTransport transport) { Contract.Requires<ArgumentNullException>(providerEndpoint != null); Contract.Requires<ArgumentException>(!String.IsNullOrEmpty(mode)); this.Recipient = providerEndpoint; this.Mode = mode; this.Transport = transport; this.Version = version; }
/// <summary> /// Initializes a new instance of the <see cref="MessageBase"/> class for direct requests or indirect messages. /// </summary> /// <param name="protectionRequired">The level of protection the message requires.</param> /// <param name="transport">A value indicating whether this message requires a direct or indirect transport.</param> /// <param name="recipient">The URI that a directed message will be delivered to.</param> /// <param name="version">The OAuth version.</param> protected MessageBase(MessageProtections protectionRequired, MessageTransport transport, MessageReceivingEndpoint recipient, Version version) { Requires.NotNull(recipient, "recipient"); Requires.NotNull(version, "version"); this.protectionRequired = protectionRequired; this.transport = transport; this.recipient = recipient; this.Version = version; }
/// <summary> /// Initializes a new instance of the <see cref="MessageBase"/> class for direct response messages. /// </summary> /// <param name="protectionRequired">The level of protection the message requires.</param> /// <param name="originatingRequest">The request that asked for this direct response.</param> /// <param name="version">The OAuth version.</param> protected MessageBase(MessageProtections protectionRequired, IDirectedProtocolMessage originatingRequest, Version version) { Requires.NotNull(originatingRequest, "originatingRequest"); Requires.NotNull(version, "version"); this.protectionRequired = protectionRequired; this.transport = MessageTransport.Direct; this.originatingRequest = originatingRequest; this.Version = version; }
/// <summary> /// Initializes a new instance of the <see cref="MessageBase"/> class for direct response messages. /// </summary> /// <param name="protectionRequired">The level of protection the message requires.</param> /// <param name="originatingRequest">The request that asked for this direct response.</param> /// <param name="version">The OAuth version.</param> protected MessageBase(MessageProtections protectionRequired, IDirectedProtocolMessage originatingRequest, Version version) { Contract.Requires<ArgumentNullException>(originatingRequest != null); Contract.Requires<ArgumentNullException>(version != null); this.protectionRequired = protectionRequired; this.transport = MessageTransport.Direct; this.originatingRequest = originatingRequest; this.Version = version; }
/// <summary> /// Initializes a new instance of the <see cref="RequestBase"/> class. /// </summary> /// <param name="version">The OpenID version this message must comply with.</param> /// <param name="providerEndpoint">The OpenID Provider endpoint.</param> /// <param name="mode">The value for the openid.mode parameter.</param> /// <param name="transport">A value indicating whether the message will be transmitted directly or indirectly.</param> protected RequestBase(Version version, Uri providerEndpoint, string mode, MessageTransport transport) { Requires.NotNull(providerEndpoint, "providerEndpoint"); Requires.NotNullOrEmpty(mode, "mode"); this.Recipient = providerEndpoint; this.Mode = mode; this.Transport = transport; this.Version = version; }
/// <summary> /// Initializes a new instance of the <see cref="MessageBase"/> class /// that is used for directed messages. /// </summary> /// <param name="version">The version.</param> /// <param name="messageTransport">The message transport.</param> /// <param name="recipient">The recipient.</param> protected MessageBase(Version version, MessageTransport messageTransport, Uri recipient) { Contract.Requires<ArgumentNullException>(version != null); Contract.Requires<ArgumentNullException>(recipient != null); this.version = version; this.messageTransport = messageTransport; this.Recipient = recipient; this.HttpMethods = HttpDeliveryMethods.GetRequest | HttpDeliveryMethods.PostRequest; }
/// <summary> /// Initializes a new instance of the <see cref="MessageBase"/> class /// that is used for directed messages. /// </summary> /// <param name="version">The version.</param> /// <param name="messageTransport">The message transport.</param> /// <param name="recipient">The recipient.</param> protected MessageBase(Version version, MessageTransport messageTransport, Uri recipient) { Requires.NotNull(version, "version"); Requires.NotNull(recipient, "recipient"); this.version = version; this.messageTransport = messageTransport; this.Recipient = recipient; this.HttpMethods = HttpDeliveryMethods.GetRequest | HttpDeliveryMethods.PostRequest; }
/// <summary> /// Initializes a new instance of the <see cref="MessageBase"/> class for direct requests or indirect messages. /// </summary> /// <param name="protectionRequired">The level of protection the message requires.</param> /// <param name="transport">A value indicating whether this message requires a direct or indirect transport.</param> /// <param name="recipient">The URI that a directed message will be delivered to.</param> /// <param name="version">The OAuth version.</param> protected MessageBase(MessageProtections protectionRequired, MessageTransport transport, MessageReceivingEndpoint recipient, Version version) { Contract.Requires<ArgumentNullException>(recipient != null); Contract.Requires<ArgumentNullException>(version != null); this.protectionRequired = protectionRequired; this.transport = transport; this.recipient = recipient; this.Version = version; }
public async Task <IActionResult> Index(MessageModel model) { var message = new Message(model.Body, model.AuthorName); var messageTransport = new MessageTransport(message); await _bus.Publish(messageTransport); return(View()); }
/// <summary> /// Initializes a new instance of the <see cref="MessageBase"/> class for direct requests or indirect messages. /// </summary> /// <param name="protectionRequired">The level of protection the message requires.</param> /// <param name="transport">A value indicating whether this message requires a direct or indirect transport.</param> /// <param name="recipient">The URI that a directed message will be delivered to.</param> /// <param name="version">The OAuth version.</param> protected MessageBase(MessageProtections protectionRequired, MessageTransport transport, MessageReceivingEndpoint recipient, Version version) { Contract.Requires <ArgumentNullException>(recipient != null); Contract.Requires <ArgumentNullException>(version != null); this.protectionRequired = protectionRequired; this.transport = transport; this.recipient = recipient; this.Version = version; }
/// <summary> /// Initializes a new instance of the <see cref="MessageBase"/> class for direct response messages. /// </summary> /// <param name="protectionRequired">The level of protection the message requires.</param> /// <param name="originatingRequest">The request that asked for this direct response.</param> /// <param name="version">The OAuth version.</param> protected MessageBase(MessageProtections protectionRequired, IDirectedProtocolMessage originatingRequest, Version version) { Contract.Requires <ArgumentNullException>(originatingRequest != null); Contract.Requires <ArgumentNullException>(version != null); this.protectionRequired = protectionRequired; this.transport = MessageTransport.Direct; this.originatingRequest = originatingRequest; this.Version = version; }
private static void SendRooms(Socket socket) { MessageTransport objMessageTransport = new MessageTransport(); objMessageTransport._typeObject = Enums.TypeObject.Room; objMessageTransport.LstRooms = ListRooms;//new List<string>() { "Principal 1", "Principal 2", "Principal 3" }; objMessageTransport.Message = "Conectado"; socket.Send(MessageTransportToByte(objMessageTransport)); }
/// <summary> /// Initializes a new instance of the <see cref="RequestBase"/> class. /// </summary> /// <param name="version">The OpenID version this message must comply with.</param> /// <param name="providerEndpoint">The OpenID Provider endpoint.</param> /// <param name="mode">The value for the openid.mode parameter.</param> /// <param name="transport">A value indicating whether the message will be transmitted directly or indirectly.</param> protected RequestBase(Version version, Uri providerEndpoint, string mode, MessageTransport transport) { Contract.Requires <ArgumentNullException>(providerEndpoint != null); Contract.Requires <ArgumentException>(!String.IsNullOrEmpty(mode)); this.Recipient = providerEndpoint; this.Mode = mode; this.Transport = transport; this.Version = version; }
/// <summary> /// Initializes a new instance of the <see cref="RequestBase"/> class. /// </summary> /// <param name="version">The OpenID version this message must comply with.</param> /// <param name="providerEndpoint">The OpenID Provider endpoint.</param> /// <param name="mode">The value for the openid.mode parameter.</param> /// <param name="transport">A value indicating whether the message will be transmitted directly or indirectly.</param> protected RequestBase(Version version, Uri providerEndpoint, string mode, MessageTransport transport) { if (providerEndpoint == null) { throw new ArgumentNullException("providerEndpoint"); } if (String.IsNullOrEmpty(mode)) { throw new ArgumentNullException("mode"); } this.Recipient = providerEndpoint; this.Mode = mode; this.Transport = transport; this.Version = version; }
public async void PublishedEventSendsWrappedEventToTextWriter() { var outputSink = new TaskCompletionSource<string>(); var outputWriter = Substitute.For<TextWriter>(); outputWriter.When(x => x.WriteLine(Arg.Any<string>())).Do(callInfo => outputSink.SetResult(callInfo.Arg<string>())); using (var transporter = new MessageTransport(inputSource, outputWriter)) { await transporter.PublishEventAsync(new JObject(new JProperty("foo", "bar"))); string output = await outputSink.Task; Assert.Equal(@"{""content_type"":""Event"",""body"":{""foo"":""bar""}}", output); } }
public static bool TryParse(string value, out MessageTransport result) { result = default(MessageTransport); if( value=="http") result = MessageTransport.Http; else if( value=="ftp") result = MessageTransport.Ftp; else if( value=="mllp") result = MessageTransport.Mllp; else return false; return true; }
internal TestSignedDirectedMessage(MessageTransport transport) : base(transport) { }
/// <summary> /// Initializes a new instance of the <see cref="MessageBase"/> class /// that is used for direct response messages. /// </summary> /// <param name="version">The version.</param> protected MessageBase(Version version) { Contract.Requires<ArgumentNullException>(version != null); this.messageTransport = MessageTransport.Direct; this.version = version; this.HttpMethods = HttpDeliveryMethods.GetRequest; }
public MessageTransportTest() { var outputWriter = Substitute.For<TextWriter>(); transporter = new MessageTransport(inputSource, outputWriter); transporter.Start(); }
internal TestReplayProtectedMessage(MessageTransport transport) : base(transport) { }
/// <summary> /// Initializes a new instance of the <see cref="MessageBase"/> class for direct requests or indirect messages. /// </summary> /// <param name="protectionRequired">The level of protection the message requires.</param> /// <param name="transport">A value indicating whether this message requires a direct or indirect transport.</param> /// <param name="recipient">The URI that a directed message will be delivered to.</param> protected MessageBase(MessageProtections protectionRequired, MessageTransport transport, MessageReceivingEndpoint recipient) { if (recipient == null) { throw new ArgumentNullException("recipient"); } this.protectionRequired = protectionRequired; this.transport = transport; this.recipient = recipient; }
internal TestDirectedMessage(MessageTransport transport) : base(transport) { this.HttpMethods = HttpDeliveryMethods.GetRequest | HttpDeliveryMethods.PostRequest | HttpDeliveryMethods.HeadRequest; }
internal TestExpiringMessage(MessageTransport transport) : base(transport) { }
protected TestMessage(MessageTransport transport) { this.transport = transport; }
public static string ToString(MessageTransport value) { if( value==MessageTransport.Http ) return "http"; else if( value==MessageTransport.Ftp ) return "ftp"; else if( value==MessageTransport.Mllp ) return "mllp"; else throw new ArgumentException("Unrecognized MessageTransport value: " + value.ToString()); }