Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use automatic delegation of methods and slots for obby states

* obby/rudel-obby-state.el (rudel-obby-state): added superclasses
  rudel-impersonator and rudel-delegator
  (rudel-obby-state::impersonation-target-slot): new slot; target
  object for slot delegation
  (rudel-obby-state::delegation-target-slot): new slot; target object
  for method delegation
  (rudel-obby-state::rudel-send): removed; now delegated to delegation
  target object
* obby/rudel-obby-server.el (rudel-obby-server-state-new): changed
  method-resolution-order to :c3
  (rudel-obby-server-state-encryption-negotiate): likewise
  (rudel-obby-server-state-before-join): likewise
  (rudel-obby-server-state-idle): likewise
* obby/rudel-obby-client.el (rudel-obby-client-state-new): changed
  method-resolution-order to :c3
  (rudel-obby-client-state-encryption-negotiate): likewise
  (rudel-obby-client-state-encryption-start): likewise
  (rudel-obby-client-state-waiting-for-join-info): likewise
  (rudel-obby-client-state-joining): likewise
  (rudel-obby-client-state-join-failed): likewise
  (rudel-obby-client-state-idle): likewise
  (rudel-obby-client-state-session-synching): likewise
  (rudel-obby-client-state-subscribing): likewise
  (rudel-obby-client-state-document-synching): likewise
  (rudel-obby-client-state-we-finalized): likewise
  (rudel-obby-client-state-they-finalized): likewise
  (rudel-obby-client-state-disconnected): likewise
  • Loading branch information...
commit 40dedf7e4c403c4340d77c137bfe74f59a0239ec 1 parent bb8aafa
@scymtym scymtym authored
View
39 obby/rudel-obby-client.el
@@ -61,7 +61,8 @@
(defclass rudel-obby-client-state-new
(rudel-obby-client-connection-state)
()
- "Start state of newly established connections.")
+ "Start state of newly established connections."
+ :method-invocation-order :c3)
(defmethod rudel-obby/obby_welcome
((this rudel-obby-client-state-new) version)
@@ -79,7 +80,8 @@
(defclass rudel-obby-client-state-encryption-negotiate
(rudel-obby-client-connection-state)
()
- "Start state of the encryption handshake.")
+ "Start state of the encryption handshake."
+ :method-invocation-order :c3)
(defmethod rudel-obby/net6_encryption
((this rudel-obby-client-state-encryption-negotiate) value)
@@ -94,7 +96,8 @@
(defclass rudel-obby-client-state-encryption-start
(rudel-obby-client-connection-state)
()
- "Second state of the encryption handshake.")
+ "Second state of the encryption handshake."
+ :method-invocation-order :c3)
(defmethod rudel-obby/net6_encryption_begin
((this rudel-obby-client-state-encryption-start))
@@ -124,7 +127,8 @@
()
"State entered when the connection is established and
potentially needs additional information for joining the
-session.")
+session."
+ :method-invocation-order :c3)
;;; Class rudel-obby-client-state-joining
@@ -133,7 +137,8 @@ session.")
(defclass rudel-obby-client-state-joining
(rudel-obby-client-connection-state)
()
- "First state after the connection has been properly set up.")
+ "First state after the connection has been properly set up."
+ :method-invocation-order :c3)
(defmethod rudel-enter ((this rudel-obby-client-state-joining) info)
"When entering this state, send a login request."
@@ -221,7 +226,8 @@ login failure.")
:documentation
"Additional error data describing the login
failure."))
- "State for failed login attempts.")
+ "State for failed login attempts."
+ :method-invocation-order :c3)
(defmethod rudel-enter ((this rudel-obby-client-state-join-failed)
error)
@@ -239,7 +245,8 @@ failure."))
(rudel-obby-client-connection-state
rudel-obby-document-handler)
((document-container-slot :initform 'session))
- "Default state of the connection.")
+ "Default state of the connection."
+ :method-invocation-order :c3)
(defmethod rudel-obby/net6_client_join
((this rudel-obby-client-state-idle)
@@ -538,7 +545,8 @@ received from the server.")
:documentation
"Flag that remembers, whether the session has
a 'self' user object."))
- "State used for synching session data.")
+ "State used for synching session data."
+ :method-invocation-order :c3)
(defmethod rudel-enter ((this rudel-obby-client-state-session-synching)
num-items)
@@ -654,7 +662,8 @@ a 'self' user object."))
:type rudel-obby-document-child
:documentation
""))
- "")
+ ""
+ :method-invocation-order :c3)
(defmethod rudel-enter ((this rudel-obby-client-state-subscribing)
user document)
@@ -700,7 +709,8 @@ a 'self' user object."))
:type (integer 0)
:documentation
""))
- "")
+ ""
+ :method-invocation-order :c3)
(defmethod rudel-enter ((this rudel-obby-client-state-document-synching)
document num-bytes)
@@ -750,7 +760,8 @@ a 'self' user object."))
:type (or symbol string)
:documentation
"The reason for the finalization."))
- "State used to indicate that we closed the connection.")
+ "State used to indicate that we closed the connection."
+ :method-invocation-order :c3)
(defmethod rudel-enter ((this rudel-obby-client-state-we-finalized)
&optional reason1)
@@ -773,7 +784,8 @@ a 'self' user object."))
:type (or symbol string)
:documentation
"The reason for the finalization."))
- "State used to indicate that the connection was closed by the peer.")
+ "State used to indicate that the connection was closed by the peer."
+ :method-invocation-order :c3)
(defmethod rudel-enter ((this rudel-obby-client-state-they-finalized)
&optional reason1)
@@ -793,7 +805,8 @@ a 'self' user object."))
(defclass rudel-obby-client-state-disconnected
(rudel-obby-client-connection-state)
()
- "State used to indicated that the connection is closed.")
+ "State used to indicated that the connection is closed."
+ :method-invocation-order :c3)
;;; Client connection states.
View
12 obby/rudel-obby-server.el
@@ -72,7 +72,8 @@
(defclass rudel-obby-server-state-new
(rudel-obby-server-connection-state)
()
- "State in which new connections start out.")
+ "State in which new connections start out."
+ :method-invocation-order :c3)
(defmethod rudel-enter ((this rudel-obby-server-state-new))
"Sends welcome messages to the client and starts the session
@@ -92,7 +93,8 @@ timeout timer."
(defclass rudel-obby-server-state-encryption-negotiate
(rudel-obby-server-connection-state)
()
- "Encryption negotiation state.")
+ "Encryption negotiation state."
+ :method-invocation-order :c3)
(defmethod rudel-enter ((this rudel-obby-server-state-encryption-negotiate))
"Send net6 'encryption' message requesting to not enable encryption."
@@ -121,7 +123,8 @@ failed encryption negotiation."
(defclass rudel-obby-server-state-before-join
(rudel-obby-server-connection-state)
()
- "Waiting for client request joining the session.")
+ "Waiting for client request joining the session."
+ :method-invocation-order :c3)
(defmethod rudel-obby/net6_client_login
((this rudel-obby-server-state-before-join) username color
@@ -239,7 +242,8 @@ the client has joined the session and no operation is in
progress. In this state, the connection waits for new messages
from the client that initiate operations. Simple (which means
stateless in this case) operations are performed without leaving
-the idle state.")
+the idle state."
+ :method-invocation-order :c3)
(defmethod rudel-obby/obby_user_colour
((this rudel-obby-server-state-idle) color-)
View
20 obby/rudel-obby-state.el
@@ -49,11 +49,16 @@
;;; Class rudel-obby-state
;;
-(defclass rudel-obby-state (rudel-state)
- ((connection :initarg :connection
- :type object
- :documentation
- "Connection object that uses the state."))
+(defclass rudel-obby-state (rudel-state
+ rudel-impersonator
+ rudel-delegator)
+ ((impersonation-target-slot :initform 'connection)
+ (delegation-target-slot :initform 'connection)
+ (connection :initarg :connection
+ :type object
+ :documentation
+ "Connection object that uses the
+state."))
"Base class for state classes used in the obby backend."
:abstract t)
@@ -87,11 +92,6 @@ Display a warning if no such handler is found."
nil))))
)
-(defmethod rudel-send ((this rudel-obby-state) &rest args)
- "Send ARGS through the connection associated with THIS."
- (with-slots (connection) this
- (apply #'rudel-send connection args)))
-
;;; Class rudel-obby-client-connection-state
;;
Please sign in to comment.
Something went wrong with that request. Please try again.