An asynchronous networking library that just works
You can check out the test
directory for full use cases
Setup event handlers for the server then start it providing the IP
and Port
val server = BlueServer()
server.onConnected += { ch ->
System.err.println("Client connected")
ch.channel.write(ByteBuffer.wrap("Hello!")).get()
}
server.onReceived += { receivedEventArgs ->
serverRead += receivedEventArgs.bytes.size
received = String(receivedEventArgs.bytes)
println("Server received:$received")
}
server.start("localhost", 60001)
Connect to a server using IP
and Port
then send messages
val client = BlueClient()
// Register for events
client.onConnected += { /* Your code here */ }
client.onReceived += { b:ByteArray -> /*your code here*/ }
// Simple usage
client.connect("localhost", 6001)
client.send("Hello World!".toByteArray())