static extern int FormatMessage( FormatMessage dwFlags, IntPtr lpSource, int dwMessageId, uint dwLanguageId, out StringBuilder msgOut, int nSize, IntPtr Arguments );
private void ParseAndCreateCommandsLs() { using (StreamReader sr = File.OpenText(FilePath)) { while (!sr.EndOfStream) { string command = sr.ReadLine(); FormatMessage newMess = new FormatMessage(command); MessagesLs.Add(newMess); } } }
public static void SendMessage(FormatMessage formatMsg) { clientSocket = ConfigureClientSocket(); // configuring clientSocket before every message sending Console.WriteLine("\n\tSocket connecting with {0} ", clientSocket.RemoteEndPoint.ToString()); byte[] byteMessage = formatMsg.Serialize(); // sending data through socket clientSocket.Send(byteMessage); Console.WriteLine($"Client sent \"{formatMsg.Command}\""); logger.LogCommand(true, true, formatMsg.Command); }
public static void ReceiveMessage() { // input data buffer byte[] receivedBytes = new byte[256]; // receiving server's answer clientSocket.Receive(receivedBytes); FormatMessage receivedMessage = FormatMessage.Desserialize(receivedBytes); string answer = receivedMessage.Command; Console.WriteLine($"Server answer:\t{answer}"); logger.LogCommand(false, true, answer); }
public static void ReceiveExecuteMessage() { // waiting for input connection handler = serverSocket.Accept(); // client has just connected // input data buffer byte[] receivedBytes = new byte[256]; // receiving server's answer handler.Receive(receivedBytes); FormatMessage receivedMessage = FormatMessage.Desserialize(receivedBytes); LastMessage = receivedMessage; // analysing received messages DataAnalyse.Parse(); logger.LogCommand(false, false, LastMessage.Command); }
public static void SendMessage() { FormatMessage replyMsg; if (!string.IsNullOrWhiteSpace(ErrorCMDReply)) { replyMsg = new FormatMessage($"Command: \"{ErrorCMDReply}\" made an error!"); ErrorCMDReply = string.Empty; } else if (IsAllCommandsExecuted) { replyMsg = new FormatMessage("All commands executed!"); } else { replyMsg = new FormatMessage("Server in work"); } byte[] msg = replyMsg.Serialize(); handler.Send(msg); logger.LogCommand(true, false, replyMsg.Command); }
public string IncomingMessage(string message, string contact) { FormatMessage SMS = new FormatMessage(); string response = SMS.SplittingMessage(message, contact); Context.Response.Output.Write(response); Context.Response.End(); return string.Empty; }