SkillAgentSearch skills...

Tenio

TenIO is an open-source project for making online games that includes a java NIO (Non-blocking I/O) based server specifically designed for multiplayer games and simple existing game clients for rapid development: Libgdx (Java), Cocos2d-x (C++), Unity (C#), Phaserjs (Javascript).

Install / Use

/learn @congcoi123/Tenio

README

<p align="center"> <a href="#"> <img src="assets/tenio-github-logo.png"> </a> </p> <p align="center"> <a href="LICENSE"> <img src="https://img.shields.io/badge/license-MIT-blue.svg"> </a> <a href="#"> <img src="https://img.shields.io/github/last-commit/congcoi123/tenio"> </a> <a href="https://github.com/congcoi123/tenio/issues"> <img src="https://img.shields.io/github/issues/congcoi123/tenio"> </a> <a href="CONTRIBUTING.md"> <img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg"> </a> <a href="https://discord.gg/ybkNU87Psy"> <img src="https://img.shields.io/discord/1146091189456613407?logo=discord&logoColor=white"> </a> </p>

TenIO Tweet

TenIO is an open-source project to create multiplayer online games that includes a java NIO (Non-blocking I/O) based server specifically designed for multiplayer games, which supports UDP, TCP, Websocket, HTTP transports, and available simple client projects for quick development.

Features

  • Scalable, distributed design
  • Easy-to-use, OOP design
  • Based on standard Java development, ensuring cross-platform support
  • Simple event handlers implementation
  • Simple physic simulator and debugger
  • Have simple existing game clients for rapid development

Showcases

| <img src="assets/game-box-online-logo.png" width="100px;"/><br /><sub><b>Game Box Online</b></sub><br /> | <img src="assets/gold-miner-online-logo.png" width="100px;"/><br /><sub><b>Gold Miner Online</b></sub><br /> | <img src="assets/retro-brick-online-logo.png" width="100px;"/><br /><sub><b>Brick Game Online</b></sub><br /> | | :-----------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------------------------------------------: |

First Glimpse

Simple Movement Simulation
Simple Movement Simulation

Simple Implementation

  • Establishes a simple server with only a single Java class
/**
 * This class shows how a simple server handle messages that come from a client.
 */
@Bootstrap
@EventHandler
public final class SimpleServer extends AbstractHandler implements EventConnectionEstablishedResult<ZeroMap>,
        EventPlayerLogin<Player>, EventReceivedMessageFromPlayer<Player, DataCollection> {

  public static void main(String[] params) {
    ApplicationLauncher.run(SimpleServer.class, params);
  }

  @Override
  public void onConnectionEstablishedResult(Session session, ZeroMap message, ConnectionEstablishedResult result) {
    if (result == ConnectionEstablishedResult.SUCCESS) {
      api().login(message.getString(SharedEventKey.KEY_PLAYER_LOGIN), session);
    }
  }

  @Override
  public void onPlayerLogin(Player player) {
    var parcel = map().putString(SharedEventKey.KEY_PLAYER_LOGIN,
            String.format("Welcome to server: %s", player.getIdentity()));

    response().setContent(parcel).setRecipientPlayer(player).write();
  }

  @Override
  public void onReceivedMessageFromPlayer(Player player, DataCollection message) {
    DataCollection parcel = null;
    if (message instanceof ZeroMap request) {
      parcel = map().putString(SharedEventKey.KEY_CLIENT_SERVER_ECHO,
              String.format("Echo(%s): %s", player.getIdentity(),
                      request.getString(SharedEventKey.KEY_CLIENT_SERVER_ECHO)));
    } else if (message instanceof MsgPackMap request) {
      parcel = msgmap().putString(SharedEventKey.KEY_CLIENT_SERVER_ECHO,
              String.format("Echo(%s): %s", player.getIdentity(),
                      request.getString(SharedEventKey.KEY_CLIENT_SERVER_ECHO)));
    }

    response().setContent(parcel).setRecipientPlayer(player).write();
  }
}
  • Supports self-defined commands to interact with the server conveniently
  1. Usage
2022-11-20 05:20:38,256 [main] INFO  com.tenio.core.server.ServerImpl - [SERVER][Example] Started
$ help
help - Shows all supporting commands
  [<command>,<command>,<command>]
info - Provides brief information about players and rooms on the server
  player
  room
player - Logout the first player from the server
  logout first
server - Allows stopping or restarting the server
  stop
  restart
unban - Allows removing banned Ip addresses from the ban list
  [<address>,<command>,<command>]
$ info player
> There are 1 players > The first 10 entities > [Player{name='IkjvI', properties={}, session=Session{id=0, name='IkjvI', transportType=TCP, createdTime=1668918078524, lastReadTime=1668918078524, lastWriteTime=1668918078524, lastActivityTime=1668918078524, readBytes=75, writtenBytes=120, droppedPackets=0, inactivatedTime=0, datagramRemoteSocketAddress=null, clientAddress='127.0.0.1', clientPort=60659, serverPort=8032, serverAddress='127.0.0.1', maxIdleTimeInSecond=0, activated=true, connected=true, hasUdp=false, enabledKcp=false, hasKcp=false}, currentRoom=null, state=null, roleInRoom=SPECTATOR, lastLoginTime=1668918078589, lastJoinedRoomTime=1668918078588, playerSlotInCurrentRoom=-1, loggedIn=true, activated=true, hasSession=true}]
$ 
  1. Make sure to set the command usage flag in setting.json file to be enabled
{
  "command": {
    "enabled": true
  },
  "plugin": {
    "enabled": false,
    "path": "/plugin"
  }
}
  1. Simple implementation
@Command(label = "player", usage = {
    "logout first"
}, description = "Logout the first player from the server")
public class PlayerCommand extends AbstractCommandHandler {

  @Override
  public void execute(List<String> args) {
    var action = args.get(0);
    var param = args.get(1);

    if (action.equals("logout") && param.equals("first")) {
      var players = api().getReadonlyPlayersList();
      if (players.isEmpty()) {
        CommandUtility.INSTANCE.showConsoleMessage("Empty list of players.");
        return;
      }
      var firstPlayer = players.get(0);
      CommandUtility.INSTANCE.showConsoleMessage("Player {" + firstPlayer.getName() + "} is " +
          "going to logout.");
      api().logout(firstPlayer);
    } else {
      CommandUtility.INSTANCE.showConsoleMessage("Invalid action.");
    }
  }
}

Wiki

The wiki provides implementation level details and answers to general questions that a developer starting to use TenIO might have about it.

Clients

| <img src="assets/cocos2dx-logo.png" width="150px;"/><br /><sub><b>TenIO Cocos2dx</b></sub><br /> | <img src="assets/libgdx-logo.png" width="150px;"/><br /><sub><b>TenIO Libgdx</b></sub><br /> | <img src="assets/unity-logo.png" width="150px;"/><br /><sub><b>TenIO Unity</b></sub><br /> | <img src="assets/phaserjs-logo.png" width="150px;"/><br /><sub><b>TenIO Phaserjs</b></sub><br /> | | :-----------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------: |

Framework

The project is strongly based on the same name framework as you can be referenced by the following repositories.

Requirements

- Java 17

License

The TenIO project is currently available under the MIT License.

Contributing

Please check out the contributing guideline for more details.

Documentations

Please check out the documentations directory for more details.

Installation

$ git clone https://github.com/congcoi123/tenio.git

Examples

Collection

Please check out this repository for references.

Wanna try Kotlin?

Then you should check out this showcase for more details.

Happy coding !

View on GitHub
GitHub Stars126
CategoryDevelopment
Updated1d ago
Forks12

Languages

Java

Security Score

100/100

Audited on Mar 26, 2026

No findings