Skip to content
Browse files

Improved session startup in infinote/rudel-infinote{,client}.el

* infinote/rudel-infinote.el (rudel-infinote-backend::rudel-connect):
  use `rudel-wait' to ensure the connection is ready for use; handle
  missing :host property
  (rudel-infinote-backend::rudel-make-node): do not set the :group
  slot when creating nodes
* infinote/rudel-infinote-client.el
  (rudel-infinote-client-connection::initialize-instance): cosmetic
  (rudel-infinote-client-connection::rudel-make-and-add-group): added
  a comment
  (rudel-infinote-client-connection::rudel-make-and-add-node): added a
  (rudel-infinote-client-connection::rudel-receive): added comments
  (rudel-infinote-client-connection::rudel-wait): new method; block
  until the connection is ready for use; this is determined by
  monitoring the state of the directory group
  • Loading branch information...
1 parent ffc0a9f commit 46ed712990d01cfb66e2eb5eea1064ea10ba710b @scymtym committed
Showing with 19 additions and 16 deletions.
  1. +15 −3 infinote/rudel-infinote-client.el
  2. +4 −13 infinote/rudel-infinote.el
18 infinote/rudel-infinote-client.el
@@ -128,8 +128,8 @@ side."))
;; The special 'InfDirectory' group is there from the beginning.
(let ((directory-group (rudel-infinote-group-directory
- "InfDirectory"
- :publisher "you"))) ;; TODO use correct publisher name
+ "InfDirectory"
+ :publisher "you"))) ;; TODO use correct publisher name
(rudel-add-group this directory-group)
(require 'rudel-infinote-node-directory)
@@ -178,7 +178,8 @@ which case it is the name of a group."
(defmethod rudel-make-and-add-group ((this rudel-infinote-client-connection)
type name method &optional node)
"Create a group object and add it to THIS."
- (let ((group (rudel-infinote-group-text-document ;; TODO class
+ ;; TODO the backend creates these
+ (let ((group (rudel-infinote-group-text-document
:publisher "you" ;; TODO temp
:method method
@@ -205,6 +206,7 @@ WHICH is compared to the result of KEY using TEST."
(defmethod rudel-make-and-add-node ((this rudel-infinote-client-connection)
id parent-id name type)
+ ;; TODO the backend does the creation
(with-slots (session) this
(let ((parent (and parent-id
(rudel-find-node this parent-id))))
@@ -261,7 +263,11 @@ WHICH is compared to the result of KEY using TEST."
(xml (xml-node-children xml))
(group (rudel-get-group this name)))
(if group
+ ;; Dispatch to GROUP
(rudel-accept group (car xml))
+ ;; Display a warning and ignore the message.
'(rudel infinote)
(format "Could not find group: `%s'" name)
@@ -280,6 +286,12 @@ WHICH is compared to the result of KEY using TEST."
(with-slots (transport) this
(rudel-disconnect transport)))
+(defmethod rudel-wait ((this rudel-infinote-client-connection)
+ &optional progress-callback)
+ "Block until THIS is done with the session setup."
+ (let ((group (rudel-get-group this "InfDirectory")))
+ (rudel-state-wait group '(idle) '() progress-callback)))
(defmethod rudel-publish ((this rudel-infinote-client-connection) document)
;; Create a new adopted context for DOCUMENT.
17 infinote/rudel-infinote.el
@@ -97,24 +97,16 @@ Return the connection object."
(let* ((session (plist-get info :session))
(host (plist-get info :host)) ;; Just as name
(connection (rudel-infinote-client-connection
- (format "to %s" host)
+ (format "to %s" (or host "unknown host"))
:session session
:transport transport)))
- ;; Start the transport and wait until the basic session setup is
- ;; complete.
+ ;; Start the transport.
(rudel-start transport)
- (rudel-state-wait transport
- '(idle)
- '(we-finalize they-finalize disconnected)
- progress-callback) ;; TODO this should be in the transport itself
;; Wait until the connection has done its session initiation on
;; the protocol level.
- (rudel-state-wait connection
- '(idle)
- '()
- progress-callback)
+ (rudel-wait connection progress-callback)
;; The connection is now ready for action; Return it.
@@ -145,8 +137,7 @@ node will be the root node."
:id id
- :parent parent
- :group (rudel-get-group this "InfDirectory")))
+ :parent parent))
;; unknown type

0 comments on commit 46ed712

Please sign in to comment.
Something went wrong with that request. Please try again.