Adding _getExitingUser to Chrome debugger support library. (#1628)
* Adding _getExitingUser to Chrome debugger support library.
This commit is contained in:
parent
0c6e254494
commit
a996a1a8b8
14
CHANGELOG.md
14
CHANGELOG.md
|
@ -1,3 +1,17 @@
|
|||
X.Y.Z Release notes
|
||||
=============================================================
|
||||
### Breaking changes
|
||||
* None.
|
||||
|
||||
### Enhancements
|
||||
* None.
|
||||
|
||||
### Bug fixes
|
||||
* [Object Server] Added `_getExitingUser` to the Chrome debugging support library.
|
||||
|
||||
### Internal
|
||||
* None.
|
||||
|
||||
2.2.3 Release notes (2018-1-17)
|
||||
=============================================================
|
||||
### Breaking changes
|
||||
|
|
|
@ -77,6 +77,12 @@ export function _adminUser(args) {
|
|||
return deserialize(undefined, result);
|
||||
}
|
||||
|
||||
export function _getExistingUser(args) {
|
||||
args = args.map((arg) => serialize(null, arg));
|
||||
const result = sendRequest('_getExistingUser', { arguments: args });
|
||||
return deserialize(undefined, result);
|
||||
}
|
||||
|
||||
export function callMethod(realmId, id, name, args) {
|
||||
if (args) {
|
||||
args = args.map((arg) => serialize(realmId, arg));
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
import { createUser as createUserRPC, _adminUser as _adminUserRPC, getAllUsers as getAllUsersRPC } from './rpc';
|
||||
import { createUser as createUserRPC, _adminUser as _adminUserRPC, getAllUsers as getAllUsersRPC, _getExistingUser as _getExistingUserRPC } from './rpc';
|
||||
import { keys, objectTypes } from './constants';
|
||||
import { createMethods } from './util';
|
||||
|
||||
|
@ -35,6 +35,10 @@ export default class User {
|
|||
static get all() {
|
||||
return getAllUsersRPC();
|
||||
}
|
||||
|
||||
static _getExistinguser() {
|
||||
return _getExistingUserRPC();
|
||||
}
|
||||
}
|
||||
|
||||
createMethods(User.prototype, objectTypes.USER, [
|
||||
|
|
22
src/rpc.cpp
22
src/rpc.cpp
|
@ -253,6 +253,28 @@ RPCServer::RPCServer() {
|
|||
JSObjectRef user_object = (JSObjectRef)jsc::Function::call(m_context, create_user_method, arg_count, arg_values);
|
||||
return (json){{"result", serialize_json_value(user_object)}};
|
||||
};
|
||||
m_requests["/_getExistingUser"] = [this](const json dict) {
|
||||
JSObjectRef realm_constructor = m_session_id ? JSObjectRef(m_objects[m_session_id]) : NULL;
|
||||
if (!realm_constructor) {
|
||||
throw std::runtime_error("Realm constructor not found!");
|
||||
}
|
||||
|
||||
JSObjectRef sync_constructor = (JSObjectRef)jsc::Object::get_property(m_context, realm_constructor, "Sync");
|
||||
JSObjectRef user_constructor = (JSObjectRef)jsc::Object::get_property(m_context, sync_constructor, "User");
|
||||
JSObjectRef create_user_method = (JSObjectRef)jsc::Object::get_property(m_context, user_constructor, "_getExistingUser");
|
||||
|
||||
json::array_t args = dict["arguments"];
|
||||
size_t arg_count = args.size();
|
||||
JSValueRef arg_values[arg_count];
|
||||
|
||||
for (size_t i = 0; i < arg_count; i++) {
|
||||
arg_values[i] = deserialize_json_value(args[i]);
|
||||
}
|
||||
|
||||
JSObjectRef user_object = (JSObjectRef)jsc::Function::call(m_context, create_user_method, arg_count, arg_values);
|
||||
return (json){{"result", serialize_json_value(user_object)}};
|
||||
|
||||
};
|
||||
m_requests["/call_method"] = [this](const json dict) {
|
||||
JSObjectRef object = m_objects[dict["id"].get<RPCObjectID>()];
|
||||
std::string method_string = dict["name"].get<std::string>();
|
||||
|
|
Loading…
Reference in New Issue