forked from l42111996/java-Kcp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
jinmiao
committed
Jun 21, 2019
1 parent
c28b2f4
commit 8ed51bb
Showing
9 changed files
with
163 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package kcp; | ||
|
||
import io.netty.buffer.ByteBuf; | ||
|
||
import java.nio.ByteBuffer; | ||
import java.util.zip.CRC32; | ||
|
||
/** | ||
* crc32校验 | ||
* Created by JinMiao | ||
* 2019-06-21. | ||
*/ | ||
public class Crc32OutPut implements KcpOutput { | ||
private KcpOutput output; | ||
private CRC32 crc32 = new CRC32(); | ||
private int headerOffset; | ||
|
||
protected Crc32OutPut(KcpOutput output,int headerOffset) { | ||
this.output = output; | ||
this.headerOffset = headerOffset; | ||
} | ||
@Override | ||
public void out(ByteBuf data, Kcp kcp) { | ||
ByteBuffer byteBuffer = data.nioBuffer(headerOffset+Ukcp.HEADER_CRC,data.readableBytes()-headerOffset-Ukcp.HEADER_CRC); | ||
crc32.reset(); | ||
crc32.update(byteBuffer); | ||
long checksum = crc32.getValue(); | ||
data.setInt(headerOffset, (int) checksum); | ||
output.out(data,kcp); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
import io.netty.buffer.ByteBuf; | ||
|
||
/** | ||
* fec | ||
* Created by JinMiao | ||
* 2018/7/27. | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters