TauNet

A super easy to use networking library.

License

License

MIT
Categories

Categories

Net
GroupId

GroupId

com.joepritzel
ArtifactId

ArtifactId

taunet
Last Version

Last Version

1.4
Release Date

Release Date

Type

Type

jar
Description

Description

TauNet
A super easy to use networking library.
Project URL

Project URL

https://github.com/Joe0/TauNet
Source Code Management

Source Code Management

https://github.com/Joe0/TauNet

Download taunet

How to add to project

<!-- https://jarcasting.com/artifacts/com.joepritzel/taunet/ -->
<dependency>
    <groupId>com.joepritzel</groupId>
    <artifactId>taunet</artifactId>
    <version>1.4</version>
</dependency>
// https://jarcasting.com/artifacts/com.joepritzel/taunet/
implementation 'com.joepritzel:taunet:1.4'
// https://jarcasting.com/artifacts/com.joepritzel/taunet/
implementation ("com.joepritzel:taunet:1.4")
'com.joepritzel:taunet:jar:1.4'
<dependency org="com.joepritzel" name="taunet" rev="1.4">
  <artifact name="taunet" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.joepritzel', module='taunet', version='1.4')
)
libraryDependencies += "com.joepritzel" % "taunet" % "1.4"
[com.joepritzel/taunet "1.4"]

Dependencies

compile (3)

Group / Artifact Type Version
com.joepritzel : feather jar 1.1
io.netty : netty-all jar 4.0.20.Final
com.google.code.gson : gson jar 2.2.4

Project Modules

There are no modules declared in this project.

TauNet

A super easy to use networking library.

Table of contents:

Features

  • Ease of Use - TauNet is made to be easy to use, even for beginners, as it helps enforce good programming practices by design. A lot of things are done 'magically' behind the scenes, so beginners don't need to worry about it.
  • No Explicit Bindings - TauNet uses information you're already giving it to figure out what types are bound to messages sent across the network. This gets rid of the awkward bindings that most other libraries need, as well as the shared classes. The only thing that needs to be done, is create a Subscriber that listens for the specified message, and make sure the simple name and fields match.
  • Event Driven - TauNet is event driven at the core, and requires the use of a publish-subscribe pattern.
  • Synchronous Feel - Even though TauNet is asynchronous at heart, it seems as if you're doing everything in synchronous.
  • Fast - At the core of TauNet is Netty, Feather, and Gson; all of which have been proven to be fast and reliable.

Usage

How to create a basic chat server: ```Java import com.joepritzel.feather.PSBroker; import com.joepritzel.feather.Subscriber; import com.joepritzel.taunet.Server; import com.joepritzel.taunet.ServerBuilder; import com.joepritzel.taunet.net.Send;

public class ChatServer {

public static void main(String[] args) throws Exception {
	Server  server = new ServerBuilder().build(); // Create a server.
	server.start("server"); // Start the server and give it a name.
	PSBroker broker = server.getBroker(); // Get the PSBroker for easy use.
	Subscriber<String> stringSub = new Subscriber<String>() { // Create a new subscriber, usually defined in its own class.
		@Override
		public void receive(String msg) {
			// Send the message to all active connections.
			server.getNetworkingImplementation().getConnections()
					.forEach(c -> 
						broker.publish(new Send<String>(c, msg)) // Send a message to the given client.
					);
		}
	};
	broker.subscribe(stringSub, String.class); // Register the subscriber with the PSBroker.
	server.waitForEnd(); // Wait for the server to finish executing.
}

}


An example client:
```Java
import java.util.Scanner;

import com.joepritzel.feather.Subscriber;
import com.joepritzel.taunet.Client;
import com.joepritzel.taunet.ClientBuilder;
import com.joepritzel.taunet.net.Send;

public class ChatClientExample {

	public static void main(String[] args) throws Exception {
		Client client = new ClientBuilder().build(); // Create a new client.
		Subscriber<String> stringSub = new Subscriber<String>() { // Create a new subscriber, usually defined in its own class.
			@Override
			public void receive(String msg) {
				System.out.println(msg); // Simply print out the string.
			}
		};
		client.getBroker().subscribe(stringSub, String.class); // Register the subscriber to the PSBroker.
		
		System.out.println("What is your name?"); // Ask for a username.
		try (Scanner in = new Scanner(System.in)) {
			String name = in.nextLine(); // Read in username.
			client.start(name); // Start client with the given username.
			while (true) { // Infinitely send messages that are typed in.
				client.getBroker().publish(
						new Send<String>(name + ": " + in.nextLine()));
			}
		}
	}
}

License

This project is distributed under the terms of the MIT License. See file "LICENSE" for further information.

Versions

Version
1.4
1.3
1.2
1.1
1.0
0.2
0.1