Move code to the library from bin/run.dart
onMessage listener and responding to requests
Use 'messages' package for easier messages manipulation