// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information. using System; using System.IO; using System.Text; using System.Threading.Tasks; namespace Microsoft.AspNet.SignalR.Hosting { /// /// Extension methods for . /// public static class ResponseExtensions { /// /// Closes the connection to a client with optional data. /// /// The . /// The data to write to the connection. /// A task that represents when the connection is closed. public static Task End(this IResponse response, string data) { if (response == null) { throw new ArgumentNullException("response"); } var bytes = Encoding.UTF8.GetBytes(data); response.Write(new ArraySegment(bytes, 0, bytes.Length)); return response.End(); } } }