72 lines
1.7 KiB
Java
72 lines
1.7 KiB
Java
/*
|
|
* This file is part of the Wildfire Chat package.
|
|
* (c) Heavyrain2012 <[email protected]>
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
package cn.wildfirechat.pojos;
|
|
|
|
import cn.wildfirechat.proto.ProtoConstants;
|
|
import cn.wildfirechat.proto.WFCMessage;
|
|
import io.netty.util.internal.StringUtil;
|
|
|
|
import java.util.List;
|
|
|
|
public class MulticastMessageData {
|
|
private String sender;
|
|
private int line;
|
|
private MessagePayload payload;
|
|
private List<String> targets;
|
|
|
|
public String getSender() {
|
|
return sender;
|
|
}
|
|
|
|
public void setSender(String sender) {
|
|
this.sender = sender;
|
|
}
|
|
|
|
public int getLine() {
|
|
return line;
|
|
}
|
|
|
|
public void setLine(int line) {
|
|
this.line = line;
|
|
}
|
|
|
|
public MessagePayload getPayload() {
|
|
return payload;
|
|
}
|
|
|
|
public void setPayload(MessagePayload payload) {
|
|
this.payload = payload;
|
|
}
|
|
|
|
public static boolean isValide(MulticastMessageData sendMessageData) {
|
|
if(sendMessageData == null ||
|
|
StringUtil.isNullOrEmpty(sendMessageData.getSender()) ||
|
|
sendMessageData.getPayload() == null) {
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public WFCMessage.MultiCastMessage toProtoMessage() {
|
|
return WFCMessage.MultiCastMessage.newBuilder().setFromUser(sender)
|
|
.setLine(line)
|
|
.setContent(payload.toProtoMessageContent())
|
|
.addAllTo(targets)
|
|
.build();
|
|
}
|
|
|
|
public List<String> getTargets() {
|
|
return targets;
|
|
}
|
|
|
|
public void setTargets(List<String> targets) {
|
|
this.targets = targets;
|
|
}
|
|
}
|