All Downloads are FREE. Search and download functionalities are using the official Maven repository.

colesico.framework.rpc.teleapi.writer.RpcProfileWriter Maven / Gradle / Ivy

The newest version!
package colesico.framework.rpc.teleapi.writer;

import colesico.framework.profile.Profile;
import colesico.framework.profile.teleapi.ProfileSerializer;
import colesico.framework.rpc.teleapi.BasicEnvelope;
import colesico.framework.rpc.teleapi.RpcTWContext;
import colesico.framework.rpc.teleapi.RpcTeleWriter;

import javax.inject.Singleton;

@Singleton
public class RpcProfileWriter implements RpcTeleWriter {

    protected final ProfileSerializer profileSerializer;

    public RpcProfileWriter(ProfileSerializer profileSerializer) {
        this.profileSerializer = profileSerializer;
    }

    @Override
    public void write(Profile value, RpcTWContext context) {
        BasicEnvelope env = (BasicEnvelope) context.getResponse();
        if (value != null) {
            env.setProfile(profileSerializer.serialize(value));
        } else {
            env.setProfile(new byte[0]);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy