/// <summary> /// /// </summary> /// <param name="et"></param> /// <param name="arg"></param> private void CompleteProcessing(EventEntry entry) { switch (entry.Type) { case EventType.IsConnecting: IsConnecting?.Invoke(this, (int)entry.Argument); break; case EventType.IsListening: IsListening?.Invoke(this, EventArgs.Empty); break; case EventType.Connected: Connected?.Invoke(this, EventArgs.Empty); break; case EventType.Disconnected: Disconnected?.Invoke(this, EventArgs.Empty); break; case EventType.Sent: Sent?.Invoke(this, ( Message )entry.Argument); break; case EventType.Received: Received?.Invoke(this, ( Message )entry.Argument); break; case EventType.T3Timeout: T3Timeout?.Invoke(this, ( Message )entry.Argument); break; default: break; } }
private void CendCompleted(object sender, SocketAsyncEventArgs args) { if (args.SocketError == SocketError.Success && args.BytesTransferred > 0) { byte[] keyBytes = new byte[16]; Array.Copy(args.Buffer, 0, keyBytes, 0, 16); Guid key = new Guid(keyBytes); byte[] lenghtBytes = new byte[4]; Array.Copy(args.Buffer, 16, lenghtBytes, 0, 4); int length = BitConverter.ToInt32(lenghtBytes); byte[] msgBytes = new byte[length]; Array.Copy(args.Buffer, 20, msgBytes, 0, args.BytesTransferred - 20); SocketMessage msg = new SocketMessage { Key = key, Body = msgBytes, Length = length }; if (Sent != null) { Sent.Invoke(this, _client, msg); } } else { Stop(); } }
public void Send() { var message = new TextMessage(InputBox.Text, DateTime.Now, UserService.LoggedUser); Sent?.Invoke(this, message); InputBox.Text = ""; }
public void SendConsole(string message) { Console.WriteLine($"Sending console {message}"); Sent?.Invoke(); SendError?.Invoke(this, new SendErrorEventArgs("brak polaczenia")); }
public void SendAll() { while (_queue.Count > 0) { var email = _queue.Dequeue(); Sent?.Invoke(email); } }
/// <summary> /// Raises the Sent event. /// </summary> internal static void OnSent(IEmailQueueItem item, MailMessage message) { if (!item.IsNew) { Database.Delete(item); } Sent?.Invoke(item, new EventArgs <MailMessage>(message)); }
private void Send(string messageType, FIXMessageWriter message, long seqNum) { message.Prepare(Configuration.Version, messageType, seqNum, Clock.Time, Configuration.Sender, Configuration.Target); Channel.Write(message); State.OutboundTimestamp = Clock.Time; Sent?.Invoke(this, message); }
public void RaiseOutgoing(ISendable target, IMessage message) { if (target == null || message == null) { return; } Log.Trace($"[OUT ({message.Attachments?.Count})] {message?.Text}"); Sent?.Invoke(this, new MessageSentEventArgs(target, message)); }
public void RaiseOutgoing(ISendable target, IMessage message) { _outgoingStopwatch.Start(); Sent?.Invoke(this, new MessageSentEventArgs(target, message)); _outgoingStopwatch.Stop(); if (_outgoingStopwatch.ElapsedMilliseconds > 100) { Debug.WriteLine($"Outgoing message bus took {_incomingStopwatch.ElapsedMilliseconds}ms!"); } _outgoingStopwatch.Reset(); }
public void Write(byte[] data, bool notifyOnSuccess = true) { try { networkStream.BeginWrite(data, 0, data.Length, EndWrite, new WriteIOState(data, notifyOnSuccess)); } catch (Exception ex) { Sent?.Invoke(this, new SentEventArgs(ex, this, data)); } }
/// <summary> /// Start an offset update if enough time has passed. /// </summary> /// <param name="server">The server peer.</param> public void Update() { if (!_pingTimer.TryCycle()) { return; } _server.Send(PingMessage.Now); Sent?.Invoke(); }
private void SendCallback(IAsyncResult ar) { try { // Retrieve the socket from the state object. Client = (Socket)ar.AsyncState; // Complete sending the data to the remote device. int bytesSent = Client.EndSend(ar); Sent?.Invoke(this, bytesSent); } catch (Exception e) { ErrorAccrued?.Invoke(this, new ErrorEventArgs(e)); } }
public void Send(string messageType, FIXMessageWriter message) { var state = State; message.Prepare(Configuration.Version, messageType, state.OutboundSeqNum, Clock.Time, Configuration.Sender, Configuration.Target); Channel.Write(message); state.OutboundSeqNum++; state.OutboundTimestamp = Clock.Time; Sent?.Invoke(this, message); }
public void SendBytes(byte[] bytes) { if (!this.Client.Connected) { return; } try { this.Client.GetStream().Write(bytes, 0, bytes.Length); } catch (IOException) { this.Disconnect(); return; } Sent?.Invoke(this, bytes); }
// This is the call back function, which will be invoked when a client is connected public void OnDataSent(IAsyncResult ar) { try { // get the data UdpClient ii = ((UdpState)ar.AsyncState).u; // stop the send call back ii.EndSend(ar); Sent?.Invoke(); } catch (Exception e) { if (isListening) { Console.WriteLine($"{this.GetType().FullName}:{e.Message}"); } } }
private void HandleLetterSent(ILetter sentLetter) { switch (sentLetter.Type) { case LetterType.Initialize: HandleInitialize(); break; case LetterType.Heartbeat: NotifyOnEmptyQueue(); break; case LetterType.Batch: case LetterType.User: Sent?.Invoke(this, sentLetter); NotifyOnEmptyQueue(); break; } }
public void SendString(string str, Encoding encoding) { if (!this.Client.Connected) { return; } try { byte[] sendingBytes = encoding.GetBytes(str); this.Client.GetStream().Write(sendingBytes, 0, sendingBytes.Length); } catch (IOException) { this.Disconnect(); return; } Sent?.Invoke(this, str); }
private void ChannelOnSent(IChannel channel, ILetter letter) { if (letter.Type == LetterType.Batch) { _sentBatch = false; for (var i = 0; i < letter.Parts.Length; i++) { Sent?.Invoke(this, _queue.Dequeue()); } } else { Sent?.Invoke(this, _queue.Dequeue()); } ChannelQueueEmpty?.Invoke(this); TrySendBatch(false); }
private void EndWrite(IAsyncResult ar) { IOState state = ar.AsyncState as WriteIOState; try { networkStream.EndWrite(ar); state.AdvancePosition(state.Size); if (state.NotifySuccess) { Sent?.Invoke(this, new SentEventArgs(this, state.Data)); } } catch (Exception ex) { Sent?.Invoke(this, new SentEventArgs(ex, this, state.Data)); } }
private void OnSend(object sender, SocketAsyncEventArgs e) { SignalResetEvent(); // Signal sent event for processing. Sent?.Invoke(this, e); if (e.SocketError != SocketError.Success) { ProcessError(e); } byte[] receiveBuffer = new byte[1024]; var receiveArgs = CreateSocketAsyncEventArgs(OnReceive); // Start receive operation. _socket.ReceiveAsync(receiveArgs); // Wait for receive operation to complete. WaitResetEvent(); }
private void OnSent(object sender, PayloadSentEventArgs args) { var message = args.Message; var id = message.ID; var packet = (Packet)message.Payload; var sentContext = _sentContexts[id]; sentContext.RetransmissionsCounts[packet.Current - 1] = args.RetransmissionsCount; if (sentContext.Total == 1) { Sent?.Invoke(this, new MessageSentEventArgs(id, sentContext.Total, sentContext.RetransmissionsCounts, args.Sent, args.Sent)); _sentContexts.Remove(id); return; } if (sentContext.Count == 0) { sentContext.FirstSent = args.Sent; } ++sentContext.Count; if (sentContext.Count != packet.Current) { Failed?.Invoke(this, new MessageSendingFailedEventArgs(id, _sequence, packet.Current, packet.Total)); _sentContexts.Remove(id); return; } if (sentContext.Count != sentContext.Total) { return; } Sent?.Invoke(this, new MessageSentEventArgs(id, sentContext.Total, sentContext.RetransmissionsCounts, sentContext.FirstSent, args.Sent)); _sentContexts.Remove(id); }
private void CendCompleted(object sender, SocketAsyncEventArgs args) { if (args.SocketError == SocketError.Success && args.BytesTransferred > 0) { byte[] keyBytes = new byte[16]; Array.Copy(args.Buffer, 0, keyBytes, 0, 16); Guid key = new Guid(keyBytes); byte[] lenghtBytes = new byte[4]; Array.Copy(args.Buffer, 16, lenghtBytes, 0, 4); int length = BitConverter.ToInt32(lenghtBytes); byte[] msgBytes = new byte[length]; Array.Copy(args.Buffer, 20, msgBytes, 0, args.BytesTransferred - 20); SocketMessage msg = new SocketMessage { Key = key, Body = msgBytes, Length = length }; if (Sent != null) { Sent.Invoke(this, args.AcceptSocket, msg); } } else { if (!args.AcceptSocket.SafeHandle.IsClosed) { if (ClientOff != null) { ClientOff.Invoke(this, args.AcceptSocket.RemoteEndPoint); } _clients.Remove(args.AcceptSocket); args.AcceptSocket.Shutdown(SocketShutdown.Both); args.AcceptSocket.Close(); } } }
/// <summary> /// Called after network sent data. /// </summary> /// <param name="sender">The sender instance.</param> /// <param name="ev">The <see cref="SentEventArgs"/> instance.</param> protected virtual void OnSent(object sender, SentEventArgs ev) => Sent?.Invoke(sender, ev);
private void ChannelSent(IChannel channel, ILetter letter) { Sent?.Invoke(letter, new SentEventArgs { Binding = channel.Binding, Socket = this, RemoteNodeId = channel.RemoteNodeId }); }
/// <summary> /// Envía un mensaje a un receptor /// </summary> public void Send(Message message) { Sent?.Invoke(this, new EventArgsSent(message)); }
/// <summary> /// Raises the Sent event. /// </summary> internal static void OnSent(IEmailQueueItem item, System.Net.Mail.MailMessage message) { Sent?.Invoke(item, new EventArgs <System.Net.Mail.MailMessage>(message)); }
protected virtual void OnSent(string command) { Sent?.Invoke(this, command); }
public void SendMessage(Message message) { Sent?.Invoke(message); }
private static void ConnectionOnSent(object sender, EventArgs e) { Sent?.Invoke(sender, e); }
public void SendMessage(Comment comment, object sender) { Sent?.Invoke(comment, sender); }