MCPcopy Create free account
hub / github.com/DeNA/PacketProxy / receive

Method receive

src/main/java/core/packetproxy/DuplexSync.java:87–125  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

85 }
86
87 @Override
88 public byte[] receive() throws Exception {
89 byte[] input_data = new byte[100 * 1024];
90
91 ByteArrayOutputStream bin = new ByteArrayOutputStream();
92 ByteArrayOutputStream bout = new ByteArrayOutputStream();
93
94 int length = 0;
95 while ((length = in.read(input_data, 0, input_data.length)) >= 0) {
96
97 bin.write(input_data, 0, length);
98
99 int packetLen = 0;
100 while ((packetLen = callOnServerPacketReceived(bin.toByteArray())) > 0) {
101
102 byte[] packetData = ArrayUtils.subarray(bin.toByteArray(), 0, packetLen);
103 byte[] restData = ArrayUtils.subarray(bin.toByteArray(), packetLen, bin.size());
104 bin.reset();
105 bin.write(restData);
106
107 callOnServerChunkArrived(packetData);
108
109 byte[] available_data = callOnServerChunkAvailable();
110 if (available_data == null || available_data.length == 0) {
111
112 continue;
113 }
114 do {
115
116 byte[] decoded = callOnServerChunkReceived(available_data);
117 bout.write(decoded);
118 available_data = callOnServerChunkAvailable();
119 } while (available_data != null && available_data.length > 0);
120 byte[] encoded = callOnServerChunkSend(bout.toByteArray());
121 return encoded;
122 }
123 }
124 return null;
125 }
126
127 @Override
128 public void close() throws Exception {

Callers 1

createConnectionMethod · 0.95

Calls 10

callOnServerChunkSendMethod · 0.80
writeMethod · 0.65
readMethod · 0.45
toByteArrayMethod · 0.45
sizeMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected