Beispiel #1
0
        /// <summary>
        /// Handler for the IChannel.ReceiveError event
        /// </summary>
        /// <param name="error">The error code</param>
        /// <param name="message">The error message</param>
        /// <param name="channel">The channel signaling the error</param>
        public void OnChannelReceiveError(int error, string message, IChannel channel)
        {
            string uri = channel.Uri;

            if (error == (int)SocketChannel.SocketErrors.RemoteClosed)
            {
                CommObjects.ChannelManager.CloseChannel(uri);
                FecsMain.Logger.AddLog(string.Format("Client {0} disconnected (outqueue)", uri),
                                       LoggerSeverities.Info);
                //>> LDR 2004.05.05
                string ip;
                int    port;
                TcpIpUri.UriAsAddressPort(channel.Uri, out ip, out port);
                FecsBecsHeader hd = new FecsBecsHeader(channel.Uri, ip, new PacketData(System.DateTime.Now, "-1"));
                _outQueue.Send(hd, "<s1 id=\"0\"><uri>" + channel.Uri + "</uri></s1>");
                //<< LDR 2004.05.05

                //>> LDR 2004.07.16
                //				channel.SendError -= new ErrorHandler(OnChannelSendError);
                //				channel.IncomingMessage -=
                //					new MessageHandler(OnChannelIncomingMessage);
                //				channel.ReceiveError -=
                //					new ErrorHandler(OnChannelReceiveError);
                //<< LDR 2004.07.16
            }
            else if (CommObjects.ChannelManager.GetChannel(uri) != null)
            {
                FecsMain.Logger.AddLog(string.Format("[{2}]Error receiving from {0}: {1} ({2})",
                                                     channel.Uri, error, message), LoggerSeverities.Error);
            }
        }
Beispiel #2
0
 /// <summary>
 /// Handler for the IChannel.IncomingMessage event
 /// </summary>
 /// <param name="msg">The message received</param>
 /// <param name="channel">The channel that received the message</param>
 public void OnChannelIncomingMessage(OPSTelegrama msg, IChannel channel)
 {
     if (ValidateMessage(msg))
     {
         string ip;
         int    port;
         TcpIpUri.UriAsAddressPort(channel.Uri, out ip, out port);
         IPacketizer    packetizer = msg.Packetizer;
         FecsBecsHeader hd         = new FecsBecsHeader(channel.Uri, ip, packetizer.PacketInfo);
         for (int i = 0; i < packetizer.PacketsCount; i++)
         {
             _outQueue.Send(hd, packetizer[i]);
             FecsMain.Logger.AddLog(
                 string.Format("[OutputQueueFecsAdapter]:Message received from {0} [{1}]", channel.Uri, msg.XmlData),
                 LoggerSeverities.Info);
         }
     }
     else
     {
         FecsMain.Logger.AddLog(
             string.Format("[OutputQueueFecsAdapter]:Message not validated from {0} [{1}]", channel.Uri, msg.XmlData),
             LoggerSeverities.Error);
         NackMessage(msg, channel);
     }
 }