public void FireMessageProcessingEvent() { if (MessageProcessing != null) { MessageProcessing.Invoke(this); } }
public void doPost() { Assert.AreEqual("utf-8", Encoding.UTF8.HeaderName); Assert.AreEqual(Encoding.UTF8, Encoding.GetEncoding(Encoding.UTF8.HeaderName)); Encoding e = Encoding.GetEncoding("Windows-1251"); var p = new PHP_SMS(); p.Vars["sn"] = "1"; p.Vars["num"] = "<br>"; p.Vars["sms_text"] = "Привет"; p.URL = "http://www.i-rai.com:83/test.php"; p.Encoding = Encoding.UTF8; Assert.AreEqual("Привет мир! sn = 1 num = " + p.Vars["num"] + " sms_text = " + p.Vars["sms_text"], p.doPost()); // Испытываем скрипт index.php в кодировке Windows-1251 var p1 = PHP_SMS.Get_by_Prefix("index"); Assert.AreEqual("Привет, мир! Windows-1251 sn = 4141 num = 79117117850 sms_text = " + "Привет", MessageProcessing.GetAnswer(p1, "4141", "Привет", "79117117850")); PHP_SMS pp = PHP_SMS.Get_by_Prefix("supsex"); // Assert.IsTrue(MessageProcessing.GetAnswer(pp, "4141", "test", "79117117850").StartsWith("Пароль: ")); // Assert.AreEqual("", MessageProcessing.GetAnswer(pp, "4141", "test", "79117117850")); PHP_SMS p2 = PHP_SMS.Get_by_Prefix("test"); // Assert.AreEqual("", MessageProcessing.GetAnswer(p2, "4141", "test", "79117117850")); Assert.IsTrue(MessageProcessing.GetAnswer(p2, "4141", "test", "79117117850").StartsWith("\nhttp://test.i-rai.com/psi1.php?pass=")); }
private void ConnectingProcessing(string message, IPEndPoint ePoint) { string[] mass = message.Split(' '); //mass[0] - подключился или готов, mass[1] - имя игрока if (mass[0].Equals("подключился")) { var pl = playersTable.players.Find(x => x.Name.Equals(mass[1])); if (pl == null) { playersTable.Add(mass[1], ePoint); } //оповестить других игроков } else if (mass[0].Equals("готов")) { var player = playersTable.players.Find(x => x.Name.Equals(mass[1]) && x.IsReady == false); if (player != null) { playersReady++; player.IsReady = true; } if (playersReady == playersTable.players.Count()) { messageProcessing = GameProcessing; socket.ReceiveTimeout = 20000; StartGame(); } } }
public BotController(ILogger <BotController> logger, IConfiguration configuration, MessageProcessing messageProcessing, IVkApi vkApi) { Log = logger; Config = configuration; CommandBinding = messageProcessing; Vk = vkApi; Log.LogInformation("Services Inited"); }
internal void RaiseMessageRecieved(ChatMsg message, ref bool consumed) { var torchMsg = new TorchChatMessage(MyMultiplayer.Static?.GetMemberName(message.Author) ?? $"user_{message.Author}", message.Author, message.Text); MessageProcessing?.Invoke(torchMsg, ref consumed); }
public BitfinexSocketService(MessageProcessing processing, ISocketCommandService commandService, IOptions <StockApiConnections> options, ILogger <BitfinexSocketService> customlogger) { _processing = processing; _commandService = commandService; _options = options; _logger = customlogger; }
/// <inheritdoc /> protected override bool OfflineMessageProcessor(TorchChatMessage msg) { if (MyMultiplayer.Static != null) { return(false); } var consumed = false; MessageProcessing?.Invoke(msg, ref consumed); return(consumed); }
internal void RaiseMessageRecieved(ChatMsg message, ref bool consumed) { var torchMsg = new TorchChatMessage(GetMemberName(message.Author), message.Author, message.Text); MessageProcessing?.Invoke(torchMsg, ref consumed); if (!consumed) { _chatLog.Info($"{torchMsg.Author}: {torchMsg.Message}"); } }
protected override void OnInitialized(EventArgs e) { base.OnInitialized(e); if (DataContext == null) { DataContext = new Model(); } var model = DataContext as Model; model.Waiting.Clear(); model.Expecting.Clear(); Dispatcher.Invoke(async() => { await MessageProcessing.CheckAppointments(model); }); }
// Обработка приходящих сообщений private void Vk_MessageReceived(object sender, MessageEventArgs e) { // Добавление в Users, если отсутствует if (!Users.Contains(e.Message.Id)) { Task.Delay(300).Wait(); var name = vk.GetUsername(e.Message.Id); if (name != null) { Users.AddUser(e.Message.Id, name, null); } } // Вызов события о новом сообщении MessageReceived?.Invoke(this, e); // Пинаем каждый модуль чтоб он обработал сообщения for (int i = 0; i < Extensions.Length; i++) { var extension = Extensions[i]; // Скипаем выключенные модули if (!extension.Enabled) { continue; } // Передаём модулям сообщения для обработки MessageProcessing?.Invoke(this, new MessageProcessedEventArgs(extension)); var res = extension.ProcessMessage(e.Message.Id, e.Message.Text); // Логирование и остановка обработки if (res == ProcessResult.Processed) { MessageProcessed?.Invoke(this, new MessageProcessedEventArgs(extension)); if (extension.StopAfterProcessed) { ExtensionStopProcessing?.Invoke(this, new MessageProcessedEventArgs(extension)); return; } } else if (res == ProcessResult.Skipped) { MessageSkipped?.Invoke(this, new MessageProcessedEventArgs(extension)); } } }
private void ClientHandler <M>(Socket clientSocket) { clientList.Add(clientSocket); OnServerAccept?.Invoke(this, new AcceptEventArgs(clientSocket)); int fullMessageSize; string fullMessage; byte[] messageBuffer = new byte[1024]; while (true) { fullMessage = string.Empty; fullMessageSize = 0; try { do { int messageSize = clientSocket.Receive(messageBuffer); fullMessageSize += messageSize; fullMessage += Encoding.UTF8.GetString(messageBuffer, 0, messageSize); } while (clientSocket.Available > 0); OnServerReceive?.Invoke(this, new EventArgs()); } catch (Exception exception) { OnReceiveException?.Invoke(this, new ExceptionEventArgs(clientSocket, exception)); break; } List <ByteArray> byteArrays = Buffer.SplitBuffer(Encoding.UTF8.GetBytes(fullMessage), 0); object message = default; foreach (var byteArray in byteArrays) { if (typeof(M) != typeof(string)) { message = JsonSerializer.Deserialize <M>(Encoding.UTF8.GetString(byteArray.bytes)); } else { message = Encoding.UTF8.GetString(byteArray.bytes); } MessageProcessing?.Invoke(this, new MessageProcessEventArgs(new MessageData(message, fullMessageSize, fullMessage))); } } }
internal void RaiseMessageRecieved(ChatMsg message, ref bool consumed) { var torchMsg = new TorchChatMessage(GetMemberName(message.Author), message.Author, message.Text, (ChatChannel)message.Channel, message.TargetId); if (_muted.Contains(message.Author)) { consumed = true; _chatLog.Warn($"MUTED USER: [{torchMsg.Channel}:{torchMsg.Target}] {torchMsg.Author}: {torchMsg.Message}"); return; } MessageProcessing?.Invoke(torchMsg, ref consumed); if (!consumed) { _chatLog.Info($"[{torchMsg.Channel}:{torchMsg.Target}] {torchMsg.Author}: {torchMsg.Message}"); } }
/// <summary> /// Vlastní zpracování přijaté zprávy dle jejího typu /// </summary> /// <param name="login"></param> /// <param name="password"></param> /// <param name="partnerCode"></param> /// <param name="messageType"></param> /// <param name="data"></param> /// <param name="encoding"></param> /// <param name="result"></param> /// <param name="authToken"></param> /// <returns></returns> private static SubmitDataToProcessingResult ProcessData(string login, string password, string partnerCode, string messageType, byte[] data, string encoding, SubmitDataToProcessingResult result, AuthToken authToken) { string messageTypeNormalized = messageType.ToUpper().Trim(); if (messageTypeNormalized.Contains("TEST")) { messageTypeNormalized = "TEST"; } switch (messageTypeNormalized) { case "TEST": result = TestProcessing.Process(authToken, login, password, partnerCode, messageType, data, encoding); break; case "GETSERVICESSTATUSES": result = ServicesStatusesProcessing.Process(authToken, login, password, partnerCode, messageType); break; case "RECEPTIONCONFIRMATION": case "KITTINGCONFIRMATION": case "SHIPMENTCONFIRMATION": case "RETURNED": case "RETURNEDEQUIPMENT": case "RETURNEDITEM": case "RETURNEDSHIPMENT": case "REFURBISHEDCONFIRMATION": case "DELETEMESSAGECONFIRMATION": case "CRMORDERCONFIRMATION": case "CRMORDERAPPROVAL": result = MessageProcessing.Process(authToken, login, password, partnerCode, messageType, data, encoding); break; default: ProjectHelper.CreateErrorResult(Fenix.ApplicationLog.GetMethodName(), ref result, "100", String.Format("Unknown messageType = [{0}]", messageType)); break; } return(result); }
private async void buttonSmsOut_Click(object sender, RoutedEventArgs e) { var model = DataContext as Model; var processor = new MessageProcessing(); await processor.CheckForMessages(model); }
public Server() { messageProcessing = ConnectingProcessing; }
public void Startup() { // // get configuration information // MessageQueueAppConfig messageQueueAppConfig = new MessageQueueAppConfig(); ConnectionStrings connectionStrings = new ConnectionStrings(); var basePath = PlatformServices.Default.Application.ApplicationBasePath; if (basePath.ToLower().Contains("salesordermanagementqa")) { CodeProject.Shared.Common.Models.AppSettings.MessageQueueAppSettings appSettings = new CodeProject.Shared.Common.Models.AppSettings.MessageQueueAppSettings(); string readContents; using (StreamReader streamReader = new StreamReader(basePath + @"\AppSettings.QA.json", Encoding.UTF8)) { readContents = streamReader.ReadToEnd(); } appSettings = CodeProject.Shared.Common.Utilities.SerializationFunction <CodeProject.Shared.Common.Models.AppSettings.MessageQueueAppSettings> .ReturnObjectFromString(readContents); messageQueueAppConfig.MessageQueueHostName = appSettings.MessageQueueAppConfig.MessageQueueHostName; messageQueueAppConfig.MessageQueueUserName = appSettings.MessageQueueAppConfig.MessageQueueUserName; messageQueueAppConfig.MessageQueuePassword = appSettings.MessageQueueAppConfig.MessageQueuePassword; messageQueueAppConfig.MessageQueueEnvironment = appSettings.MessageQueueAppConfig.MessageQueueEnvironment; messageQueueAppConfig.ExchangeName = appSettings.MessageQueueAppConfig.ExchangeName; messageQueueAppConfig.RoutingKey = appSettings.MessageQueueAppConfig.RoutingKey; messageQueueAppConfig.InboundMessageQueue = appSettings.MessageQueueAppConfig.InboundMessageQueue; messageQueueAppConfig.OutboundMessageQueues = appSettings.MessageQueueAppConfig.OutboundMessageQueues; messageQueueAppConfig.LoggingExchangeName = appSettings.MessageQueueAppConfig.LoggingExchangeName; messageQueueAppConfig.LoggingMessageQueue = appSettings.MessageQueueAppConfig.LoggingMessageQueue; messageQueueAppConfig.OriginatingQueueName = appSettings.MessageQueueAppConfig.OriginatingQueueName; messageQueueAppConfig.SendToLoggingQueue = appSettings.MessageQueueAppConfig.SendToLoggingQueue; messageQueueAppConfig.AcknowledgementMessageExchangeSuffix = appSettings.MessageQueueAppConfig.AcknowledgementMessageExchangeSuffix; messageQueueAppConfig.AcknowledgementMessageQueueSuffix = appSettings.MessageQueueAppConfig.AcknowledgementMessageQueueSuffix; messageQueueAppConfig.TriggerExchangeName = appSettings.MessageQueueAppConfig.TriggerExchangeName; messageQueueAppConfig.TriggerQueueName = appSettings.MessageQueueAppConfig.TriggerQueueName; messageQueueAppConfig.QueueImmediately = appSettings.MessageQueueAppConfig.QueueImmediately; messageQueueAppConfig.InboundSemaphoreKey = appSettings.MessageQueueAppConfig.InboundSemaphoreKey; messageQueueAppConfig.OutboundSemaphoreKey = appSettings.MessageQueueAppConfig.OutboundSemaphoreKey; messageQueueAppConfig.ProcessingIntervalSeconds = appSettings.MessageQueueAppConfig.ProcessingIntervalSeconds; messageQueueAppConfig.SendingIntervalSeconds = appSettings.MessageQueueAppConfig.SendingIntervalSeconds; messageQueueAppConfig.ReceivingIntervalSeconds = appSettings.MessageQueueAppConfig.ReceivingIntervalSeconds; messageQueueAppConfig.SignalRHubUrl = appSettings.MessageQueueAppConfig.SignalRHubUrl; messageQueueAppConfig.RunAsService = appSettings.MessageQueueAppConfig.RunAsService; connectionStrings.PrimaryDatabaseConnectionString = appSettings.ConnectionStrings.PrimaryDatabaseConnectionString; using (var sw = File.AppendText(Path)) { sw.WriteLine("HostName=" + messageQueueAppConfig.MessageQueueHostName + "*"); } } else { string environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT"); string jsonFile = $"AppSettings.{environment}.json"; var configBuilder = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile(jsonFile, optional: true, reloadOnChange: true); IConfigurationRoot configuration = configBuilder.Build(); configuration.GetSection("MessageQueueAppConfig").Bind(messageQueueAppConfig); configuration.GetSection("ConnectionStrings").Bind(connectionStrings); } // // set up sending queue // IMessageQueueConnection sendingQueueConnection = new MessageQueueConnection(messageQueueAppConfig); sendingQueueConnection.CreateConnection(); List <IMessageQueueConfiguration> messageQueueConfigurations = new List <IMessageQueueConfiguration>(); IMessageQueueConfiguration salesOrderSubmittedConfiguration = new MessageQueueConfiguration(MessageQueueExchanges.SalesOrderSubmitted, messageQueueAppConfig, sendingQueueConnection); salesOrderSubmittedConfiguration.AddQueue(MessageQueueEndpoints.InventoryQueue); salesOrderSubmittedConfiguration.AddQueue(MessageQueueEndpoints.LoggingQueue); salesOrderSubmittedConfiguration.InitializeOutboundMessageQueueing(); messageQueueConfigurations.Add(salesOrderSubmittedConfiguration); ISalesOrderManagementDataService salesOrderManagementDataService = new SalesOrderManagementDataService(); IMessageQueueProcessing messageProcessing = new MessageProcessing(salesOrderManagementDataService); _sendSalesOrderManagementMessages = new SendMessages(sendingQueueConnection, messageProcessing, messageQueueAppConfig, connectionStrings, messageQueueConfigurations, MessageQueueEndpoints.SalesOrderQueue); // // set up receiving queue // IMessageQueueConnection receivingConnection = new MessageQueueConnection(messageQueueAppConfig); receivingConnection.CreateConnection(); List <IMessageQueueConfiguration> inboundMessageQueueConfigurations = new List <IMessageQueueConfiguration>(); IMessageQueueConfiguration inboundConfiguration = new MessageQueueConfiguration(messageQueueAppConfig, receivingConnection); inboundMessageQueueConfigurations.Add(inboundConfiguration); inboundConfiguration.InitializeInboundMessageQueueing(MessageQueueEndpoints.SalesOrderQueue); inboundConfiguration.InitializeLoggingExchange(MessageQueueExchanges.Logging, MessageQueueEndpoints.LoggingQueue); ISalesOrderManagementDataService inboundSalesOrderManagementDataService = new SalesOrderManagementDataService(); IMessageQueueProcessing inboundMessageProcessing = new MessageProcessing(inboundSalesOrderManagementDataService); _receiveSalesOrderManagementMessages = new ReceiveMessages(receivingConnection, inboundMessageProcessing, messageQueueAppConfig, connectionStrings, inboundMessageQueueConfigurations); // // Set Up Message Processing // ISalesOrderManagementDataService salesOrderManagementProcessingDataService = new SalesOrderManagementDataService(); IMessageQueueProcessing messageProcessor = new MessageProcessing(salesOrderManagementProcessingDataService); _processMessages = new ProcessMessages(messageProcessor, messageQueueAppConfig, connectionStrings); var builder = new HostBuilder().ConfigureAppConfiguration((hostingContext, config) => { }) .ConfigureServices((hostContext, services) => { services.AddTransient <IHostedService>(provider => _sendSalesOrderManagementMessages); }) .ConfigureServices((hostContext, services) => { services.AddTransient <IHostedService>(provider => _processMessages); }) .ConfigureServices((hostContext, services) => { services.AddTransient <IHostedService>(provider => _receiveSalesOrderManagementMessages); }); }
public static async Task Main(string[] args) { // // get configuration information // MessageQueueAppConfig messageQueueAppConfig = new MessageQueueAppConfig(); ConnectionStrings connectionStrings = new ConnectionStrings(); string environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT"); string jsonFile = $"appsettings.{environment}.json"; var configBuilder = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile(jsonFile, optional: true, reloadOnChange: true); IConfigurationRoot configuration = configBuilder.Build(); configuration.GetSection("MessageQueueAppConfig").Bind(messageQueueAppConfig); configuration.GetSection("ConnectionStrings").Bind(connectionStrings); // // set up sending queue // IMessageQueueConnection sendingQueueConnection = new MessageQueueConnection(messageQueueAppConfig); sendingQueueConnection.CreateConnection(); List <IMessageQueueConfiguration> messageQueueConfigurations = new List <IMessageQueueConfiguration>(); // // Inventory Received Transactions // IMessageQueueConfiguration inventoryReceivedConfiguration = new MessageQueueConfiguration(MessageQueueExchanges.InventoryReceived, messageQueueAppConfig, sendingQueueConnection); inventoryReceivedConfiguration.AddQueue(MessageQueueEndpoints.SalesOrderQueue); inventoryReceivedConfiguration.AddQueue(MessageQueueEndpoints.PurchaseOrderQueue); inventoryReceivedConfiguration.AddQueue(MessageQueueEndpoints.LoggingQueue); inventoryReceivedConfiguration.InitializeOutboundMessageQueueing(); messageQueueConfigurations.Add(inventoryReceivedConfiguration); // // Product Creation and Updates // IMessageQueueConfiguration productUpdatedConfiguration = new MessageQueueConfiguration(MessageQueueExchanges.ProductUpdated, messageQueueAppConfig, sendingQueueConnection); productUpdatedConfiguration.AddQueue(MessageQueueEndpoints.SalesOrderQueue); productUpdatedConfiguration.AddQueue(MessageQueueEndpoints.PurchaseOrderQueue); productUpdatedConfiguration.AddQueue(MessageQueueEndpoints.LoggingQueue); productUpdatedConfiguration.InitializeOutboundMessageQueueing(); messageQueueConfigurations.Add(productUpdatedConfiguration); // // Inventory Shipped Transactions // IMessageQueueConfiguration inventoryShippedConfiguration = new MessageQueueConfiguration(MessageQueueExchanges.InventoryShipped, messageQueueAppConfig, sendingQueueConnection); inventoryShippedConfiguration.AddQueue(MessageQueueEndpoints.SalesOrderQueue); inventoryShippedConfiguration.AddQueue(MessageQueueEndpoints.LoggingQueue); inventoryShippedConfiguration.InitializeOutboundMessageQueueing(); messageQueueConfigurations.Add(inventoryShippedConfiguration); // // initialize Sending Messages // IInventoryManagementDataService inventoryManagementDataService = new InventoryManagementDataService(); IMessageQueueProcessing messageProcessing = new MessageProcessing(inventoryManagementDataService); IHostedService sendInventoryManagementMessages = new SendMessages(sendingQueueConnection, messageProcessing, messageQueueAppConfig, connectionStrings, messageQueueConfigurations, MessageQueueEndpoints.InventoryQueue); // // set up receiving queue // IMessageQueueConnection receivingConnection = new MessageQueueConnection(messageQueueAppConfig); receivingConnection.CreateConnection(); List <IMessageQueueConfiguration> inboundMessageQueueConfigurations = new List <IMessageQueueConfiguration>(); IMessageQueueConfiguration inboundConfiguration = new MessageQueueConfiguration(messageQueueAppConfig, receivingConnection); inboundMessageQueueConfigurations.Add(inboundConfiguration); inboundConfiguration.InitializeInboundMessageQueueing(MessageQueueEndpoints.InventoryQueue); inboundConfiguration.InitializeLoggingExchange(MessageQueueExchanges.Logging, MessageQueueEndpoints.LoggingQueue); IInventoryManagementDataService inboundInventoryManagementDataService = new InventoryManagementDataService(); IMessageQueueProcessing inboundMessageProcessing = new MessageProcessing(inboundInventoryManagementDataService); IHostedService receiveInventoryManagementMessages = new ReceiveMessages(receivingConnection, inboundMessageProcessing, messageQueueAppConfig, connectionStrings, inboundMessageQueueConfigurations); // // Set Up Message Processing // IInventoryManagementDataService inventoryManagementProcessingDataService = new InventoryManagementDataService(); IMessageQueueProcessing messageProcessor = new MessageProcessing(inventoryManagementProcessingDataService); ProcessMessages processMessages = new ProcessMessages(messageProcessor, messageQueueAppConfig, connectionStrings); var builder = new HostBuilder().ConfigureAppConfiguration((hostingContext, config) => {}) .ConfigureServices((hostContext, services) => { services.AddTransient <IHostedService>(provider => processMessages); }) .ConfigureServices((hostContext, services) => { services.AddTransient <IHostedService>(provider => sendInventoryManagementMessages); }) .ConfigureServices((hostContext, services) => { services.AddTransient <IHostedService>(provider => receiveInventoryManagementMessages); }) .ConfigureLogging((hostingContext, logging) => { logging.AddConfiguration(hostingContext.Configuration.GetSection("Logging")); logging.AddConsole(); }); await builder.RunConsoleAsync(); }
private async void buttonRefresh_Click(object sender, RoutedEventArgs e) { var model = DataContext as Model; await MessageProcessing.CheckAppointments(model); }
public async System.Threading.Tasks.Task ReadTodaysAppointments() { ArrivalsModel model = new ArrivalsModel(); await MessageProcessing.CheckAppointments(model); }