extends Node

func send(text: String) -> void:
  var msg: String = text.strip_edges()
  if msg == "":
    return
  var sender: String = Net.local_name
  var id: int = Net.local_id()
  if multiplayer.multiplayer_peer == null:
    EventBus.chat_message.emit(id, sender, msg)
    return
  _broadcast.rpc(id, sender, msg)

@rpc("any_peer", "reliable", "call_local")
func _broadcast(peer_id: int, sender: String, msg: String) -> void:
  EventBus.chat_message.emit(peer_id, sender, msg)
