protected override async Task MainLoop(ILineBasedStream stream)
            {
                await stream.WriteLineAsync("OK");

                await Shutdown(Connection.SupportsCleanShutdown, true);

                Connection.Dispose();
            }
            protected override async Task MainLoop(ILineBasedStream stream)
            {
                string line;

                while ((line = await stream.ReadLineAsync()) != null)
                {
                    await stream.WriteLineAsync(line);
                }
            }
示例#3
0
            protected override async Task MainLoop(ILineBasedStream serverStream, ILineBasedStream clientStream)
            {
                await serverStream.WriteLineAsync("SERVER OK");

                var line = await clientStream.ReadLineAsync();

                if (!line.Equals("SERVER OK"))
                {
                    throw new ConnectionException("Got unexpected output from server: '{0}'", line);
                }
                await clientStream.WriteLineAsync("CLIENT OK");

                line = await serverStream.ReadLineAsync();

                if (!line.Equals("CLIENT OK"))
                {
                    throw new ConnectionException("Got unexpected output from client: '{0}'", line);
                }
                if ((Flags & MyFlags.ServerSendsExtra) != 0)
                {
                    await serverStream.WriteLineAsync("EXTRA LINE FROM SERVER!");
                }
                if ((Flags & MyFlags.ClientSendsExtra) != 0)
                {
                    await clientStream.WriteLineAsync("EXTRA LINE FROM CLIENT!");
                }
                if ((Flags & MyFlags.ServerClosesFirst) != 0)
                {
                    await Server.Shutdown(true, false);

                    line = await clientStream.ReadLineAsync();

                    if (line != null)
                    {
                        throw new ConnectionException("Got unexpected line after server sent close");
                    }
                }
                if ((Flags & MyFlags.ClientClosesFirst) != 0)
                {
                    await Client.Shutdown(true, false);

                    line = await serverStream.ReadLineAsync();

                    if (line != null)
                    {
                        throw new ConnectionException("Got unexpected line after client sent close");
                    }
                }
                if ((Flags & MyFlags.DuplicateClose) != 0)
                {
                    await Shutdown(true, true);
                }
                await Shutdown(true, true);

                Close();
            }
            protected override async Task MainLoop(ILineBasedStream serverStream, ILineBasedStream clientStream)
            {
                await serverStream.WriteLineAsync("OK");

                var line = await clientStream.ReadLineAsync();

                if (!line.Equals("OK"))
                {
                    throw new ConnectionException("Got unexpected output '{0}'", line);
                }
                await Shutdown(SupportsCleanShutdown, true);

                Close();
            }
示例#5
0
 protected abstract Task MainLoop(ILineBasedStream stream);
示例#6
0
 protected abstract Task MainLoop(ILineBasedStream serverStream, ILineBasedStream clientStream);
示例#7
0
			protected override async Task MainLoop (ILineBasedStream serverStream, ILineBasedStream clientStream)
			{
				await serverStream.WriteLineAsync ("SERVER OK");
				var line = await clientStream.ReadLineAsync ();
				if (!line.Equals ("SERVER OK"))
					throw new ConnectionException ("Got unexpected output from server: '{0}'", line);
				await clientStream.WriteLineAsync ("CLIENT OK");
				line = await serverStream.ReadLineAsync ();
				if (!line.Equals ("CLIENT OK"))
					throw new ConnectionException ("Got unexpected output from client: '{0}'", line);
				if ((Flags & MyFlags.ServerSendsExtra) != 0)
					await serverStream.WriteLineAsync ("EXTRA LINE FROM SERVER!");
				if ((Flags & MyFlags.ClientSendsExtra) != 0)
					await clientStream.WriteLineAsync ("EXTRA LINE FROM CLIENT!");
				if ((Flags & MyFlags.ServerClosesFirst) != 0) {
					await Server.Shutdown (true, false);
					line = await clientStream.ReadLineAsync ();
					if (line != null)
						throw new ConnectionException ("Got unexpected line after server sent close");
				}
				if ((Flags & MyFlags.ClientClosesFirst) != 0) {
					await Client.Shutdown (true, false);
					line = await serverStream.ReadLineAsync ();
					if (line != null)
						throw new ConnectionException ("Got unexpected line after client sent close");
				}
				if ((Flags & MyFlags.DuplicateClose) != 0)
					await Shutdown (true, true);
				await Shutdown (true, true);
				Close ();
			}