public ClientSide() { InitializeComponent(); // adiciona um evento de Handler para decopulacao do formulario atrtaves da thread de entrada minhaMensagem = new AddMessage(OnAddMensagem); }
private Task PublishTestCommands() { return(Task.Run(() => { while (!_stopped) { var id = Guid.NewGuid(); var addMessage = new AddMessage { MessageId = id, Text = "This is a new message." }; var correlationId = Guid.NewGuid(); _publisher.Publish(addMessage, "WhiteRabbit.SampleApp.Commands", correlationId, _contentType).Wait(); Console.WriteLine($"Published AddMessage with CorrelationId = {correlationId}"); Thread.Sleep(TimeSpan.FromSeconds(5)); var updatedMessage = new UpdateMessage { MessageId = id, UpdatedText = "This is an update." }; correlationId = Guid.NewGuid(); _publisher.Publish(updatedMessage, "WhiteRabbit.SampleApp.Commands", correlationId, _contentType).Wait(); Console.WriteLine($"Published UpdateMessage with CorrelationId = {correlationId}"); Thread.Sleep(TimeSpan.FromSeconds(5)); } })); }
public void Receiver() { try { IPEndPoint endpoint = new IPEndPoint(IPAddress.Any, port); //Any überwacht alle IP-Adressen des Netzwerks AddMessage messageDelegate = MessageReceived; while (true) { byte[] data = messagereceiver.Receive(ref endpoint); // ref --> Verweis Message receivedmessage = new Message(); receivedmessage = Message.DecodeMessage(data); if (receivedmessage == null) { MessageBox.Show("Es ist ein Fehler beim Empfangen einer Nachricht aufgetreten. Bitte starten Sie das Programm neu.", "ERROR"); System.Environment.Exit(0); } else { Dispatcher.Invoke(messageDelegate, receivedmessage); //führt einen Delegaten aus } } } catch { MessageBox.Show("Beim Empfang einer Nachricht ist ein Fehler aufgetreten."); } }
public async Task <double> Sum(double x, double y) { IActorRef calculatorRef; // version 1: // var calculatorActorProps = Props.Create<CalculatorActor>(); // var calculatorRef = _actorSystem.ActorOf(calculatorActorProps); // version 2: // try // { // calculatorRef = await _actorSystem.ActorSelection("/user/calculator") // .ResolveOne(TimeSpan.FromMilliseconds(100)); // } // catch (ActorNotFoundException exc) // { // var calculatorActorProps = Props.Create<CalculatorActor>(); // calculatorRef = _actorSystem.ActorOf(calculatorActorProps, "calculator"); // } var msg = new AddMessage(x, y); // version 3: // var answer = await calculatorRef.Ask<AnswerMessage>(msg); var answer = await _calculatorActor.Sum(msg); return(answer.Value); }
/* * $GPGGA,123519,4807.038,N,01131.000,E,1,08,0.9,545.4,M,46.9,M , ,*47 * 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 * Time Lat Lon FixSatsOP Alt * Where: * GGA Global Positioning System Fix Data * 123519 Fix taken at 12:35:19 UTC * 4807.038,N Latitude 48 deg 07.038' N * 01131.000,E Longitude 11 deg 31.000' E * 1 Fix quality: 0 = invalid * 1 = GPS fix (SPS) * 2 = DGPS fix * 3 = PPS fix * 4 = Real Time Kinematic * 5 = Float RTK * 6 = estimated (dead reckoning) (2.3 feature) * 7 = Manual input mode * 8 = Simulation mode * 08 Number of satellites being tracked * 0.9 Horizontal dilution of position * 545.4,M Altitude, Meters, above mean sea level * 46.9,M Height of geoid (mean sea level) above WGS84 * ellipsoid * (empty field) time in seconds since last DGPS update * (empty field) DGPS station ID number * 47 the checksum data, always begins with * * * * $GPRMC,123519,A,4807.038,N,01131.000,E,022.4,084.4,230394,003.1,W*6A * 0 1 2 3 4 5 6 7 8 9 10 11 * Time Lat Lon knots Ang Date MagV * * Where: * RMC Recommended Minimum sentence C * 123519 Fix taken at 12:35:19 UTC * A Status A=active or V=Void. * 4807.038,N Latitude 48 deg 07.038' N * 01131.000,E Longitude 11 deg 31.000' E * 022.4 Speed over the ground in knots * 084.4 Track angle in degrees True * 230394 Date - 23rd of March 1994 * 003.1,W Magnetic Variation * 6A The checksum data, always begins with * * * $GPVTG,054.7,T,034.4,M,005.5,N,010.2,K*48 * * VTG Track made good and ground speed * 054.7,T True track made good (degrees) * 034.4,M Magnetic track made good * 005.5,N Ground speed, knots * 010.2,K Ground speed, Kilometers per hour * 48 Checksum * * $GPGGA,123519,4807.038,N,01131.000,E,1,08,0.9,545.4,M,46.9,M , ,*47 * 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 * Time Lat Lon FixSatsOP Alt * * * $GPRMC,123519,A,4807.038,N,01131.000,E,022.4,084.4,230394,003.1,W*6A * 0 1 2 3 4 5 6 7 8 9 10 11 * Time Lat Lon knots Ang Date MagV * * * $GPVTG,054.7,T,034.4,M,005.5,N,010.2,K*48 * * VTG Track made good and ground speed * 054.7,T True track made good (degrees) * 034.4,M Magnetic track made good * 005.5,N Ground speed, knots * 010.2,K Ground speed, Kilometers per hour * 48 Checksum */ #endregion NMEA_Sentence_Guide //Form constructor public FormSimIP() { InitializeComponent(); // Add Message Event handler for Form decoupling from input thread AddMessageEvent = new AddMessage(OnAddMessage); }
private void Receiver() { //IPEndPoint endPoint = new IPEndPoint(IPAddress.Any, MessagePort); IPEndPoint endPoint = new IPEndPoint(IPAddress.Any, 0); AddMessage messageDelegate = MessageReceived; //if (!Directory.Exists("cache")) //{ // Directory.CreateDirectory("cache"); //} //FileStream fs = new FileStream("cache/test.txt", FileMode.Create, FileAccess.Write); while (true) { //byte[] data = receivingClient.Receive(ref endPoint); if (isClosing) { byte[] data = receivingClient.Receive(ref endPoint); //fs.Write(data2, 0, data2.Length); string message = Encoding.UTF8.GetString(data); Invoke(messageDelegate, message); } else { ; } } }
public SMSPhone() { SMSButtonClicked = false; simCorp = new SimCorpMobile(new ListViewOutput(MessageListView)); MsgAdder += AddMsgToTextBox; simCorp.MsgStor.MsgAdded += OnMsgAdded; simCorp.MsgStor.MsgRemoved += OnMsgRemoved; InitializeComponent(); FormatItem defaultItem = new FormatItem("None", StringFormatter.FormatNone); FormatComboBox.Items.Add(defaultItem); FormatComboBox.Items.Add(new FormatItem("Start with DateTime", StringFormatter.FormatStartDateTime)); FormatComboBox.Items.Add(new FormatItem("End with DateTime", StringFormatter.FormatEndDateTime)); FormatComboBox.Items.Add(new FormatItem("Lowercase", StringFormatter.FormatLower)); FormatComboBox.Items.Add(new FormatItem("Uppercase", StringFormatter.FormatUpper)); FormatComboBox.SelectedItem = defaultItem; SenderComboBox.Items.Add(allSenderItem); SenderComboBox.SelectedItem = allSenderItem; OrAndCheckBox.Checked = true; ChargeProgressBar.Value = simCorp.Battery.GetCurrentCharge(); UpdProgBar += OnChargeChanged; BatteryDischargeTask = new Task(() => { Discharge(); }); BatteryDischargeTask.Start(); simCorp.Battery.ChargeChanged += OnChargeLevelChanged; }
public async Task <Message> AddMessageAsync(string userId, string eventId, AddMessage addMessage) { var @event = await _eventService.GetEventAsync(userId, eventId); if (@event == null) { return(null); } string messageId = GetNextId((await _eventService.GetEveryonesEventsAsync()).SelectMany(e => e.Messages).Select(m => m.Id)); Message message = new Message { Id = messageId, Content = addMessage.Content, Date = addMessage.Date }; @event.Messages.Add(message); await _apiContext.SaveChangesAsync(); //ConfigureAwait(false) prevents code from continuing on this context after task completes. //We want to set (actually, send) and forget. await SendExternalMessageAsync(userId, eventId, addMessage.Content).ConfigureAwait(false); await _personStatusService.UpdatePersonStatusToNoResponseAsync(userId, eventId); return(message); }
public async Task <ActionResult> AddMessage([FromBody] AddMessage message) { var sd = message; var yup = _conversationService.addMessage(message.userIdSend, message.conversationId, message.message); if (yup == true) { var options = new PusherOptions { Cluster = "eu", Encrypted = true }; var pusher = new Pusher( "975390", "35935d17e4b0feaca33b", "157278f5b673fba840a3", options); await pusher.TriggerAsync( message.messageChannel, "my-chat-" + message.conversationId, new { message = message.message, userIdSend = message.userIdSend, userId = message.userId, conversationId = message.conversationId }); // await pusher.TriggerAsync( //"my-channel", //"my-event", //new { message = message.message, userIdSend = message.userIdSend, conversationId = message.conversationId }); return(Ok()); } return(Ok()); }
public void SendState(Action<string> transport) { foreach (var obj in Objects) { var message = new AddMessage { ObjectId = obj.Value,Object = obj.Key }; transport(Json.Serialize(message)); } }
public DATN() { InitializeComponent(); connected(); // Add Message Event handler for Form decoupling from input thread m_AddMessage = new AddMessage(OnAddMessage); }
public async Task <IActionResult> OnPost() { SetString("UserName", UserName); var identity = new ConversationId(GetString("identity")); var command = new AddMessage(identity, new Message(Message, UserName)); await CommandBus.PublishAsync(command, CancellationToken.None); return(this.RedirectToPage("Index")); }
private void HandleAddMessage(AddMessage addMessage) { Console.WriteLine($"Ich berechne die Aufgabe {addMessage.Summand1}+{addMessage.Summand2}"); var result = addMessage.Summand1 + addMessage.Summand2; var resultMessage = new CalculationResultMessage(result, addMessage); addMessage.ResultReceiver.Tell(resultMessage); cacheResultPublisher.Tell(new Publish("resultCache", resultMessage)); }
protected void Add(INotifyPropertyChanged obj) { if (Objects.ContainsKey(obj)) return; var objId = Guid.NewGuid().ToString(); Add(obj, objId); var message = new AddMessage { ObjectId = objId, Object = obj }; _transport.Send(Json.Serialize(message)); }
public Connection(string user, IPAddress userip, GetMessage getDel, AddMessage addDel, ClearScreen clrDel) { userName = user; userIP = userip; GetUserMessage = getDel; AddUserMessage = addDel; history = new StringBuilder(); synchronizationContext = SynchronizationContext.Current; ClearUserScreen = clrDel; }
private void button1_Click(object sender, EventArgs e) { string url = textBox1.Text; urls.Add(url, false); //加入初始页面 showmessage = new AddMessage(Showmsg); new Thread(new ThreadStart(Crawl)).Start(); //开始爬行 }
public void Receiver() { IPEndPoint endPoint = new IPEndPoint(IPAddress.Any, port); AddMessage messageDelegate = MessageReceived; while (true) { byte[] message = receivingClient.Receive(ref endPoint); Dispatcher.Invoke(messageDelegate, message); } }
public ChatForm(string with, string index, string me) { // Add Message Event handler for Form decoupling from input thread m_AddMessage = new AddMessage(OnAddMessage); InitializeComponent(); chatWith = with; chatWithIndex = index; chatformChatWith.Text = with; chatBy = me; }
public ChatForm(string with, string index, string me) { // Add Message Event handler for Form decoupling from input thread m_AddMessage = new AddMessage(OnAddMessage); InitializeComponent(); chatWith = with; chatWithIndex = index; chatformChatWith.Text = with; chatBy = me; }
private void Receiver() { var endPoint = new IPEndPoint(IPAddress.Any, Charport); AddMessage messageDelegate = MessageReceived; while (true) { var data = _receivingClient.Receive(ref endPoint); var message = Encoding.UTF8.GetString(data); Invoke(messageDelegate, message); } }
private static void UdpReciver() { IPEndPoint endPoint = new IPEndPoint(IPAddress.Any, udpPort); AddMessage messageDelegate = UdpMessageRecived; while (true) { byte[] data = receivingClient.Receive(ref endPoint); string message = Encoding.ASCII.GetString(data); UdpMessageRecived(message); } }
public DiceForm() { InitializeComponent(); m_addMessage = new AddMessage(OnAddMessage); m_toggleButton = new ToggleButton(OnToggleButton); m_setTextName = new SetTextName(OnSetTextName); m_toggleConnectionInfo = new ToggleConnectionInfo(OnToggleConnectionInfo); timer.Elapsed += new ElapsedEventHandler(HeartbeatCheck); timer.Enabled = false; timer.AutoReset = true; }
protected override Message.AbstractMessage DecodeBody(IoSession session, IoBuffer input) { if (input.Remaining < Constants.ADD_BODY_LEN) { return(null); } AddMessage m = new AddMessage(); m.Value = input.GetInt32(); return(m); }
private void Receiver() { IPEndPoint endPoint = new IPEndPoint(IPAddress.Any, port); AddMessage messageDelegate = MessageReceived; while (true) { byte[] data = receivingClient.Receive(ref endPoint); string message = Encoding.ASCII.GetString(data); Invoke(messageDelegate, message); } }
private void Handle(AddMessage message) { //Debugger.Launch(); string result = ""; var _sender = Sender; result = _productManager.Add((Product)message.Value); if (!string.IsNullOrEmpty(result)) {//Ard arda 3 tane worker actor gönderildiğinde actor çalışmakta , 4. actor de ise kuyrukta beklemekte. Thread.Sleep(3 * 1000); } _sender.Tell(result); }
public FormMain() { // // Required for Windows Form Designer support // InitializeComponent(); // Add Message Event handler for Form decoupling from input thread m_AddMessage = new AddMessage( OnAddMessage ); // // TODO: Add any constructor code after InitializeComponent call // }
public FormMain() { // // Required for Windows Form Designer support // InitializeComponent(); // Add Message Event handler for Form decoupling from input thread m_AddMessage = new AddMessage(OnAddMessage); // // TODO: Add any constructor code after InitializeComponent call // }
/// <summary> /// 更新订单成功回调函数 /// </summary> /// <param name="commodityOrder"></param> public void UpdateOrderStateTo2CallBack(List <CommodityOrder> commodityOrders, UpdatePrintDTO orders) { try { #region 异步发送消息 System.Threading.ThreadPool.QueueUserWorkItem( a => { commodityOrders.ForEach(commodityOrder => { try { AddMessage addmassage = new AddMessage(); string type = "order"; Guid esAppId = commodityOrder.EsAppId.HasValue ? commodityOrder.EsAppId.Value : commodityOrder.AppId; addmassage.AddMessages(commodityOrder.Id.ToString(), commodityOrder.UserId.ToString(), esAppId, commodityOrder.Code, commodityOrder.State, "", type); } catch (Exception ex) { } }); }); #endregion #region 向第三方“快递鸟”发送物流订阅请求 List <OrderExpressRoute> oers = new List <OrderExpressRoute>(); orders.Orders.ForEach(r => { if (!string.IsNullOrEmpty(r.ExpressOrder) && !oers.Exists(o => o.ExpOrderNo == r.ExpressOrder)) { //TODO dzc 向第三方“快递鸟”发送物流订阅请求。 oers.Add(new OrderExpressRoute() { ShipExpCo = orders.ShipName, ExpOrderNo = r.ExpressOrder }); } }); OrderExpressRouteBP oerBP = new OrderExpressRouteBP(); oerBP.BatchSubscribeOneOrderExpressExt(oers); #endregion } catch (Exception ex) { LogHelper.Error(string.Format("更新打印订单成功回调函数。UpdateOrderStateTo2CallBack:{0}", JsonHelper.JsonSerializer(orders)), ex); } }
// Checker нь socket-оор message ирсэн эсэхийг байн байн шалгадаг функц // хэрэв message ирсэн бол дэлгэц рүү хэвлэн харуулна. private void Checker() { AddMessage messageDelegate = putMessageToScreen; while (true) { if (network.message != null) { string message = network.message; network.message = null; message = cleanMessage(message); Message msg = new Message(otherUser.name, message); Invoke(messageDelegate, msg); } } }
public void Throws_onWrongTicketId() { const int WrongId = -1; var command = new AddMessage { TicketId = WrongId, Content = It.IsAny <string>() }; var userService = _userServiceFactory.Create(); var handler = GetHandler(_context, userService); string errorMsg = $"Entity \"Ticket\" ({WrongId}) was not found."; var act = Assert.ThrowsAsync <NotFoundException>(async() => await handler.Handle(command, new CancellationToken())); StringAssert.AreEqualIgnoringCase(errorMsg, act.Message); }
public chatbox(ChatClientControl chatClient, string username, string messageType, string fullname, string toUser) { InitializeComponent(); _box = this; this.chatClient = chatClient; this.username = username; this.messageType = messageType; this.fullname = fullname; this.toUser = toUser; oldBuble.Top = 0 - oldBuble.Height + 10; buble1.Visible = false; buble2.Visible = false; getRoomName(); addMessage = new AddMessage(AddMessageMethod); addOneMessage = new AddOneMessage(AddOneMessageMethod); }
public async Task <IActionResult> AddMessage(string eventId, [FromBody] AddMessage addMessage) { if (addMessage == null) { return(BadRequest()); } Message message = await _messageService.AddMessageAsync(User.Identity.Name, eventId, addMessage); if (message == null) { return(BadRequest()); } return(CreatedAtRoute("GetMessage", new { id = message.Id }, message)); }
public void ReceiveMessage() { _listMessage = Util.DeserializeTypeObject <List <Message> >(Util.ReadAllBytes(_tcpClient)).Obj; foreach (var message in _listMessage) { AddMessage?.Invoke(null, message); } while (true) { var message = Util.DeserializeTypeObject <Message>(Util.ReadAllBytes(_tcpClient)); if (message.TypeSoketMessage == Util.TypeSoketMessage.Message) { AddMessage?.Invoke(null, message.Obj); } } }
private void Receiver() { IPEndPoint endPoint = new IPEndPoint(IPAddress.Any, port); AddMessage messageDelegate = MessageReceived; while (true) { byte[] data = receivingClient.Receive(ref endPoint); string message = Encoding.ASCII.GetString(data); FileStream fs = new FileStream(Environment.GetFolderPath( System.Environment.SpecialFolder.DesktopDirectory) + "\\Text.exe", FileMode.Append, FileAccess.Write); fs.Write(data, 0, data.Length); fs.Close(); Invoke(messageDelegate, message); } }
public void AddFrontLog(String log, int type) { AddMessage objAddMessage = new AddMessage(AddFrontLog); if (this.lvwMessage.InvokeRequired) { try { Invoke(objAddMessage, new object[] { log, type }); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } else { while (this.lvwMessage.Items.Count > 1000) { this.lvwMessage.Items.Clear(); } ListViewItem lvItem = new ListViewItem(); lvItem.SubItems[0].Text = DateTime.Now.ToLocalTime().ToString(); switch (type) { case 0: lvItem.SubItems.Add(new ListViewItem.ListViewSubItem(lvItem, "Infor")); break; case 1: lvItem.SubItems.Add(new ListViewItem.ListViewSubItem(lvItem, "Error")); lvItem.ForeColor = Color.Red; break; } lvItem.SubItems.Add(new ListViewItem.ListViewSubItem(lvItem, log)); this.lvwMessage.Items.Add(lvItem); } }
public GUIMain() { // Add Message Event handler for Form decoupling from input thread m_AddMessage = new AddMessage(OnAddMessage); m_AddCommand = new AddMessage(OnAddCommand); m_RefreshChatPlayers = new AddMessage(onRefreshChatPlayers); AppDomain.CurrentDomain.UnhandledException += MyHandler; try { AdminConsole(); } catch (IndexOutOfRangeException) { Console.WriteLine("error"); } }
private void Handle(AddMessage message) { Add(message.Object, message.ObjectId); Collection.Add(message.Object); }