Skip to content


Browse files Browse the repository at this point in the history
Add basic communication
  • Loading branch information
borodust committed Apr 21, 2017
1 parent 723fe65 commit d0cfc8f
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
38 changes: 38 additions & 0 deletions client/src/main.lisp
Expand Up @@ -10,6 +10,11 @@
(defclass mortar-combat (enableable generic-system dispatcher)
((scene :initform nil :reader scene-of)
(task-queue :initform nil)

(server :initform nil)
(identity :initform nil)
(relay :initform nil)

(keymap :initform nil)
(player :initform nil))
(:default-initargs :depends-on '(graphics-system
Expand Down Expand Up @@ -48,6 +53,39 @@
(adopt group ball)))))))

(defun connect ()
(with-slots (server relay) (mortar-combat)
(unless (or server relay)
(setf server (connect-to-server "" 8778)
relay (connect-to-server "" 8222)))))

(defun register-as (name)
(with-slots (server relay identity) (mortar-combat)
(run (>> (identify server name)
(->> (id)
(setf identity id)
(register-game-stream relay (server-identity-id id)))))))

(defun create-combat-arena (name)
(with-slots (server) (mortar-combat)
(run (create-arena server name))))

(defun join-combat-arena (name)
(with-slots (server) (mortar-combat)
(run (join-arena server name))))

(defun ping-game-server ()
(with-slots (relay) (mortar-combat)
(let ((start (real-time-seconds)))
(run (>> (ping-peer relay)
(instantly ()
(log:info "Ping: ~Fs" (- (real-time-seconds) start))))))))

(defmethod initialize-system :after ((this mortar-combat))
(with-slots (scene player keymap task-queue) this
(register-resource-loader (make-resource-loader (asset-path "font.brf")
Expand Down
1 change: 1 addition & 0 deletions client/src/proxy.lisp
@@ -0,0 +1 @@
(in-package :mortar-combat)

0 comments on commit d0cfc8f

Please sign in to comment.