Exemple #1
0
        public override void Execute(CommandData data)
        {
            EntityId oldId;

            try
            {
                oldId = data.GetAs <CreationParamsBase>().options.OldId;
            }catch (Exception)
            {
                throw new CoflnetException("invalid_payload", "The payload of the command isn't of type CreationParamsBase nor derived from it");
            }
            var resource = CreateResource(data);

            resource.AssignId(data.CoreInstance.EntityManager);

            // make sure the owner is set
            resource.GetAccess().Owner = data.Recipient;

            // add the size to any data cap limit (tracking module)
            // TODO


            // it is possible that the return will not be received by the target in case it gets offline

            data.SendBack(CommandData.CreateCommandData <CreationResponseCommand, KeyValuePair <EntityId, EntityId> >
                              (data.SenderId, new KeyValuePair <EntityId, EntityId>(oldId, resource.Id)));
        }
Exemple #2
0
        public override Entity CreateResource(CommandData data)
        {
            var res = CreateReceivable(data);

            res.publicKey = data.GetAs <Params>().KeyPair.publicKey;
            return(res);
        }
Exemple #3
0
        public override Entity CreateResource(CommandData data)
        {
            CreateUserRequest request = data.GetAs <CreateUserRequest> ();
            var user = new CoflnetUser(data.SenderId);

            user.PrivacySettings = request.privacySettings;
            return(user);
        }
Exemple #4
0
        public override void Execute(CommandData data)
        {
            var okay = data.GetAs <KeyValuePair <string, string> > ();


            data.CoreInstance.EntityManager
            .GetEntity <CoflnetUser> (data.Recipient)
            .KeyValues[okay.Key] = okay.Value;
        }
Exemple #5
0
        public override void Execute(CommandData data)
        {
            var response = data.GetAs <RegisterUserResponse> ();

            ConfigController.UserSettings.userId     = response.id;
            ConfigController.UserSettings.userSecret = response.secret;

            // Login
        }
Exemple #6
0
        public override CommandData ExecuteWithReturn(CommandData data)
        {
            String result;

            data.GetTargetAs <CoflnetUser> ()
            .KeyValues
            .TryGetValue(data.GetAs <string> (), out result);

            var returnData = new CommandData();

            returnData.SerializeAndSet <String> (result);
            return(returnData);
        }
Exemple #7
0
        public override void Execute(CommandData data)
        {
            RegisterUserRequest request = data.GetAs <RegisterUserRequest> ();

            // validate captcha Token
            // todo :)

            CoflnetUser user = CoflnetUser.Generate(request.clientId, data.CoreInstance.EntityManager);

            user.PrivacySettings = request.privacySettings;

            var response = new RegisterUserResponse();

            response.id     = user.Id;
            response.secret = user.Secret;


            data.SendBack(CommandData.CreateCommandData <RegisteredUser, RegisterUserResponse> (data.SenderId, response));
            //SendTo(data.sId, user.PublicId, "createdUser");
        }
Exemple #8
0
        public override void Execute(CommandData data)
        {
            var dataParams = data.GetAs <ReceiveConfirmParams> ();

            CommandDataPersistence.Instance.Remove(data.SenderId, dataParams.sender, dataParams.messageId);
        }
Exemple #9
0
 public override void Execute(CommandData data)
 {
     ConfigController.ActiveUserId = data.GetAs <EntityId> ();
 }
Exemple #10
0
 /// <summary>
 /// Execute the command logic with specified data.
 /// </summary>
 /// <param name="data"><see cref="CommandData"/> passed over the network .</param>
 public override void Execute(CommandData data)
 {
     // execute it on the local user
     data.CoreInstance.ReceiveCommand(data.GetAs <CommandData>());
 }
Exemple #11
0
        /// <summary>
        /// Execute the command logic with specified data.
        /// </summary>
        /// <param name="data"><see cref="CommandData"/> passed over the network .</param>
        public override void Execute(CommandData data)
        {
            var param = data.GetAs <KeyValuePair <EntityId, AccessMode> > ();

            data.GetTargetAs <Entity> ().Access.Authorize(param.Key, param.Value);
        }
Exemple #12
0
        public override void Execute(CommandData data)
        {
            var pair = data.GetAs <KeyValuePair <EntityId, EntityId> >();

            data.CoreInstance.EntityManager.UpdateIdAndAddRedirect(pair.Key, pair.Value);
        }