Skip to content

Example Netty-based Ktor server for Android 5+

Notifications You must be signed in to change notification settings

gnarea/minimal-ktor-server-android

Repository files navigation

Example Netty-based Ktor server for Android 5+

This repo implements an Android 5+ app that runs a Netty-powered KTor server when the app is in the foreground.

The server runs on 0.0.0.0:13276 without TLS.

MainActivity contains the KTor server code.

Endpoints

This app implements two endpoints:

GET /

It returns a 200 OK with a text body (text/plain) that contains the model name of the device the server runs on.

WebSocket /ws

This is a WebSocket endpoint that implements the following protocol:

  1. Client connects to server.
  2. Server sends text message to client.
  3. Server waits for client to send message back (any message).
  4. Server closes connection as soon as message from client is received.

Automated test

ServerTest contains a test that checks the endpoints above.

Make sure to set the right IP to your Android device on your WiFi network.

Licence

This repo is in the public domain.

About

Example Netty-based Ktor server for Android 5+

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages