All Projects → whirvis → JRakNet

whirvis / JRakNet

Licence: MIT license
A protocol implementation of the networking library RakNet.

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to JRakNet

netty-raknet
A reliable and high performance RakNet library designed with strict Netty patterns.
Stars: ✭ 24 (-76.92%)
Mutual labels:  udp, raknet
XAsyncSockets
XAsyncSockets is an efficient Python/MicroPython library of managed asynchronous sockets.
Stars: ✭ 28 (-73.08%)
Mutual labels:  udp
captcp
A open source program for TCP analysis of PCAP files
Stars: ✭ 110 (+5.77%)
Mutual labels:  udp
overload
📡 Overload DoS Tool (Layer 7)
Stars: ✭ 167 (+60.58%)
Mutual labels:  udp
okhoxi-serac
冰塔协议-传输层协议
Stars: ✭ 33 (-68.27%)
Mutual labels:  udp
RiptideSampleFPS
Sample FPS project using RiptideNetworking, and source code for the Riptide tutorials.
Stars: ✭ 80 (-23.08%)
Mutual labels:  udp
okdbc
A fast, light-weight key/value store with http & memcache(TCP/UDP) interface.
Stars: ✭ 28 (-73.08%)
Mutual labels:  udp
sthread
sthread(simple-thread):支持高并发的协程网络库
Stars: ✭ 27 (-74.04%)
Mutual labels:  udp
AndroidNetMonitor
This project aims to collect and analyze traffic information of Android.(采集手机发送和接收的报文简要信息,并且根据socket记录每个报文对应哪个手机app)
Stars: ✭ 25 (-75.96%)
Mutual labels:  udp
aioudp
Asyncio UDP server
Stars: ✭ 21 (-79.81%)
Mutual labels:  udp
lib32100
Library implementing port 32100 UDP Cloud protocol
Stars: ✭ 37 (-64.42%)
Mutual labels:  udp
udppunch
udppunch hole for wireguard
Stars: ✭ 123 (+18.27%)
Mutual labels:  udp
reactor-aeron
A reactive driver for Aeron transport (https://github.com/real-logic/aeron)
Stars: ✭ 43 (-58.65%)
Mutual labels:  udp
Packet Sender Mobile
iOS and Android version of Packet Sender
Stars: ✭ 58 (-44.23%)
Mutual labels:  udp
mongoose
Embedded Web Server
Stars: ✭ 8,968 (+8523.08%)
Mutual labels:  udp
vtun
A simple VPN written in Go.
Stars: ✭ 592 (+469.23%)
Mutual labels:  udp
ENet-CSharp
A improved fork of ENet, a tried and true networking library. C, C++, C# compatible.
Stars: ✭ 65 (-37.5%)
Mutual labels:  udp
udp-proxy-2020
A crappy UDP router for the year 2020 and beyond
Stars: ✭ 46 (-55.77%)
Mutual labels:  udp
gnb udp over tcp
gnb_udp_over_tcp 是一个为GNB开发的通过tcp链路中转UDP分组转发的服务
Stars: ✭ 32 (-69.23%)
Mutual labels:  udp
dperf
dperf is a DPDK based 100Gbps network performance and load testing software.
Stars: ✭ 1,320 (+1169.23%)
Mutual labels:  udp

apm Build Status

JRakNet

JRakNet is a networking library for Java which implements the UDP based protocol RakNet. This library was meant to be used for Minecraft servers and clients, but can still be used to create game servers and clients for other video games with ease. You can also read the JavaDocs

Protocol Info Version
Current protocol 10
Supported server protocol 10
Supported client protocol 10

Notes

  • Always use the newest version of JRakNet (with the exception of snapshots), including bug fix updates as they almost always fix major bugs, add new features, or have optimizations to make the API run faster. As a general rule, it is also not a good idea to fork this repository as it is almost always being updated like stated before. This means it is very possible for it to become out of date very quickly unless you are intending to create a new feature or fixing a bug to be merged back into the original repository through a pull request.
  • Some data packet IDs are reserved by RakNet. Because of this, it is recommended that all game packets not relating to RakNet begin with their own special ID (add a byte at the beginning of all packets that is not used as an internal packet ID by RakNet). It is also recommended that game servers and game clients do not use raw packets (the Netty based functions) at all unless it is absolutely necessary.

How to use with Maven

If you are using a release version, use this dependency:

<dependency>
    <groupId>com.whirvis</groupId>
    <artifactId>jraknet</artifactId>
    <version>2.12.3</version>
</dependency>

If you are wanting to use a snapshot version, use this repository and dependency:

<repository>
    <id>codemc-repo</id>
    <url>https://repo.codemc.org/repository/maven-public/</url>
</repository>
<dependency>
    <groupId>com.whirvis</groupId>
    <artifactId>jraknet</artifactId>
    <version>2.12.4-SNAPSHOT</version>
</dependency>

How to create a server

Creating a server in JRakNet is extremely easy, all it takes to create one can be seen here:

// Add loopback exemption for Minecraft
if (!UniversalWindowsProgram.MINECRAFT.setLoopbackExempt(true)) {
	System.err.println("Failed to add loopback exemption for Minecraft");
}

// Create server
RakNetServer server = new RakNetServer(19132, 10);
server.setIdentifier(new MinecraftIdentifier("JRakNet Example Server", 354, "1.11", 0, 10,
	server.getGloballyUniqueId(), "New World", "Survival"));

// Add listener
server.addListener(new RakNetServerListener() {

	// Client connected
	@Override
	public void onConnect(RakNetServer server, InetSocketAddress address, ConnectionType connectionType) {
		System.out.println("Client from address " + address + " has connected to the server");
	}
	
	// Client logged in
	@Override
	public void onLogin(RakNetServer server, RakNetClientPeer peer) {
		System.out.println("Client from address " + peer.getAddress() + " has logged in");
	}

	// Client disconnected
	@Override
	public void onDisconnect(RakNetServer server, InetSocketAddress address, RakNetClientPeer peer, String reason) {
		System.out.println("Client from address " + address
						+ " has disconnected from the server for reason \"" + reason + "\"");
	}

	// Packet received
	@Override
	public void handleMessage(RakNetServer server, RakNetClientPeer peer, RakNetPacket packet, int channel) {
		System.out.println("Client from address " + peer.getAddress() + " sent packet with ID "
				+ RakNet.toHexStringId(packet) + " on channel " + channel);
	}

});

// Start server
server.start();

This is a simple RakNet server that can be tested through Minecraft by going to the "Friends" tab where the server should show up. Once the server pops up, you should be able to click on it to trigger the connection and packet hooks.

How to enable loopback exemption

On Windows 10, applications that use the Universal Windows Program framework by default are not able to connect to servers that are running on the same machine as them. This annoying feature can be disabled by simply creating a UniversalWindowsProgram object with the first and only parameter being the ID of the application that you are wanting to be able to connect to. An example would be Microsoft's Edge which is Microsoft.MicrosoftEdge_8wekyb3d8bbwe. So, in order to enable loopback exemption, it would only take this:

UniversalWindowsProgram microsoftEdge = new UniversalWindowsProgram("Microsoft.MicrosoftEdge_8wekyb3d8bbwe");
if(!microsoftEdge.setLoopbackExempt(true)) {
	System.err.println("Failed to enable loopback exemption for Microsoft Edge");
}

Simple, right? Feel free to implement this if you are running on a non-Windows 10 machine. This implementation was made specifically to work even if your machine does not run Windows 10 or does not have Windows PowerShell installed. Of course, if you are not on a Windows 10 machine with Windows PowerShell installed there really is no way to properly check if your application is loopback exempted. However, I'm sure that this can be solved with the help of a user that has Windows 10 with Windows PowerShell if needed.

How to create a client

Creating a client in JRakNet is also very easy. The code required to create a client can be seen here:

// Create client
RakNetClient client = new RakNetClient();
		
// Add listener
client.addListener(new RakNetClientListener() {

	// Connected to server
	@Override
	public void onConnect(RakNetClient client, InetSocketAddress address, ConnectionType connectionType) {
		System.out.println("Successfully connected to server with address " + address);
	}
	
	// Logged into server
	@Override
	public void onLogin(RakNetClient client, RakNetServerPeer peer) {
		System.out.println("Successfully logged into server");
		client.disconnect();
	}

	// Disconnected from server
	@Override
	public void onDisconnect(RakNetClient client, InetSocketAddress address, RakNetServerPeer peer, String reason) {
		System.out.println("Successfully disconnected from server with address " + address + " for reason \"" + reason + "\"");
	}

});

// Connect to server
client.connect("sg.lbsg.net", 19132);

This is a simple RakNet client that attempts to connect to the main LBSG server. When it is connected, it closes the connection.


Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].