add support for logging out

This commit is contained in:
Ari Lazier 2016-10-20 13:07:45 -07:00
parent dfc10a5a42
commit e52351fc50
2 changed files with 16 additions and 5 deletions

View File

@ -80,6 +80,11 @@ public:
{"all", {wrap<all_users>, nullptr}}, {"all", {wrap<all_users>, nullptr}},
}; };
static void logout(ContextType, ObjectType, size_t, const ValueType[], ReturnValue &);
MethodMap<T> const methods = {
{"logout", wrap<logout>}
};
}; };
template<typename T> template<typename T>
@ -109,7 +114,8 @@ template<typename T>
void UserClass<T>::create_user(ContextType ctx, ObjectType this_object, size_t argc, const ValueType arguments[], ReturnValue &return_value) { void UserClass<T>::create_user(ContextType ctx, ObjectType this_object, size_t argc, const ValueType arguments[], ReturnValue &return_value) {
validate_argument_count(argc, 3, 4); validate_argument_count(argc, 3, 4);
SharedUser *user = new SharedUser(SyncManager::shared().get_user(Value::validated_to_string(ctx, arguments[1]), SharedUser *user = new SharedUser(SyncManager::shared().get_user(
Value::validated_to_string(ctx, arguments[1]),
Value::validated_to_string(ctx, arguments[2]), Value::validated_to_string(ctx, arguments[2]),
(std::string)Value::validated_to_string(ctx, arguments[0]), (std::string)Value::validated_to_string(ctx, arguments[0]),
Value::validated_to_boolean(ctx, arguments[3]))); Value::validated_to_boolean(ctx, arguments[3])));
@ -125,6 +131,11 @@ void UserClass<T>::all_users(ContextType ctx, ObjectType object, ReturnValue &re
return_value.set(Object::create_array(ctx, user_vector)); return_value.set(Object::create_array(ctx, user_vector));
} }
template<typename T>
void UserClass<T>::logout(ContextType ctx, ObjectType object, size_t, const ValueType[], ReturnValue &) {
get_internal<T, UserClass<T>>(object)->get()->log_out();
}
template<typename T> template<typename T>
class SyncClass : public ClassDefinition<T, void *> { class SyncClass : public ClassDefinition<T, void *> {
using GlobalContextType = typename T::GlobalContext; using GlobalContextType = typename T::GlobalContext;

@ -1 +1 @@
Subproject commit 1cf28ec004b20353c175feb669c8d84943282035 Subproject commit e4a0ff9493c1559fae7ec64a42fa87dc52be8fd2