use of com.zx.sms.LongSMSMessage in project SMSGate by Lihuanghe.
the class AbstractLongMessageHandler method encode.
@Override
protected void encode(ChannelHandlerContext ctx, T requestMessage, List<Object> out) throws Exception {
if ((entity == null || entity.getSupportLongmsg() == SupportLongMessage.BOTH || entity.getSupportLongmsg() == SupportLongMessage.SEND) && requestMessage instanceof LongSMSMessage && needHandleLongMessage(requestMessage)) {
SmsMessage msgcontent = ((LongSMSMessage) requestMessage).getSmsMessage();
List<LongMessageFrame> frameList = LongMessageFrameHolder.INS.splitmsgcontent(msgcontent);
boolean first = true;
LongSMSMessage lmsg = (LongSMSMessage) requestMessage;
for (LongMessageFrame frame : frameList) {
T t = (T) lmsg.generateMessage(frame);
out.add(t);
}
} else {
out.add(requestMessage);
}
}
use of com.zx.sms.LongSMSMessage in project SMSGate by Lihuanghe.
the class ChannelUtil method syncWriteLongMsgToEntity.
public static <T extends BaseMessage> List<Promise<T>> syncWriteLongMsgToEntity(EndpointEntity e, BaseMessage msg) throws Exception {
EndpointConnector connector = e.getSingletonConnector();
if (connector == null)
return null;
if (msg instanceof LongSMSMessage) {
LongSMSMessage<BaseMessage> lmsg = (LongSMSMessage<BaseMessage>) msg;
if (!lmsg.isReport()) {
// 长短信拆分
SmsMessage msgcontent = lmsg.getSmsMessage();
List<LongMessageFrame> frameList = LongMessageFrameHolder.INS.splitmsgcontent(msgcontent);
// 保证同一条长短信,通过同一个tcp连接发送
List<BaseMessage> msgs = new ArrayList<BaseMessage>();
for (LongMessageFrame frame : frameList) {
BaseMessage basemsg = (BaseMessage) lmsg.generateMessage(frame);
msgs.add(basemsg);
}
return connector.synwrite(msgs);
}
}
Promise promise = connector.synwrite(msg);
if (promise == null) {
// 为空,可能是连接断了,直接返回
return null;
}
List<Promise<T>> arrPromise = new ArrayList<Promise<T>>();
arrPromise.add(promise);
return arrPromise;
}
Aggregations