/// <summary> /// Pushes a new AIC-Message to the client. /// </summary> /// <param name="alarms">The list of active alarms.</param> /// <param name="wasConnectionState">The WAS connection-state.</param> /// <param name="type">The type of message (request or response).</param> private void PushAicMessage(List <Alarm> alarms, bool wasConnectionState, MessageType type) { if (this.mTcpClient == null || !this.mTcpClient.IsConnected()) { this.mLogger.LogWarning(string.Format("Can't push message because TCP-Client (IP: {0}) has already gone", this.ClientAddress), WarningType.ClientSession_CantPushMessage); return; } AicMessage message = new AicMessage { Alarms = alarms, ConnectionWasToServerOk = wasConnectionState, MessageType = type }; try { message.Serialize(this.mTcpClient.GetStream().GetUnderlyingStream()); this.mLogger.LogInformation(string.Format("New {0}-push to client (IP: {1}) performed", type, this.ClientAddress), InformationType.ClientSession_PerformedPush); } catch (Exception ex) { this.mLogger.LogError("(ClientSession/PushNewState/Exception)", ErrorType.Undefined, ex); } }
/// <summary> /// Sends the KeepAlive-Message to the client to avoid dirty connection states. /// </summary> private void SendKeepAliveMessage() { try { AicMessage message = new AicMessage { Alarms = new List <Alarm>(), ConnectionWasToServerOk = true, MessageType = MessageType.KeepAlive }; message.Serialize(this.mTcpClient.GetStream().GetUnderlyingStream()); } catch (Exception ex) { this.mLogger.LogError("(ClientListener/SendKeepAliveMessage/Exception)", ErrorType.Undefined, ex); } }