Sueta

[OLD] Multisocket

6.3

for Spigot & BungeeCord

·Plugin

OVER 4K DOWNLOADS

________________________________________________________________________________________________________________

Tired of Plugin Messaging Channels?

This plugin simply allows developers to send any data from a server to another using sockets with SSL

You can send data from any instance of BungeeCord or Spigot to any instance of BungeeCord or Spigot, just with few lines and without headache ;)

WebSockets allows you to have whole conversations instead of simple request-response

You can even send and receive data from web apps using JavaScript

Admins

Just put the file in the plugins folder of your BungeeCord and of your Spigots

Example of network

Let's suppose you have one BungeeCord and two Spigots: Factions and HungerGames.

Each server will have one socket, each on a different port.

  • BungeeCord has a socket on port 25590
  • Factions has a socket on port 25591
  • HungerGames has a socket on port 25592

BungeeCord

sockets:
  "bungee":
    port: 25590
    connections:
      "factions":
        host: localhost
        port: 25591
      "hungergames":
        host: localhost
        port: 25592

Factions

sockets:
  "factions":
    port: 25591
    connections:
      "bungee":
        host: localhost
        port: 25590
      "hungergames":
        host: localhost
        port: 25592

HungerGames

sockets:
  "hungergames":
    port: 25592
    connections:
      "factions":
        host: localhost
        port: 25591
      "bungee":
        host: localhost
        port: 25590

Developers
It only supports Kotlin for the moment

Go to JitPack

Kotlin

// When your plugin is enabled
override fun onEnable(){

    // When any socket is started
    onSocketEnable { name ->
        println("Enabled socket $name on port $port")
 
        // You must define all routes here
 
        // Create route to /MyPlugin/test
        onConversation("/MyPlugin/test"){
            // Send message
            send("it works!")
            // Wait until a message is received
            println(readMessage())
            // Do it as many times as you want
            send("it still works!")
            println(readMessage())
        }
 
        hello("factions")
    }
}

fun Socket.hello(target: String){
    // Get the connection to target
    val connection = connections[target]
    ?: return println("Unknown connection: $target")
 
    // Start a conversation to /MyPlugin/hello
    connection.conversation("/MyPlugin/hello") {
        // Send message
        send("hello world!")
        // Wait until a message is received
        println(readMessage())
    }
 
    connection.printFactions()
}

fun Connection.printFactions(){
    // Short function equivalent to conversation { readMessage() }
    request("/Factions/factions"){
        // Just print the first message received and close the conversation
        result -> println(result)
    }
}

The #mc-multisockets on GitHub

Similar projects

Plugin →