xin.alum.aim.model.Sent Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aim-starter Show documentation
Show all versions of aim-starter Show documentation
aim-starter 基于netty的WebSocket和Socket通信包
/*
* Copyright 2013-2019 Xia Jun([email protected]).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
***************************************************************************************
* *
* Website : http://www.farsunset.com *
* *
***************************************************************************************
*/
package xin.alum.aim.model;
import com.google.protobuf.Any;
import lombok.Data;
import lombok.SneakyThrows;
import xin.alum.aim.AIM;
import xin.alum.aim.constant.AIMConstant;
import xin.alum.aim.model.proto.Packet;
import xin.alum.aim.model.proto.ProtoJsonUtil;
import xin.alum.aim.util.GZipUtil;
/**
* java |android 客户端请求结构
*/
@Data
public class Sent extends DBase {
@Override
public int getType() {
return AIMConstant.DATA_TYPE_SENT;
}
public Sent() {
super();
}
public Sent(String key) {
super(key);
}
public Sent(String key, long timestamp) {
super(key, timestamp);
}
public Sent(String key, long timestamp, com.google.protobuf.Message data) {
super(key, timestamp);
this.setData(data);
}
public Sent(String key, com.google.protobuf.Message data) {
super(key);
this.setData(data);
}
@Override
public Packet.Sent toBuilder() {
Packet.Sent.Builder builder = Packet.Sent.newBuilder();
builder.setKey(this.getKey());
builder.setTimestamp(this.getTimestamp());
if (data != null) {
builder.setData(Any.pack(data));
}
return builder.build();
}
@SneakyThrows
public String toString() {
return new ProtoJsonUtil(Packet.Data.getDescriptor()).toJson(toBuilder());
}
}