本文整理汇总了C#中PersistentResponse类的典型用法代码示例。如果您正苦于以下问题:C# PersistentResponse类的具体用法?C# PersistentResponse怎么用?C# PersistentResponse使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PersistentResponse类属于命名空间,在下文中一共展示了PersistentResponse类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Send
public override Task Send(PersistentResponse response)
{
var data = JsonSerializer.Stringify(response);
OnSending(data);
return Context.Response.WriteAsync("id: " + response.MessageId + "\n" + "data: " + data + "\n\n");
}
示例2: Send
public override Task Send(PersistentResponse response)
{
var data = JsonSerializer.Stringify(response);
OnSending(data);
return _socket.Send(data);
}
示例3: Send
public override void Send(PersistentResponse response)
{
Context.Response.Write("id: " + response.MessageId + "\n");
Context.Response.Write("data: " + JsonSerializer.Stringify(response) + "\n\n");
if (Context.Response.IsClientConnected)
{
Context.Response.Flush();
}
}
示例4: Send
public override Task Send(PersistentResponse response)
{
var data = JsonSerializer.Stringify(response);
OnSending(data);
if (Context.Response.IsClientConnected)
{
return Context.Response.WriteAsync("id: " + response.MessageId + "\n" + "data: " + data + "\n\n");
}
return TaskAsyncHelper.Empty;
}
示例5: Send
public override Task Send(PersistentResponse response)
{
OnSendingResponse(response);
OutputWriter.Write("<script>r(c, ");
JsonSerializer.Serialize(response, OutputWriter);
OutputWriter.Write(");</script>\r\n");
OutputWriter.Flush();
return Context.Response.FlushAsync().Catch(IncrementErrorCounters);
}
示例6: Send
public override Task Send(PersistentResponse response)
{
var data = JsonSerializer.Stringify(response);
OnSending(data);
var script = "<script>r(c, " + data + ");</script>\r\n";
if (_isDebug)
{
script += "<div>" + data + "</div>\r\n";
}
return Context.Response.WriteAsync(script);
}
示例7: Send
public override Task Send(PersistentResponse response)
{
OnSendingResponse(response);
OutputWriter.Write("id: ");
OutputWriter.Write(response.MessageId);
OutputWriter.WriteLine();
OutputWriter.Write("data: ");
JsonSerializer.Serialize(response, OutputWriter);
OutputWriter.WriteLine();
OutputWriter.WriteLine();
OutputWriter.Flush();
return Context.Response.FlushAsync().Catch(IncrementErrorCounters);
}
示例8: Send
public override Task Send(PersistentResponse response)
{
OnSendingResponse(response);
OutputWriter.Write("id: ");
OutputWriter.Write(response.MessageId);
OutputWriter.WriteLine();
OutputWriter.Write("data: ");
JsonSerializer.Stringify(response, OutputWriter);
OutputWriter.WriteLine();
OutputWriter.WriteLine();
OutputWriter.Flush();
return TaskAsyncHelper.Empty;
}
示例9: WriteJsonSkipsNullTransportDaa
public void WriteJsonSkipsNullTransportDaa()
{
// Arrange
var writer = new StringWriter();
var response = new PersistentResponse(m => m.Key == "key2");
response.Messages = new List<ArraySegment<Message>>();
response.MessageId = "Baz";
response.Messages.Add(new ArraySegment<Message>(new[] { new Message("1", "key", "value1"),
new Message("1", "key2", "value2") }, 0, 2));
// Act
((IJsonWritable)response).WriteJson(writer);
// Assert
Assert.Equal(@"{""MessageId"":""Baz"",""Disconnect"":false,""TimedOut"":false,""Messages"":[value1]}", writer.ToString());
}
示例10: Send
public override Task Send(PersistentResponse response)
{
var data = JsonSerializer.Stringify(response);
OnSending(data);
var script = String.Format(_sendTemplate, data);
if (_isDebug)
{
script += (String.Format(_debugTemplate, data));
}
if (Context.Response.IsClientConnected)
{
return Context.Response.WriteAsync(script);
}
return TaskAsyncHelper.Empty;
}
示例11: Send
public override void Send(PersistentResponse response)
{
var payload = JsonSerializer.Stringify(response);
OnSending(payload);
var script = String.Format(_sendTemplate, payload);
Context.Response.Write(script);
if (_isDebug)
{
Context.Response.Write(String.Format(_debugTemplate, payload));
}
if (Context.Response.IsClientConnected)
{
Context.Response.Flush();
}
}
示例12: WriteJsonWritesSkipsCommands
public void WriteJsonWritesSkipsCommands()
{
// Arrange
var writer = new StringWriter();
var response = new PersistentResponse(m => false);
response.Messages = new List<ArraySegment<Message>>();
response.TransportData = new Dictionary<string, object>();
response.TransportData["Groups"] = new List<string>
{
"g1"
};
response.MessageId = "Baz";
response.Messages.Add(new ArraySegment<Message>(new[] { new Message("1", "key", "value1") { CommandId = "something"},
new Message("1", "key2", "value2") }, 0, 2));
// Act
((IJsonWritable)response).WriteJson(writer);
// Assert
Assert.Equal(@"{""MessageId"":""Baz"",""Disconnect"":false,""TimedOut"":false,""TransportData"":{""Groups"":[""g1""]},""Messages"":[value2]}", writer.ToString());
}
示例13: Send
public virtual Task Send(PersistentResponse response)
{
HeartBeat.MarkConnection(this);
var data = _jsonSerializer.Stringify(response);
OnSending(data);
return Context.Response.WriteAsync(data);
}
示例14: Send
public override Task Send(PersistentResponse response)
{
return Send((object)response);
}
示例15: AddTransportData
private void AddTransportData(PersistentResponse response)
{
if (LongPollDelay > 0)
{
if (response.TransportData == null)
{
response.TransportData = new Dictionary<string, object>();
}
response.TransportData["LongPollDelay"] = LongPollDelay;
}
}