0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-09-29 04:08:54 +02:00

modules/client/sync: Add event_idx to accept struct; move top object construction to handlers.

This commit is contained in:
Jason Volk 2019-02-27 15:24:48 -08:00
parent 85cae708db
commit f91f6226a6
2 changed files with 32 additions and 11 deletions

View file

@ -129,11 +129,6 @@ ircd::m::sync::handle_get(client &client,
log, "request %s", loghead(data) log, "request %s", loghead(data)
}; };
json::stack::object object
{
*data.out
};
const bool shortpolled const bool shortpolled
{ {
range.first > range.second? range.first > range.second?
@ -159,6 +154,11 @@ ircd::m::sync::handle_get(client &client,
void void
ircd::m::sync::empty_response(data &data) ircd::m::sync::empty_response(data &data)
{ {
json::stack::object top
{
*data.out
};
// Empty objects added to output otherwise Riot b0rks. // Empty objects added to output otherwise Riot b0rks.
json::stack::object json::stack::object
{ {
@ -222,6 +222,11 @@ try
*data.out *data.out
}; };
json::stack::object top
{
*data.out
};
bool ret{false}; bool ret{false};
m::sync::for_each(string_view{}, [&data, &ret] m::sync::for_each(string_view{}, [&data, &ret]
(item &item) (item &item)
@ -308,6 +313,11 @@ try
*data.out *data.out
}; };
json::stack::object top
{
*data.out
};
const unique_buffer<mutable_buffer> buf const unique_buffer<mutable_buffer> buf
{ {
96_KiB //TODO: XXX 96_KiB //TODO: XXX
@ -420,7 +430,18 @@ ircd::m::sync::linear_proffer_event(data &data,
data.out, &out data.out, &out
}; };
return linear_proffer_event_one(data)? json::stack::object top
{
*data.out
};
const bool success
{
linear_proffer_event_one(data)
};
top.~object();
return success?
size(out.completed()): size(out.completed()):
0UL; 0UL;
} }
@ -430,11 +451,6 @@ ircd::m::sync::linear_proffer_event(data &data,
bool bool
ircd::m::sync::linear_proffer_event_one(data &data) ircd::m::sync::linear_proffer_event_one(data &data)
{ {
json::stack::object top
{
*data.out
};
return !m::sync::for_each(string_view{}, [&data] return !m::sync::for_each(string_view{}, [&data]
(item &item) (item &item)
{ {

View file

@ -37,6 +37,7 @@ namespace ircd::m::sync::longpoll
{ {
json::strung strung; json::strung strung;
std::string client_txnid; std::string client_txnid;
event::idx event_idx;
accepted(const m::vm::eval &eval) accepted(const m::vm::eval &eval)
:strung :strung
@ -49,6 +50,10 @@ namespace ircd::m::sync::longpoll
eval.copts->client_txnid: eval.copts->client_txnid:
string_view{} string_view{}
} }
,event_idx
{
eval.sequence
}
{ {
const json::object object{this->strung}; const json::object object{this->strung};
static_cast<m::event &>(*this) = m::event{object}; static_cast<m::event &>(*this) = m::event{object};