Permalink
Browse files

Add basic communication

  • Loading branch information...
borodust committed Apr 21, 2017
1 parent 723fe65 commit d0cfc8f29760b967260e4ea13ef5b47a684a8651
Showing with 39 additions and 0 deletions.
  1. +38 −0 client/src/main.lisp
  2. +1 −0 client/src/proxy.lisp
@@ -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
@@ -48,6 +53,39 @@
(adopt group ball)))))))
(defun connect ()
(with-slots (server relay) (mortar-combat)
(unless (or server relay)
(setf server (connect-to-server "127.0.0.1" 8778)
relay (connect-to-server "127.0.0.1" 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")
@@ -0,0 +1 @@
(in-package :mortar-combat)

0 comments on commit d0cfc8f

Please sign in to comment.