Permalink
Browse files

* rudel.el (rudel-host-session): determine a transport and a protocol

  backend; ask the protocol backend to create the session 
* rudel-util.el (rudel-socket-owner):
  (rudel-filter-dispatch):
  (rudel-sentinel-dispatch): removed; made obsolete by transports
* rudel-protocol.el (rudel-protocol-backend::rudel-host): added
  backend argument, which is the transport backend; updated
  documentation string
* rudel-debug.el (rudel-state-machine::rudel-state-change): attached
  method to `rudel-state-machine' instead of `rudel-socket-owner'
  (rudel-debug-stream-name): determine the name from a transport
  object instead of a socket
* obby/rudel-obby.el (require rudel-transport): required for
  transports
  (rudel-obby-backend::rudel-connect): use a transport object instead
  of a socket
  (rudel-obby-backend::rudel-ask-host-info): added :address property
  (rudel-obby-backend::rudel-host): added transport-backend argument;
  do not create a socket but call the
  `rudel-wait-for-connections' method of the transport backend
  (rudel-obby-send): removed; made obsolete by transports
  (rudel-obby-generate-message): new function; used in parsing
  transport filters to serialize obby messages
* obby/rudel-obby-util.el (require rudel-transport-util): new; for
  `rudel-transport-make-filter-stack'
  (rudel-obby-socket-owner): removed; made obsolete by transports
* obby/rudel-obby-server.el (header): bumped version to 0.3
  (rudel-obby-client): removed base class `rudel-obby-socket-owner'
  (rudel-obby-client::transport): new slot; stores transport object
  (rudel-obby-client::initialize-instance): build a transport filter
  stack and install `rudel-accept' as filter
  (rudel-obby-client::rudel-message): removed; `rudel-accept' is
  called by the transport
  (rudel-obby-client::rudel-send): new; send data through transport
  (rudel-obby-server): removed base class `rudel-socket-owner'
  (rudel-obby-server::rudel-add-client): expect a transport object
  instead of a socket
* obby/rudel-obby-debug.el (header): cosmetic changes
  (require rudel-obby-client): new; required since all methods are now
  attached to the `rudel-obby-connection' class
  (rudel-obby-connection::rudel-send): now attached to the
  `rudel-obby-connection' class
  (rudel-obby-connection::rudel-accept): renamed `rudel-receive' ->
  `rudel-accept'; now attached to the `rudel-obby-connection' class
  (rudel-obby-socket-owner::rudel-message): removed; obsolete
  (rudel-obby-connection::rudel-switch): now attached to the
  `rudel-obby-connection' class
* obby/rudel-obby-client.el (header): bumped version to 0.3
  (rudel-obby-client-state-encryption-start::rudel-obby/net6_encryption_begin):
  call transport method to enable encryption
  (rudel-obby-connection): removed base class `rudel-socket-owner'
  (rudel-obby-connection::transport): new slot; stores transport
  object
  (rudel-obby-connection::initialize-instance): build a transport
  filter stack and install `rudel-accept' as filter
  (rudel-obby-connection::rudel-send): new; send data through the
  transport
  (rudel-obby-connection::rudel-message): removed; obsolete
  • Loading branch information...
1 parent 1dc2be4 commit 2fd925df6ab64146dda693244d8571225d7a649d @scymtym committed Dec 3, 2009
Showing with 237 additions and 231 deletions.
  1. +71 −0 ChangeLog
  2. +44 −23 obby/rudel-obby-client.el
  3. +12 −27 obby/rudel-obby-debug.el
  4. +37 −14 obby/rudel-obby-server.el
  5. +17 −40 obby/rudel-obby-util.el
  6. +34 −50 obby/rudel-obby.el
  7. +4 −4 rudel-debug.el
  8. +7 −2 rudel-protocol.el
  9. +0 −55 rudel-util.el
  10. +11 −16 rudel.el
View
@@ -1,3 +1,74 @@
+2009-12-03 Jan Moringen <scymtym@users.sourceforge.net>
+
+ * rudel.el (rudel-host-session): determine a transport and a
+ protocol backend; ask the protocol backend to create the session
+ * rudel-util.el (rudel-socket-owner):
+ (rudel-filter-dispatch):
+ (rudel-sentinel-dispatch): removed; made obsolete by transports
+ * rudel-protocol.el (rudel-protocol-backend::rudel-host): added
+ backend argument, which is the transport backend; updated
+ documentation string
+ * rudel-debug.el (rudel-state-machine::rudel-state-change):
+ attached method to `rudel-state-machine' instead of
+ `rudel-socket-owner'
+ (rudel-debug-stream-name): determine the name from a transport
+ object instead of a socket
+ * obby/rudel-obby.el (require rudel-transport): required for
+ transports
+ (rudel-obby-backend::rudel-connect): use a transport object
+ instead of a socket
+ (rudel-obby-backend::rudel-ask-host-info): added :address property
+ (rudel-obby-backend::rudel-host): added transport-backend
+ argument; do not create a socket but call the
+ `rudel-wait-for-connections' method of the transport backend
+ (rudel-obby-send): removed; made obsolete by transports
+ (rudel-obby-generate-message): new function; used in parsing
+ transport filters to serialize obby messages
+ * obby/rudel-obby-util.el (require rudel-transport-util): new; for
+ `rudel-transport-make-filter-stack'
+ (rudel-obby-socket-owner): removed; made obsolete by transports
+ * obby/rudel-obby-server.el (header): bumped version to 0.3
+ (rudel-obby-client): removed base class `rudel-obby-socket-owner'
+ (rudel-obby-client::transport): new slot; stores transport object
+ (rudel-obby-client::initialize-instance): build a transport filter
+ stack and install `rudel-accept' as filter
+ (rudel-obby-client::rudel-message): removed; `rudel-accept' is
+ called by the transport
+ (rudel-obby-client::rudel-send): new; send data through transport
+ (rudel-obby-server): removed base class `rudel-socket-owner'
+ (rudel-obby-server::rudel-add-client): expect a transport object
+ instead of a socket
+ * obby/rudel-obby-debug.el (header): cosmetic changes
+ (require rudel-obby-client): new; required since all methods are
+ now attached to the `rudel-obby-connection' class
+ (rudel-obby-connection::rudel-send): now attached to the
+ `rudel-obby-connection' class
+ (rudel-obby-connection::rudel-accept): renamed `rudel-receive' ->
+ `rudel-accept'; now attached to the `rudel-obby-connection' class
+ (rudel-obby-socket-owner::rudel-message): removed; obsolete
+ (rudel-obby-connection::rudel-switch): now attached to the
+ `rudel-obby-connection' class
+ * obby/rudel-obby-client.el (header): bumped version to 0.3
+ (rudel-obby-client-state-encryption-start::rudel-obby/net6_encryption_begin):
+ call transport method to enable encryption
+ (rudel-obby-connection): removed base class `rudel-socket-owner'
+ (rudel-obby-connection::transport): new slot; stores transport
+ object
+ (rudel-obby-connection::initialize-instance): build a transport
+ filter stack and install `rudel-accept' as filter
+ (rudel-obby-connection::rudel-send): new; send data through the
+ transport
+ (rudel-obby-connection::rudel-message): removed; obsolete
+
+ * socket/rudel-socket.el
+ (rudel-tcp-backend::rudel-wait-for-connections): when creating the
+ network process, set filter and sentinel to `ignore'
+
+ * tls/rudel-tls.el
+ (rudel-start-tls-backend::rudel-make-connection): create transport
+ object of class `rudel-start-tls-transport' not
+ `rudel-socket-transport'
+
2009-12-02 Jan Moringen <scymtym@users.sourceforge.net>
* obby/rudel-obby.el (rudel-obby-default-port): new constant; used
View
@@ -29,9 +29,11 @@
;;; History:
;;
-;; 0.2 - State machine.
+;; 0.3 - Support for transports
;;
-;; 0.1 - Initial revision.
+;; 0.2 - State machine
+;;
+;; 0.1 - Initial version
;;; Code:
@@ -96,10 +98,10 @@
((this rudel-obby-client-state-encryption-start))
"Handle net6 'encryption_begin' message."
;; Start TLS encryption for the connection.
- (with-slots (connection) this
- (with-slots (socket) connection
- (when (rudel-process-object socket :supports-tls)
- (rudel-tls-start-tls socket)
+ (with-slots (transport) (oref this :connection)
+ (let ((root-transport (oref transport :root-transport)))
+ (when (rudel-start-tls-transport-child-p root-transport)
+ (rudel-enable-encryption root-transport)
(sit-for 1))))
;; The connection is now established
@@ -745,17 +747,21 @@ failure."))
;;; Class rudel-obby-connection
;;
-(defclass rudel-obby-connection (rudel-obby-socket-owner
- rudel-connection
+(defclass rudel-obby-connection (rudel-connection
rudel-state-machine)
- ((info :initarg :info
- :type list
- :documentation
- "Stores connection information for later use.")
- (contexts :initarg :contexts
- :type hash-table
- :documentation
- "Contains jupiter context objects for all
+ ((transport :initarg :transport
+ :type rudel-transport
+ :documentation
+ "The transport object through which this connection
+sends and receives its data.")
+ (info :initarg :info
+ :type list
+ :documentation
+ "Stores connection information for later use.")
+ (contexts :initarg :contexts
+ :type hash-table
+ :documentation
+ "Contains jupiter context objects for all
documents."))
"Class rudel-obby-connection ")
@@ -771,6 +777,23 @@ documents."))
;; Register states.
(rudel-register-states this rudel-obby-client-connection-states)
+
+ ;; Set up the transport.
+ (with-slots (transport) this
+
+ ;; Build the following transport filter stack:
+ ;; + `rudel-parsing-transport-filter'
+ ;; + `rudel-assembling-transport-filter'
+ ;; + TRANSPORT
+ (setq transport (rudel-obby-make-transport-filter-stack transport))
+
+ ;; Install `rudel-accept' as filter to dispatch messages to the
+ ;; current state machine state.
+ (lexical-let ((this1 this))
+ (rudel-set-filter
+ transport
+ (lambda (data)
+ (rudel-accept this1 data)))))
)
(defmethod rudel-register-state ((this rudel-obby-connection)
@@ -784,6 +807,11 @@ documents."))
(call-next-method))
)
+(defmethod rudel-send ((this rudel-obby-connection) &rest args)
+ "Send ARGS through the transport of THIS."
+ (with-slots (transport) this
+ (rudel-send transport args)))
+
(defmethod rudel-disconnect ((this rudel-obby-connection))
""
(when (next-method-p)
@@ -817,13 +845,6 @@ documents."))
(with-slots (contexts) this
(remhash (oref document :id) contexts)))
-(defmethod rudel-message ((this rudel-obby-connection) message)
- "Dispatch MESSAGE to the current state of THIS object.
-If the state has no suitable method, generate a warning, but do
-nothing else."
- ;; Dispatch message to state.
- (rudel-accept this message))
-
(defmethod rudel-change-color- ((this rudel-obby-connection) color)
""
(rudel-send this "obby_user_colour"
View
@@ -27,7 +27,7 @@
;;; History:
;;
-;; 0.1 - Initial revision.
+;; 0.1 - Initial version
;;; Code:
@@ -38,6 +38,7 @@
(require 'rudel-debug)
(require 'rudel-obby-util)
+(require 'rudel-obby-client)
;;; Variables
@@ -50,50 +51,34 @@
;;; Functions
;;
-(defmethod rudel-send :before ((this rudel-obby-socket-owner)
+(defmethod rudel-send :before ((this rudel-obby-connection)
name &rest arguments)
"Print NAME and ARGUMENTS to debug stream."
(let ((message (apply #'rudel-obby-assemble-message
name arguments)))
- (with-slots (socket) this
+ (with-slots (transport) this
(rudel-debug-stream-insert
- (rudel-debug-stream-name socket)
+ (rudel-debug-stream-name transport)
:sent
(concat (substring message 0 (min (length message) 100))
(when (> (length message) 100)
"..."))
(append (list name) arguments))))
)
-(defmethod rudel-receive :before ((this rudel-obby-socket-owner) data)
+(defmethod rudel-accept :before ((this rudel-obby-connection) data)
"Print DATA to debug stream."
- (with-slots (socket) this
+ (with-slots (transport) this
(rudel-debug-stream-insert
- (rudel-debug-stream-name socket)
+ (rudel-debug-stream-name transport)
:received
(concat (substring data 0 (min (length data) 100))
(when (> (length data) 100)
"..."))))
)
-(defmethod rudel-message :before ((this rudel-obby-socket-owner)
- message)
- "Print DATA to debug stream."
- (let ((data (apply #'rudel-obby-assemble-message message)))
-
- (with-slots (socket) this
- (rudel-debug-stream-insert
- (rudel-debug-stream-name socket)
- :received
- (concat (substring data 0 (min (length data) 100))
- (when (> (length data) 100)
- "..."))
- message)
- ))
- )
-
-(defmethod rudel-switch :before ((this rudel-obby-socket-owner)
+(defmethod rudel-switch :before ((this rudel-obby-connection)
state &rest arguments)
"Store name of STATE for later printing."
(with-slots (state) this
@@ -103,15 +88,15 @@
"#start")))
)
-(defmethod rudel-switch :after ((this rudel-obby-socket-owner)
+(defmethod rudel-switch :after ((this rudel-obby-connection)
state &rest arguments)
"Print STATE and ARGUMENTS to debug stream."
- (with-slots (socket state) this
+ (with-slots (transport state) this
(let ((old-state rudel-obby-debug-old-state)
(new-state (object-name-string state)))
(unless (string= old-state new-state)
(rudel-debug-stream-insert
- (rudel-debug-stream-name socket)
+ (rudel-debug-stream-name transport)
:special
(if arguments
(format "%s -> %s %s" old-state new-state arguments)
View
@@ -38,9 +38,11 @@
;;; History:
;;
-;; 0.2 - State machine.
+;; 0.3 - Support for transports
;;
-;; 0.1 - Initial revision.
+;; 0.2 - State machine
+;;
+;; 0.1 - Initial version
;;; Code:
@@ -476,9 +478,13 @@ of her color to COLOR."
;;; Class rudel-obby-client
;;
-(defclass rudel-obby-client (rudel-obby-socket-owner
- rudel-state-machine)
- ((server :initarg :server
+(defclass rudel-obby-client (rudel-state-machine)
+ ((transport :initarg :transport
+ :type rudel-transport
+ :documentation
+ "The transport object through which this
+connection sends and receives its data.")
+ (server :initarg :server
:type rudel-obby-server
:documentation
"")
@@ -509,6 +515,23 @@ handled by the server.")
;; Register states.
(rudel-register-states this rudel-obby-server-connection-states)
+
+ ;; Set up the transport.
+ (with-slots (transport) this
+
+ ;; Build the following transport filter stack:
+ ;; + `rudel-parsing-transport-filter'
+ ;; + `rudel-assembling-transport-filter'
+ ;; + TRANSPORT
+ (setq transport (rudel-obby-make-transport-filter-stack transport))
+
+ ;; Install `rudel-accept' as filter to dispatch messages to the
+ ;; current state machine state.
+ (lexical-let ((this1 this))
+ (rudel-set-filter
+ transport
+ (lambda (data)
+ (rudel-accept this1 data)))))
)
(defmethod rudel-register-state ((this rudel-obby-client) symbol state)
@@ -528,10 +551,10 @@ handled by the server.")
(with-slots (server) this
(rudel-remove-client server this)))
-(defmethod rudel-message ((this rudel-obby-client) message)
- "Dispatch MESSAGE to the active state of THIS state machine."
- ;; Dispatch message to state
- (rudel-accept this message))
+(defmethod rudel-send ((this rudel-obby-client) &rest args)
+ "Send ARGS through the transport of THIS."
+ (with-slots (transport) this
+ (rudel-send transport args)))
(defmethod rudel-broadcast ((this rudel-obby-client)
receivers name &rest arguments)
@@ -610,8 +633,7 @@ handled by the server.")
;;; Class rudel-obby-server
;;
-(defclass rudel-obby-server (rudel-server-session
- rudel-socket-owner)
+(defclass rudel-obby-server (rudel-server-session)
((clients :initarg :clients
:type list
:initform nil
@@ -721,12 +743,13 @@ user. COLOR has to be sufficiently different from used colors."
)
(defmethod rudel-add-client ((this rudel-obby-server)
- client-socket)
+ client-transport)
""
(with-slots (next-client-id clients) this
- (let ((client (rudel-obby-client (process-name client-socket)
+ (let ((client (rudel-obby-client
+ (object-name client-transport)
:server this
- :socket client-socket
+ :transport client-transport
:id next-client-id
:encryption nil)))
(push client clients))
Oops, something went wrong.

0 comments on commit 2fd925d

Please sign in to comment.