public void Send(object value) { _context.Response.Write(_jsonStringifier.Stringify(value)); }
public override Task ProcessRequestAsync(HttpContext context) { Task task = null; var contextBase = new HttpContextWrapper(context); if (IsNegotiationRequest(context.Request)) { context.Response.ContentType = Json.MimeType; context.Response.Write(_jsonStringifier.Stringify(new { Url = VirtualPathUtility.ToAbsolute(context.Request.AppRelativeCurrentExecutionFilePath.Replace("/negotiate", "")), ClientId = _clientIdFactory.CreateClientId(contextBase) })); } else { _transport = GetTransport(contextBase); string clientId = contextBase.Request["clientId"]; // If there's no client id then this is a bad request if (String.IsNullOrEmpty(clientId)) { throw new InvalidOperationException("Protcol error: Missing client id."); } IEnumerable <string> groups = GetGroups(contextBase); Connection = CreateConnection(clientId, groups, contextBase); // Wire up the events we need _transport.Connected += () => { task = OnConnectedAsync(contextBase, clientId); }; _transport.Received += (data) => { task = OnReceivedAsync(clientId, data); }; _transport.Error += (e) => { task = OnErrorAsync(e); }; _transport.Disconnected += () => { task = OnDisconnectAsync(clientId); }; Func <Task> processRequestTask = _transport.ProcessRequest(Connection); if (processRequestTask != null) { if (task != null) { return(task.Success(_ => processRequestTask()).Unwrap()); } return(processRequestTask()); } } return(task ?? TaskAsyncHelper.Empty); }
public void Send(object value) { base.Send(_stringifier.Stringify(value)); }
public virtual void Send(object value) { _context.Response.ContentType = Json.MimeType; _context.Response.Write(_jsonStringifier.Stringify(value)); }