colesico.framework.rpc.teleapi.writer.RpcProfileWriter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of colesico-rpc Show documentation
Show all versions of colesico-rpc Show documentation
Colesico framework Remote Procedure Call for Services
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]);
}
}
}