New file |
| | |
| | | package com.hdl.sdk.link.socket.codec;
|
| | |
|
| | | import com.hdl.sdk.link.socket.bean.Packet;
|
| | |
|
| | | import java.util.ArrayList;
|
| | | import java.util.List;
|
| | |
|
| | | /**
|
| | | * Created by Tong on 2021/9/23.
|
| | | */
|
| | | public class MessagePipeLine implements IMessagePipeLine, IHandleMessage {
|
| | |
|
| | | public final List<IHandleFlow> queue = new ArrayList<>();
|
| | |
|
| | | @Override
|
| | | public void add(IHandleFlow flow) {
|
| | | queue.add(flow);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public synchronized void clear() {
|
| | | queue.clear();
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void read(Packet packet) throws Exception {
|
| | | for (int i = 0; i < queue.size(); i++) {
|
| | | IHandleFlow flow = queue.get(i);
|
| | | Object read = flow.read(packet);
|
| | | // try {
|
| | | // out = Objects.requireNonNull(read);
|
| | | // } catch (Exception ignored) {
|
| | | // }
|
| | | }
|
| | | }
|
| | |
|
| | | // @Override
|
| | | // public byte[] write(Packet packet) throws Exception {
|
| | | // for (int i = 0; i < queue.size(); i++) {
|
| | | // IHandleFlow flow = queue.get(i);
|
| | | // byte[] write = flow.write(packet);
|
| | | // }
|
| | | // return new byte[0];
|
| | | // }
|
| | | }
|