Пример #1
0
 public override void Execute(CommandData data)
 {
     foreach (var item in CommandDataPersistence.Instance.GetMessagesFor(data.Recipient))
     {
         data.SendBack(item);
     }
 }
Пример #2
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)));
        }
Пример #3
0
        public override void Execute(CommandData data)
        {
            var returnData = ExecuteWithReturn(data);

            // set headers
            returnData.Type      = "response";
            returnData.Recipient = data.SenderId;
            returnData.SenderId  = data.Recipient;

            // wrap it into a container so receiver knows to what request it coresponds to
            returnData.message = IEncryption.ConcatBytes(BitConverter.GetBytes(data.MessageId), returnData.message);
            data.SendBack(returnData);
            //SendTo(data.sId, user.PublicId, "createdUser");
        }
Пример #4
0
        public override void Execute(CommandData data)
        {
            var result = new PublicUserInfo();
            var user   = EntityManager.Instance.GetEntity <CoflnetUser> (data.Recipient);

            result.userName = user.UserName;
            result.GetAccess().Owner = user.Id;

            if (user.PrivacySettings["share-profile-picture"])
            {
                result.profilePicture = user.ProfileImage;
            }

            data.SendBack(CommandData.CreateCommandData <BasicInfoResponse, PublicUserInfo> (data.SenderId, result));
        }
Пример #5
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");
        }