Merge branch 'master' of github.com:realm/realm-js into yg/windows-sync

# Conflicts:
#	dependencies.list
This commit is contained in:
Yavor Georgiev 2017-10-12 21:43:10 +02:00
commit 7efcc7e594
No known key found for this signature in database
GPG Key ID: 83FC145DA0CCA9C3
4 changed files with 25 additions and 4 deletions

View File

@ -1,4 +1,4 @@
2.0.0-rc20 Release notes (2017-10-11)
2.0.0 Release notes (2017-10-12)
=============================================================
### Breaking changes
* None
@ -16,7 +16,7 @@
* Upgrading to Realm Object Server 2.0.0-rc.4.
* OpenSSL for Android is distributed in a separate package, and the build system needed updates to accommendate this.
* Added `-fvisibility=hidden` to Android builds (reduces size of `.so` file).
* Add `Session._overrideServer` to force an existing session to connect to a different server.
2.0.0-rc19 Release notes (2017-10-7)
=============================================================

View File

@ -1,5 +1,5 @@
PACKAGE_NAME=realm-js
VERSION=2.0.0-rc20
VERSION=2.0.0-rc21
REALM_CORE_VERSION=4.0.2
REALM_SYNC_VERSION=2.0.1
REALM_OBJECT_SERVER_VERSION=2.0.0-rc.4

View File

@ -1,7 +1,7 @@
{
"name": "realm",
"description": "Realm is a mobile database: an alternative to SQLite and key-value stores",
"version": "2.0.0-rc20",
"version": "2.0.0-rc21",
"license": "Apache-2.0",
"homepage": "https://realm.io",
"keywords": [

View File

@ -179,6 +179,7 @@ class SessionClass : public ClassDefinition<T, WeakSession> {
using Object = js::Object<T>;
using Value = js::Value<T>;
using ReturnValue = js::ReturnValue<T>;
using Arguments = js::Arguments<T>;
public:
std::string const name = "Session";
@ -196,6 +197,8 @@ public:
static void add_progress_notification(ContextType ctx, FunctionType, ObjectType this_object, size_t argc, const ValueType arguments[], ReturnValue &);
static void remove_progress_notification(ContextType ctx, FunctionType, ObjectType this_object, size_t argc, const ValueType arguments[], ReturnValue &);
static void override_server(ContextType ctx, ObjectType this_object, Arguments args, ReturnValue&);
PropertyMap<T> const properties = {
{"config", {wrap<get_config>, nullptr}},
{"user", {wrap<get_user>, nullptr}},
@ -206,6 +209,7 @@ public:
MethodMap<T> const methods = {
{"_simulateError", wrap<simulate_error>},
{"_refreshAccessToken", wrap<refresh_access_token>},
{"_overrideServer", wrap<override_server>},
{"addProgressNotification", wrap<add_progress_notification>},
{"removeProgressNotification", wrap<remove_progress_notification>},
};
@ -511,6 +515,23 @@ void SessionClass<T>::remove_progress_notification(ContextType ctx, FunctionType
}
}
template<typename T>
void SessionClass<T>::override_server(ContextType ctx, ObjectType this_object, Arguments args, ReturnValue&) {
args.validate_count(2);
std::string address = Value::validated_to_string(ctx, args[0], "address");
double port = Value::validated_to_number(ctx, args[1], "port");
if (port < 1 || port > 65535 || uint16_t(port) != port) {
std::ostringstream message;
message << "Invalid port number. Expected an integer in the range 1-65,535, got '" << port << "'";
throw std::invalid_argument(message.str());
}
if (auto session = get_internal<T, SessionClass<T>>(this_object)->lock()) {
session->override_server(std::move(address), uint16_t(port));
}
}
template<typename T>
class SyncClass : public ClassDefinition<T, void*> {
using GlobalContextType = typename T::GlobalContext;