Skip to content

Repository files navigation

Whisper

... a local TCP + TLS connection that makes intercommunicating processes go broom broomm

whisper

Java 9 module system compatible as well hell yeahhhh (io.github.brickwall2900.whisper)

why? i lwky locked in for 6 or 7 days since idk how to do IPC in Java and i haven't even looked for any libraries that would do it for me so i made one myself... idk it kinda sucks ass though so idk if you should use this

how to use

Basically, you do something like

import io.github.brickwall2900.processing.ProcessManager;

ProcessManager manager = ProcessManager.getInstance();

then like you do crazy stuff with it

i can't explain shi so see DemoApp for how to use this thing at the most basic level...

with TLS???

SONion looking back at it now, it MIGHT be a bit overkill... 🥀🥀

and not to mention, maybe a bit useless? since you can see these certificates stored somewhere on the disk... and the passwords are like RIGHT there, generated by PasswordProvider ;-;

you could control where they're placed using the system property whisper.certificatePath to point to a valid path.

i think it's a good idea to throw the certificate path into the temp folder, eh it self generates anyways lol

you could disable TLS by setting the system property whisper.useTLS to false and just get an unencrypted stream of data.

Messenger

The Messenger class allows easy communication between different processes using String. It can be retrieved using processManager.getMessenger().

It allows for:

  • broadcasting (messenger.messageBroadcast()): send messages through all connected processes
  • channels (messenger.messagePublish()): send messages through channels in which processes that are "subscribed" to it can receive those messages
  • direct messages (messenger.messageDirect() and messenger.messageDirectReply()): send messages through a process one-on-one

child processes essentially just send packets to the master while the master process routes those packets and sends them to the right processes.

see the demo app ChatMainApp for an example of how to use Messenger.

how do I kill children?

killing a child is really simple.

all you have to do is

// you have the child's ID
// then as the parent, you kill the child.

UUID id = ...;
ProcessManager manager = ProcessManager.getInstance();

manager.shutdownProcess(
        id,
        0, // exit code
        Duration.ofSeconds(3) // shutdown ack wait time
);

// optionally wait for the child to die
manager.waitForProcessTermination(
        id, 
        Duration.ofSeconds(6), // wait time
);

// or forcibly kill the child if 
// they don't want to die
manager.forceTerminate(
        id,
        Duration.ofSeconds(7) // death wait time
);

there, now the child should be dead :)

hi please do NOT report me to the FBI this is all about child processes i swear

Packet-level Processing

Whisper uses packets for sending data in and out of processes.

Such packets sent and received are:

  • Shutdown request packets (ShutdownRequestPacket, ShutdownAckPacket, ChildShutdownRequestPackets)
  • Children replication packets (ChildReplicationPacket, ChildInitReplicationPacket)
  • Exception packets (ExceptionPacket)
  • Message packets (MessagePacket, SubscriptionStatusPacket)

and theoretically, you could implement your own packets via processManager.registerPacketProcessor(...) but i kinda suggest to just stick with the simpler stuff for now unless there is a reason to implement packet-level communication.

you can read more about how packets are implemented by going through the io.github.brickwall2900.processing.packets package and just see how it's implemented...

TODO

i tested:

  • master process connection / disconnection
  • master process server start up/shutdown
  • child process creation
  • child process bootstrap
  • child process behavior
  • child and master messenger

not tested:

  • EventConnection disconnection
  • master process server restarting

needs some work:

  • child process premature termination due to an exception
  • exception packets
  • fuzzing this thing by throwing random packets to it

things i want to add:

  • remote method invocation

but yes, it's in a state where it's working right now and i'll fix these later when i come back to ts

Releases

Packages

Contributors

Languages