Sanguosha.Core.Utils.RecordTakingOutputStream.Flush C# (CSharp) Method

Flush() public method

public Flush ( ) : void
return void
        public override void Flush()
        {
            lock (OutputStreams)
            {
                foreach (var stream in OutputStreams)
                {
                    stream.Flush();
                }
            }
        }

Usage Example

Example #1
0
        void ReconnectionListener()
        {
            Trace.TraceInformation("Reconnection listener Started on {0} : {1}", ipAddress.ToString(), IpPort);
            while (true)
            {
                try
                {
                    var client = listener.AcceptTcpClient();
                    Trace.TraceInformation("Client connected");
                    var stream = client.GetStream();
                    stream.ReadTimeout = 2000;
                    Account theAccount = null;
                    if (game.Configuration != null)
                    {
                        object item;
                        try
                        {
                            item = (new ItemReceiver(stream)).Receive();
                        }
                        catch (Exception)
                        {
                            item = null;
                        }
                        if (!(item is LoginToken) ||
                         !game.Configuration.AccountIds.Any(id => id.token == ((LoginToken)item).token))
                        {
                            client.Close();
                            continue;
                        }
                        int index;
                        for (index = 0; index < game.Configuration.AccountIds.Count; index++)
                        {
                            if (game.Configuration.AccountIds[index].token == ((LoginToken)item).token)
                            {
                                theAccount = game.Configuration.Accounts[index];
                            }
                        }
                    }
                    stream.ReadTimeout = Timeout.Infinite;
                    int indexC = game.Settings.Accounts.IndexOf(theAccount);
                    Trace.Assert(indexC >= 0);
                    lock (handlers[indexC].queueIn) lock (handlers[indexC].queueOut) lock (handlers[indexC].sender) lock (handlers[indexC].receiver)
                                {
                                    handlers[indexC].sender.Flush();
                                    var newRCStream = new RecordTakingOutputStream(stream);
                                    (handlers[indexC].stream as RecordTakingOutputStream).DumpTo(newRCStream);
                                    handlers[indexC].disconnected = false;
                                    newRCStream.Flush();
                                    handlers[indexC].stream = newRCStream;
                                    handlers[indexC].sender = new ItemSender(handlers[indexC].stream);
                                    handlers[indexC].receiver = new ItemReceiver(handlers[indexC].stream);
                                }

                }
                catch (Exception)
                {
                    return;
                }
            }
        }
All Usage Examples Of Sanguosha.Core.Utils.RecordTakingOutputStream::Flush