packet_handling.clj

Branches > client-handling-rewrite > adaa9ca > files / src / net / bowmap / packet_handling.clj

(ns net.bowmap.packet-handling
  (:require
   [net.bowmap.client.state :as state]
   [net.bowmap.packet :as pk]
   [net.bowmap.packets.client :as cp]
   [net.bowmap.packets.server :as sp]))

(defmulti handle-packet
  (fn [pk client]
    (::pk/id pk)))

(defmethod handle-packet :default [pk client]
  (prn "Unhandled packet:" pk))

(defmethod handle-packet ::sp/handshaking [pk client]
  {::state/state (:intent pk)})

(defmethod handle-packet ::sp/status-request [pk client]
  {:response {::pk/id ::cp/status-response
              :response {:version {:name "1.21.11"
                                   :protocol 774}
                         :players {:max 1000
                                   :online 0}
                         :description {:text "Bowmap!"}
                         :enforcesSecureChat false}}})