Пример #1
0
        private void OnSoftDisconnectReader()
        {
            Log.EntryNormal(LogR, "Reader soft disconnect");
            //Log.Console(info.remote + " reader softly disconnected");

            reader       = null;
            readerStatus = ReadStatus.READY;

            //SoftDisconnect();
        }
Пример #2
0
        internal void AcceptReaderConnection(Socket readingSocket,
                                             MessageProcessor messageProcessor)
        {
            try
            {
                if (IsClosed)
                {
                    throw new NodeException("AcceptConnection: node is disconnected " + FullDescription());
                }

                if (readerStatus != ReadStatus.READY)
                {
                    throw new NodeException("AcceptConnection: reader is aready initialized " + FullDescription());
                }

                reader = new SocketReader(sync,
                                          (stm) =>
                {
                    //string sentMsg = mtp.ToString();
                    //if (MasterFileLog.LogLevel > 2)
                    //    sentMsg += new ChunkDebug(stm).GetData() + "\n\n";

                    //Log.EntryVerbose(LogR, sentMsg);

                    messageProcessor(stm, this);
                },
                                          (ioex) =>
                {
                    readerStatus = ReadStatus.DISCONNECTED;
                    Close(ioex, DisconnectType.READ);
                },
                                          OnSoftDisconnectReader,
                                          readingSocket);

                readerStatus = ReadStatus.READING;
            }
            catch (Exception)
            {
                readingSocket.Close();
                throw;
            }
        }