Beispiel #1
0
        private void OnSoftDisconnectWriter()
        {
            Log.EntryNormal(LogW, "Writer soft disconnect");
            //Log.Console(info.remote + " writer softly disconnected");

            Queue <SocketWriterMessage> msgs = writer.ExtractAllMessages();

            writer       = null;
            writerStatus = WriteStatus.READY;

            while (msgs.Any() && msgs.Peek().type == SocketWriterMessageType.SOFT_DISCONNECT)
            {
                msgs.Dequeue();
            }

            if (msgs.Any())
            {
                ConnectAsync();

                while (msgs.Any())
                {
                    writer.SendMessage(msgs.Dequeue());
                }
            }
        }
Beispiel #2
0
        internal void ConnectAsync()
        {
            if (IsClosed)
            {
                throw new NodeException("SendMessage: node is closed " + FullDescription());
            }
            if (writerStatus != WriteStatus.READY)
            {
                throw new NodeException("SendMessage: node is not ready " + FullDescription());
            }

            MyAssert.Assert(writer == null);

            Action <Exception, DisconnectType> errorResponse = (e, dt) =>
            {
                writerStatus = WriteStatus.DISCONNECTED;
                Close(e, dt);
            };

            writerStatus = WriteStatus.WRITING;
            writer       = new SocketWriter(Address, sync, errorResponse, OnSoftDisconnectWriter, info);
        }