Tuna Core

a Lightweight and High Performance Java Network Framework - Core Part

Лицензия

Лицензия

Группа

Группа

com.xqbase
Идентификатор

Идентификатор

tuna-core
Последняя версия

Последняя версия

0.1.6
Дата

Дата

Тип

Тип

jar
Описание

Описание

Tuna Core
a Lightweight and High Performance Java Network Framework - Core Part
Ссылка на сайт

Ссылка на сайт

https://github.com/xqbase/tuna
Система контроля версий

Система контроля версий

https://github.com/xqbase/tuna.git

Скачать tuna-core

Как подключить последнюю версию

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

Зависимости

Библиотека не имеет зависимостей. Это самодостаточное приложение, которое не зависит ни от каких других библиотек.

Модули Проекта

Данный проект не имеет модулей.

Tuna

A Lightweight and High Performance Java Network Framework with the following features:

  • High Performance and High Scalability
  • Server / Client Connections
  • Event and Filter Support
  • SSL Support
  • Non-Blocking NIO
  • Various useful components, including debug, compression, DoS filter, HTTP support, proxy, multiplex, ...
  • Single-Thread, Easy Programming

Tuna can be used as a maven dependency:

<dependency>
    <groupId>com.xqbase</groupId>
    <artifactId>tuna-core</artifactId>
    <version>0.1.1</version>
</dependency>

Here is an example to establish a broadcasting server:

import java.io.IOException;
import java.util.HashSet;

import com.xqbase.tuna.Connection;
import com.xqbase.tuna.ConnectionHandler;
import com.xqbase.tuna.ConnectionSession;
import com.xqbase.tuna.ConnectorImpl;

public class TestBroadcast {
	static final ConnectionHandler[] EMPTY_HANDLERS = {};

	public static void main(String[] args) throws IOException {
		// All connected handlers
		HashSet<ConnectionHandler> handlers = new HashSet<>();
		// Initialize a connector
		try (ConnectorImpl connector = new ConnectorImpl()) {
			connector.add(() -> {
				return new Connection() {
					ConnectionHandler handler;

					@Override
					public void setHandler(ConnectionHandler handler) {
						this.handler = handler;
					}

					@Override
					public void onRecv(byte[] b, int off, int len) {
						for (ConnectionHandler handler_ : handlers.toArray(EMPTY_HANDLERS)) {
							// "connection.onDisconnect()" might change "handlers"
							// Broadcast to all connected handlers
							handler_.send(b, off, len);
						}
					}

					@Override
					public void onConnect(ConnectionSession session) {
						handlers.add(handler);
					}

					@Override
					public void onDisconnect() {
						handlers.remove(handler);
					}
				};
			}, 23);
			// Keep the server running for 10 minutes
			connector.postDelayed(connector::interrupt, 600000);
			// "doEvents()" makes the connector working
			connector.doEvents();
		}
	}
}

Run this program and type telnet localhost in several Command Prompt windows to test it.

com.xqbase

Версии библиотеки

Версия
0.1.6
0.1.5
0.1.4
0.1.3
0.1.2
0.1.1
0.1.0