Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void downStream(Packet packet) throws BlazeException {
- ByteBuffer buffer = this.outBuffer;
- if (isInitialized()) {
- buffer.clear();
- OutputStream stream = ByteBufferUtils
- .getByteBufferOutputStream(buffer);
- try {
- packet.getPacketData().writeFramed(stream);
- stream.close();
- buffer.flip();
- int num = this.channel.send(buffer, packet.getTo());
- System.err.println("SENT " + num);
- } catch (IOException e) {
- throw new BlazeException("Failed to send Packet " + packet, e);
- }
- }
- }
- protected void doProcess() throws Exception {
- this.inBuffer.clear();
- SocketAddress address = this.channel.receive(this.inBuffer);
- ByteBuffer buffer = this.inBuffer;
- if (isInitialized()) {
- buffer.flip();
- if (buffer.remaining() > 0) {
- System.err.println("READING " + buffer.remaining());
- InputStream stream = ByteBufferUtils
- .getByteBufferInputStream(buffer);
- PacketData data = PacketData.parseFramed(stream);
- stream.close();
- Packet packet = new Packet(address, data);
- upStream(packet);
- }
- buffer.clear();
- }
- }
Add Comment
Please, Sign In to add comment