public MarketClient(Client client) { this._client = client; if (client.ipMode == IPMode.TCP) { _dataAssembler.MaxMessageDelay = 200; _dataAssembler.MaxMessageLength = 65536; _dataAssembler.WriteMessage += WriteWithTCP; } else { _dataAssembler.MaxMessageDelay = 200; _dataAssembler.MaxMessageLength = client.mtu; _dataAssembler.WriteMessage += WriteWithUDP; } _sendMethod = _dataAssembler.Serialize; _endPoint = new IPEndPoint(ResolveHostOrAddress(client.host), client.port); _market = new MarketData[Symbols.SYMBOLS.Length]; for (int i = 0; i < _market.Length; i++) { _market[i] = new MarketData(Symbols.SYMBOLS[i], Symbols.NextPrice(10), Symbols.NextVolume(10)); } Console.WriteLine("MarketData with {0} symbols", _market.Length); }
public ClientRuntimeChannel(ClientRuntime runtime, ContractDescription contract, TimeSpan openTimeout, TimeSpan closeTimeout, IChannel contextChannel, IChannelFactory factory, MessageVersion messageVersion, EndpointAddress remoteAddress, Uri via) { this.runtime = runtime; this.remote_address = remoteAddress; runtime.Via = via; this.contract = contract; this.message_version = messageVersion; default_open_timeout = openTimeout; default_close_timeout = closeTimeout; _processDelegate = new ProcessDelegate(Process); requestDelegate = new RequestDelegate(Request); sendDelegate = new SendDelegate(Send); // default values AllowInitializationUI = true; OperationTimeout = TimeSpan.FromMinutes(1); if (contextChannel != null) { channel = contextChannel; } else { var method = factory.GetType().GetMethod("CreateChannel", new Type [] { typeof(EndpointAddress), typeof(Uri) }); channel = (IChannel)method.Invoke(factory, new object [] { remote_address, Via }); this.factory = factory; } }
public static ZPollItem Create(ReceiveDelegate receiveMessage, SendDelegate sendMessage) { var pollItem = new ZPollItem((receiveMessage != null ? ZPoll.In : ZPoll.None) | (sendMessage != null ? ZPoll.Out : ZPoll.None)); pollItem.ReceiveMessage = receiveMessage; pollItem.SendMessage = sendMessage; return pollItem; }
public IAsyncResult SendWithDelay(string pId, Delegate v, params object[] parameters) { send = SendDelay; IAsyncResult asyncResult = send.BeginInvoke(pId, v, parameters, null, null); return(asyncResult); }
public static ZPollItem Create(ReceiveDelegate receiveMessage, SendDelegate sendMessage) { var pollItem = new ZPollItem((receiveMessage != null ? ZPollEvent.In : ZPollEvent.None) | (sendMessage != null ? ZPollEvent.Out : ZPollEvent.None)); pollItem.ReceiveMessage = receiveMessage; pollItem.SendMessage = sendMessage; return(pollItem); }
private async void writeAsync() { Monitor.Enter(mSendArrayListLock); mIsSend = true; Monitor.Exit(mSendArrayListLock); var sendDelegate = new SendDelegate(write); await Task.Factory.FromAsync(sendDelegate.BeginInvoke, sendDelegate.EndInvoke, null); }
public bool Emit <T>(SendDelegate doSend, string bucketname, int value) where T : IBucket { BufferedStrategy.doSend = doSend; buffer.Accumulate <T>(bucketname, value); return(true); }
public bool Emit <T>(SendDelegate doSend, string bucketname, int value) where T : IBucket { T bucket = (T)Activator.CreateInstance(typeof(T)); bucket.Name = bucketname; bucket.Infuse(value); return(doSend(bucket.ToString())); }
public static void Send(string content) { SendDelegate sendDelegate = null; sendDelegate += SendSms; sendDelegate += SendPost; sendDelegate.Invoke(content); }
/// <summary> /// 构造函数 /// </summary> public DoubleChannelClient() { isOpen = false; connectDelegate = Connect; sendByChannel1Delegate = SendByChannel1; sendByChannel2Delegate = SendByChannel2; receiveByChannel1Delegate = ReceiveByChannel1; receiveByChannel2Delegate = ReceiveByChannel2; }
public ContactItem(byte[] byteToken, string name, double balance, SendDelegate dSend) { InitializeComponent(); AccName.Content = name; AccToken.Content = MainWindow.ByteArrToString(byteToken); Balance.Content = balance.ToString(); onSending += onSending; _pubToken = byteToken; _name = name; }
public ClientRuntimeChannel(System.ServiceModel.Dispatcher.ClientRuntime runtime, ContractDescription contract, TimeSpan openTimeout, TimeSpan closeTimeout, IChannel contextChannel, IChannelFactory factory, MessageVersion messageVersion, System.ServiceModel.EndpointAddress remoteAddress, Uri via) { if (runtime == null) { throw new ArgumentNullException("runtime"); } if (messageVersion == null) { throw new ArgumentNullException("messageVersion"); } this.runtime = runtime; this.remote_address = remoteAddress; if (runtime.Via == null) { runtime.Via = via ?? (remote_address != null ? remote_address.Uri : null); } this.contract = contract; this.message_version = messageVersion; default_open_timeout = openTimeout; default_close_timeout = closeTimeout; _processDelegate = new ProcessDelegate(Process); requestDelegate = new RequestDelegate(Request); sendDelegate = new SendDelegate(Send); AllowInitializationUI = true; if (contextChannel != null) { channel = contextChannel; } else { var method = factory.GetType().GetMethod("CreateChannel", new Type[] { typeof(System.ServiceModel.EndpointAddress), typeof(Uri) }); try { channel = (IChannel)method.Invoke(factory, new object[] { remote_address, Via }); this.factory = factory; } catch (System.Reflection.TargetInvocationException ex) { if (ex.InnerException != null) { throw ex.InnerException; } else { throw; } } } }
/// <summary> /// 构造函数 /// </summary> /// <param name="channelHandler">通道的数据包处理器</param> /// <param name="monitor">数据包处理器监测器</param> internal SingleChannelClient(IPacketHandler channelHandler, IPacketMonitor monitor) { this.channelHandler = channelHandler; isOpen = true; key = channelHandler.Key; iv = channelHandler.IV; this.monitor = monitor; connectDelegate = Connect; sendDelegate = Send; receiveDelegate = Receive; }
/// <summary> /// Ends the send (asynchronous mode). See the example in the class comment /// for an example on how to use this. /// </summary> /// <param name="ar">The ar.</param> public void EndSend(IAsyncResult ar) { SendDelegate sendDelegate = ((System.Runtime.Remoting.Messaging.AsyncResult)ar).AsyncDelegate as SendDelegate; if (sendDelegate != null) { sendDelegate.EndInvoke(ar); } else { throw new InvalidOperationException("cannot end invoke, asynchresult is null"); } }
/// <summary> /// 构造函数 /// </summary> /// <param name="channelHandler1">通道1的数据包处理器</param> /// <param name="channelHandler2">通道2的数据包处理器</param> /// <param name="monitor">数据包处理器监测器</param> internal DoubleChannelClient(IPacketHandler channelHandler1, IPacketHandler channelHandler2, IPacketMonitor monitor) { this.channelHandler1 = channelHandler1; this.channelHandler2 = channelHandler2; isOpen = true; key = channelHandler1.Key; iv = channelHandler1.IV; this.monitor = monitor; connectDelegate = Connect; sendByChannel1Delegate = SendByChannel1; sendByChannel2Delegate = SendByChannel2; receiveByChannel1Delegate = ReceiveByChannel1; receiveByChannel2Delegate = ReceiveByChannel2; }
public bool Emit <T>(SendDelegate doSend, string bucketname, int value, string message) where T : IBucket { GeyserStrategy.doSend = doSend; buffer.Accumulate <T>(bucketname, value, message); if (!schedule.Enabled) { schedule.Interval = this.Interval; schedule.Start(); } return(true); }
public Class_CommTCP(IPEndPoint iep, Encoding enc, Form _FM, TextBox _tb) { FM = _FM; tb = _tb; IPE = iep; ENC = enc; SendDelegate SD_Send = delegate(object o, OnEventArgs oea) { }; soc = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); soc.ReceiveTimeout = 3600000; soc.Bind(IPE); soc.Listen(50); var tM = new Thread(new ThreadStart(Round)); tM.Start(); }
public override IMidiOutput CreateVirtualInputSender(PortCreatorContext context) { var seq = new AlsaSequencer(AlsaIOType.Duplex, AlsaIOMode.NonBlocking); var portNumber = seq.CreateSimplePort( context.PortName ?? "managed-midi virtual in", AlsaMidiAccess.virtual_input_connected_cap, AlsaMidiAccess.midi_port_type); seq.SetClientName(context.ApplicationName ?? "managed-midi input port creator"); var port = seq.GetPort(seq.CurrentClientId, portNumber); var details = new AlsaMidiPortDetails(port); SendDelegate send = (buffer, start, length, timestamp) => seq.Send(portNumber, buffer, start, length); return(new SimpleVirtualMidiOutput(details, () => seq.DeleteSimplePort(portNumber)) { OnSend = send }); }
/// <summary> /// Odosle spravu. Ak sa spravu nepodari odoslat a je aktivovane 'AutoRepeat' sprava bude opakovane odosielana /// v pravidelnych intervaloch. Platnost spravy definuje 'ValidityInterval' /// </summary> /// /// <exception cref="ArgumentException"> /// Chyba vstupneho argumentu. Sprava neobsahuje potrebne udaje /// </exception> /// <exception cref="ArgumentNullException"> /// Chyba chybnej inicializacie spravy alebo jej poloziek /// </exception> /// <exception cref="InvalidOperationException"> /// Snaha o odoslanie spravy ak modul nebol spusteny /// </exception> /// /// <param name="message">Sprava ktoru chceme odoslat</param> /// <returns>True = sprava bola uspesne odoslana</returns> public void SendAsync(MailMessage message) { //ak uz bola vrstva spustena if (this.ClientState != ClientStates.Start) { throw new InvalidOperationException("Invalid operation."); } //osetrenie vstupneho argumentu if (message == null) { throw new ArgumentNullException("message", "Message cannot be null."); } if (message.To.Count == 0) { throw new ArgumentException("message", "Message.To must be entered."); } if (message.From == null) { throw new ArgumentNullException("message", "Message.From cannot be null."); } if (String.IsNullOrEmpty(message.Subject)) { throw new ArgumentException("message", "Message.Subject must be entered."); } if (String.IsNullOrEmpty(message.Body)) { throw new ArgumentException("message", "Message.Body must be entered."); } //zalogujeme this.InternalTrace(TraceTypes.Verbose, "Poziadavka na asynchronne odoslanie spravy. {0}", message.Subject); //pomocny delegat SendDelegate sendDelegate = new SendDelegate(this.Send); sendDelegate.BeginInvoke(message, null, null); }
public MainWindow() { InitializeComponent(); _refreshDelegate = delegate { string position = Me.Margin.Left + " " + Me.Margin.Top; Cl.SendAsync(position); // OH MY GOD! ! ! ! if (Info.Content.ToString().Contains('|') && Info.Content.ToString().Contains(':')) { string[] playersInfo = Info.Content.ToString().Split('|')[1].Split(':'); var playersId = new List<int>(); foreach (var s in playersInfo) { try { playersId.Add(Convert.ToInt32(s.Split(' ')[0])); if (_mapPlayers.ContainsKey(Convert.ToInt32(s.Split(' ')[0]))) { _mapPlayers[Convert.ToInt32(s.Split(' ')[0])].Margin = new Thickness(Convert.ToInt32(s.Split(' ')[1]), Convert.ToInt32(s.Split(' ')[2]), 0, 0); } else if (s.Split(' ')[0] != Info.Content.ToString().Split('|')[0]) { Button playerButton = new Button { Width = 40, Height = 40, HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top, Background = Brushes.Red, Margin = new Thickness(Convert.ToInt32(s.Split(' ')[1]), Convert.ToInt32(s.Split(' ')[2]), 0, 0), Content = "#" + Convert.ToInt32(s.Split(' ')[0]) }; playerButton.IsEnabled = true; _mapPlayers.Add(Convert.ToInt32(s.Split(' ')[0]), playerButton); MainGrid.Children.Add(_mapPlayers[Convert.ToInt32(s.Split(' ')[0])]); } } catch { } } List<int> blablabla = new List<int>(); foreach (var mapPlayer in _mapPlayers.Keys) { blablabla.Add(mapPlayer); } foreach (var bla in blablabla) { if (!playersId.Contains(bla)) { _mapPlayers[bla].Width = 0; _mapPlayers.Remove(bla); } } } }; Cl = new Client(this, Info); Cl.ConnectAsync("127.0.0.1", 4578); Thread m = new Thread(Refresh); m.Start(); }
/// <summary> /// Send the MailMessage /// </summary> /// <param name="eMail">MailMessage to send</param> public void Send(MailMessage eMail) { SendDelegate sd = new SendDelegate(SendEmail); AsyncCallback cb = new AsyncCallback(finishSend); IAsyncResult ar = sd.BeginInvoke(eMail, cb, sd); }
public static ZPollItem CreateSender(SendDelegate sendMessage) { return Create(null, sendMessage); }
public static ZPollItem CreateSender(SendDelegate sendMessage) { return(Create(null, sendMessage)); }
/// <summary> /// Begins sending the files in <see cref="StorageInstanceList"/> in asynchronous mode. See the example in the class comment /// for an example on how to use this. /// </summary> /// <param name="callback">The callback.</param> /// <param name="asyncState">State of the async.</param> /// <returns></returns> public IAsyncResult BeginSend(AsyncCallback callback, object asyncState) { SendDelegate sendDelegate = Send; return(sendDelegate.BeginInvoke(callback, asyncState)); }
internal NetworkSimulator(SimulatorConfig config, SendDelegate sendDelegate) { this.config = config; this.sendDelegate = sendDelegate; }
private async void writeAsync() { mIsSend = true; var sendDelegate = new SendDelegate(write); await Task.Factory.FromAsync(sendDelegate.BeginInvoke, sendDelegate.EndInvoke, null); }
public MainWindow() { InitializeComponent(); _refreshDelegate = delegate { string position = Me.Margin.Left + " " + Me.Margin.Top; Cl.SendAsync(position); // OH MY GOD! ! ! ! if (Info.Content.ToString().Contains('|') && Info.Content.ToString().Contains(':')) { string[] playersInfo = Info.Content.ToString().Split('|')[1].Split(':'); var playersId = new List <int>(); foreach (var s in playersInfo) { try { playersId.Add(Convert.ToInt32(s.Split(' ')[0])); if (_mapPlayers.ContainsKey(Convert.ToInt32(s.Split(' ')[0]))) { _mapPlayers[Convert.ToInt32(s.Split(' ')[0])].Margin = new Thickness(Convert.ToInt32(s.Split(' ')[1]), Convert.ToInt32(s.Split(' ')[2]), 0, 0); } else if (s.Split(' ')[0] != Info.Content.ToString().Split('|')[0]) { Button playerButton = new Button { Width = 40, Height = 40, HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top, Background = Brushes.Red, Margin = new Thickness(Convert.ToInt32(s.Split(' ')[1]), Convert.ToInt32(s.Split(' ')[2]), 0, 0), Content = "#" + Convert.ToInt32(s.Split(' ')[0]) }; playerButton.IsEnabled = true; _mapPlayers.Add(Convert.ToInt32(s.Split(' ')[0]), playerButton); MainGrid.Children.Add(_mapPlayers[Convert.ToInt32(s.Split(' ')[0])]); } } catch { } } List <int> blablabla = new List <int>(); foreach (var mapPlayer in _mapPlayers.Keys) { blablabla.Add(mapPlayer); } foreach (var bla in blablabla) { if (!playersId.Contains(bla)) { _mapPlayers[bla].Width = 0; _mapPlayers.Remove(bla); } } } }; Cl = new Client(this, Info); Cl.ConnectAsync("127.0.0.1", 4578); Thread m = new Thread(Refresh); m.Start(); }
public MessageQueue(SendDelegate del) { _thread = new Thread(ProcessQueue); _thread.Name = String.Format("Outbound Message Queue [{0}]", _thread.ManagedThreadId); _thread.Start(del); }
public void AddDelegate(SendDelegate sendDelegate) { this.sendDelegate += sendDelegate; }
public void RemoveDelegate(SendDelegate sendDelegate) { this.sendDelegate -= sendDelegate; }