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))); }
public override Entity CreateResource(CommandData data) { var res = CreateReceivable(data); res.publicKey = data.GetAs <Params>().KeyPair.publicKey; return(res); }
public override Entity CreateResource(CommandData data) { CreateUserRequest request = data.GetAs <CreateUserRequest> (); var user = new CoflnetUser(data.SenderId); user.PrivacySettings = request.privacySettings; return(user); }
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; }
public override void Execute(CommandData data) { var response = data.GetAs <RegisterUserResponse> (); ConfigController.UserSettings.userId = response.id; ConfigController.UserSettings.userSecret = response.secret; // Login }
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); }
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"); }
public override void Execute(CommandData data) { var dataParams = data.GetAs <ReceiveConfirmParams> (); CommandDataPersistence.Instance.Remove(data.SenderId, dataParams.sender, dataParams.messageId); }
public override void Execute(CommandData data) { ConfigController.ActiveUserId = data.GetAs <EntityId> (); }
/// <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>()); }
/// <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); }
public override void Execute(CommandData data) { var pair = data.GetAs <KeyValuePair <EntityId, EntityId> >(); data.CoreInstance.EntityManager.UpdateIdAndAddRedirect(pair.Key, pair.Value); }