Messaging over LAN? [could DC skip the relay when peers are nearby?]

I believe these could already solve your use case:
Realtime Chat - quandang

High speed file transfer and low latency messaging. Both sender and receiver need to open the app to transfer files. If not, messages and image previews will be sent through the regular updates and files won’t be sent.

Live Chat - ArcaneCircle

With this app you can have real-time ephemeral threads/discussions inside your chats, ideal for off-topic discussions without disturbing other members of the group. See who is online, “typing…” indicators and real-time message delivery, ideal for fast-paced IRC/Slack-like conversations. Tips: type /nick command in the input field to change nick, /topic to change the thread topic

A related idea for also federating with XMPP: