Fixed functions with void return
This commit is contained in:
parent
12392808f7
commit
e550ed32e2
@ -34,10 +34,10 @@ pub fn method_args(method: &crate::data::MethodTy) -> String {
|
||||
}
|
||||
|
||||
pub fn method_ret(method: &crate::data::MethodTy) -> String {
|
||||
if method.ret_stream || method.ret.is_none() {
|
||||
if method.ret_stream {
|
||||
String::new()
|
||||
} else {
|
||||
format!(": Promise<{}>", ty_to_str(method.ret.as_ref().unwrap()))
|
||||
format!(": Promise<{}>", method.ret.as_ref().map(ty_to_str).unwrap_or("void".into()))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -89,8 +89,9 @@ void mrpc::MRPCServer::msg_handler(const std::shared_ptr<restbed::Session> __c,
|
||||
}
|
||||
@for (name, ty) in m.args.iter().map(|a| (&a.name, ty_to_str(&a.ty))) { @ty @name; @name << json_get(__data, "@name");
|
||||
}
|
||||
@if m.ret_stream || m.ret.is_none() {@(s.name)_@(m.name)(@call_args(m));}
|
||||
else {send_msg(__c, @(s.name)_@(m.name)(@call_args(m)));}
|
||||
@if m.ret_stream {@(s.name)_@(m.name)(@call_args(m));}
|
||||
else if m.ret.is_some() {send_msg(__c, @(s.name)_@(m.name)(@call_args(m)));}
|
||||
else {@(s.name)_@(m.name)(@call_args(m)); send_msg(__c, nullptr);}
|
||||
@}}
|
||||
else @{ throw std::exception@{@}; @}
|
||||
@}}
|
||||
|
@ -24,6 +24,10 @@ mrpc::MRPCJWriter& operator>>(const mrpc::@e.name &v, mrpc::MRPCJWriter &w) @{
|
||||
return w;
|
||||
@}
|
||||
}
|
||||
inline mrpc::MRPCJWriter& operator>>(const std::nullptr_t &, mrpc::MRPCJWriter &w) @{
|
||||
w.Null();
|
||||
return w;
|
||||
@}
|
||||
|
||||
template<typename T>
|
||||
inline std::vector<T>& operator<<(std::vector<T> &v, const rapidjson::Value &j);
|
||||
|
@ -36,8 +36,10 @@ export class MRPCConnector @{
|
||||
else if m.ret_stream {fetchEventSource(this.url, @{
|
||||
method: 'POST',
|
||||
body: JSON.stringify(__msg),
|
||||
onmessage: __e => __cbk(JSON.parse(__e.data))
|
||||
@});} else {fetch(this.url, @{method: 'POST', body: JSON.stringify(__msg)@});}
|
||||
onmessage: __e => __cbk(JSON.parse(__e.data)),
|
||||
onerror: __e => @{throw __e;@},
|
||||
onclose: () => __cbk(null)
|
||||
@});} else {return fetch(this.url, @{method: 'POST', body: JSON.stringify(__msg)@}).then(__r => @{@});}
|
||||
@}
|
||||
}}
|
||||
@}
|
||||
|
Loading…
Reference in New Issue
Block a user