Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 155 lines (116 sloc) 4.654 kB
f4da3b8 * Project.ede (target rudel): added rudel-transport.el
jan authored
1 ;;; rudel-transport.el --- Rudel transport interface and backend
2 ;;
f1443b5 @scymtym Added rudel-ask-connect-info for transport backends
scymtym authored
3 ;; Copyright (C) 2009, 2010 Jan Moringen
f4da3b8 * Project.ede (target rudel): added rudel-transport.el
jan authored
4 ;;
5 ;; Author: Jan Moringen <scymtym@users.sourceforge.net>
7e94ded @scymtym * rudel-transport.el: socket-like interface for transports
scymtym authored
6 ;; Keywords: rudel, backend, transport
f4da3b8 * Project.ede (target rudel): added rudel-transport.el
jan authored
7 ;; X-RCS: $Id:$
8 ;;
7e94ded @scymtym * rudel-transport.el: socket-like interface for transports
scymtym authored
9 ;; This file is part of Rudel.
10 ;;
11 ;; Rudel is free software: you can redistribute it and/or modify it
12 ;; under the terms of the GNU General Public License as published by
f4da3b8 * Project.ede (target rudel): added rudel-transport.el
jan authored
13 ;; the Free Software Foundation, either version 3 of the License, or
14 ;; (at your option) any later version.
15 ;;
7e94ded @scymtym * rudel-transport.el: socket-like interface for transports
scymtym authored
16 ;; Rudel is distributed in the hope that it will be useful, but
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 ;; General Public License for more details.
f4da3b8 * Project.ede (target rudel): added rudel-transport.el
jan authored
20 ;;
21 ;; You should have received a copy of the GNU General Public License
7e94ded @scymtym * rudel-transport.el: socket-like interface for transports
scymtym authored
22 ;; along with Rudel. If not, see <http://www.gnu.org/licenses>.
f4da3b8 * Project.ede (target rudel): added rudel-transport.el
jan authored
23
24
25 ;;; Commentary:
26 ;;
7e94ded @scymtym * rudel-transport.el: socket-like interface for transports
scymtym authored
27 ;; This file contains the interface definition for Rudel transport
28 ;; objects and Rudel transport backends.
f4da3b8 * Project.ede (target rudel): added rudel-transport.el
jan authored
29
30
31 ;;; History:
32 ;;
7e94ded @scymtym * rudel-transport.el: socket-like interface for transports
scymtym authored
33 ;; 0.2 - Socket-like interface
34 ;;
fd8b48a @scymtym * rudel-transport.el (header): updated history section
scymtym authored
35 ;; 0.1 - Initial version
f4da3b8 * Project.ede (target rudel): added rudel-transport.el
jan authored
36
37
38 ;;; Code:
39 ;;
40
41 (require 'eieio)
42
fd8b48a @scymtym * rudel-transport.el (header): updated history section
scymtym authored
43 (require 'rudel-errors) ;; for `rudel-error'
f4da3b8 * Project.ede (target rudel): added rudel-transport.el
jan authored
44 (require 'rudel-backend)
45
46
95d187a @scymtym * rudel-transport.el (require rudel-errors): new require; for
scymtym authored
47 ;;; Error conditions
48 ;;
49
50 ;; rudel-malformed-message
51
52 (intern "rudel-malformed-message")
53
54 (put 'rudel-malformed-message 'error-conditions
55 '(error
56 rudel-error rudel-malformed-message))
57
58 (put 'rudel-malformed-message 'error-message
59 "Received malformed message")
60
61
f4da3b8 * Project.ede (target rudel): added rudel-transport.el
jan authored
62 ;;; Class rudel-transport
63 ;;
64
65 (defclass rudel-transport ()
66 ()
67 "Interface for transport objects.")
68
7e94ded @scymtym * rudel-transport.el: socket-like interface for transports
scymtym authored
69 (defgeneric rudel-set-filter ((this rudel-transport) handler)
70 "Install HANDLER as dispatcher for messages received by THIS.")
71
72 (defgeneric rudel-set-sentinel ((this rudel-transport) handler)
73 "Install HANDLER as dispatcher for state changes of THIS.")
74
75 (defgeneric rudel-send ((this rudel-transport) data)
f4da3b8 * Project.ede (target rudel): added rudel-transport.el
jan authored
76 "Send DATA through THIS transport object.")
77
7e94ded @scymtym * rudel-transport.el: socket-like interface for transports
scymtym authored
78 (defgeneric rudel-close ((this rudel-transport))
79 "Close THIS.")
80
d697d4d @scymtym * rudel-transport.el (rudel-transport-backend::rudel-make-connection):
scymtym authored
81 ;; TODO we could get rid of this if we required implementations to
7e94ded @scymtym * rudel-transport.el: socket-like interface for transports
scymtym authored
82 ;; queue messages until a handler is installed
83 (defgeneric rudel-start ((this rudel-transport))
84 "Start THIS.")
f4da3b8 * Project.ede (target rudel): added rudel-transport.el
jan authored
85
86
abb2343 @scymtym * socket/rudel-socket.el (rudel-socket-listener): new class;
scymtym authored
87 ;;; Class rudel-listener
88 ;;
89
90 (defclass rudel-listener ()
91 ()
92 "Interface for listener objects.
93 Listener objects wait for incoming connections and create
94 transport objects representing such connections."
95 :abstract t)
96
97 (defgeneric rudel-set-dispatcher ((this rudel-listener) handler)
98 "Install HANDLER as dispatch function for incoming connections.
99 HANDLER has to accept a single argument which will be a transport
100 object representing the incoming connection.")
101
102 (defgeneric rudel-close ((this rudel-listener))
103 "Cause THIS to stop listening for incoming connections.")
104
105
f4da3b8 * Project.ede (target rudel): added rudel-transport.el
jan authored
106 ;;; Class rudel-transport-backend
107 ;;
108
109 (defclass rudel-transport-backend (rudel-backend)
110 ()
111 "Interface implemented by transport backends."
112 :abstract t)
113
f1443b5 @scymtym Added rudel-ask-connect-info for transport backends
scymtym authored
114 (defgeneric rudel-ask-connect-info ((this rudel-transport-backend)
115 &optional info)
116 "Retrieve information for making a new connection.
117 When INFO is non-nil, augment INFO to produce new list.
118 Return a property list that contains the collected information.")
119
abb2343 @scymtym * socket/rudel-socket.el (rudel-socket-listener): new class;
scymtym authored
120 (defgeneric rudel-make-connection ((this rudel-transport-backend)
121 info info-callback
10cbdf6 @scymtym * rudel-transport.el (rudel-transport-backend::rudel-make-connection):
scymtym authored
122 &optional progress-callback)
7e94ded @scymtym * rudel-transport.el: socket-like interface for transports
scymtym authored
123 "Create a transport object according to INFO.
d697d4d @scymtym * rudel-transport.el (rudel-transport-backend::rudel-make-connection):
scymtym authored
124
10cbdf6 @scymtym * rudel-transport.el (rudel-transport-backend::rudel-make-connection):
scymtym authored
125 INFO-CALLBACK is called when the information provided in INFO is
126 not sufficient for establishing the requested
127 connection. INFO-CALLBACK has to accept the backend object and a
128 property list containing the current connection information and
129 return a property list containing the augmented connection
130 information.
131
71f4c20 @scymtym Fixed a typo in documentation string of rudel-make-connection
scymtym authored
132 When non-nil, PROGRESS-CALLBACK has to accept two arguments: a
10cbdf6 @scymtym * rudel-transport.el (rudel-transport-backend::rudel-make-connection):
scymtym authored
133 state string and a float in the range [0, 1] indicating the
134 progress. PROGRESS-CALLBACK may be called repeatedly while the
135 connection is established.
136
7e94ded @scymtym * rudel-transport.el: socket-like interface for transports
scymtym authored
137 The returned transport object has to be in a stopped state in the
138 sense that it does not attempt to dispatch any data to the filter
10cbdf6 @scymtym * rudel-transport.el (rudel-transport-backend::rudel-make-connection):
scymtym authored
139 function before `rudel-start' has been called.")
f4da3b8 * Project.ede (target rudel): added rudel-transport.el
jan authored
140
141 (defgeneric rudel-wait-for-connections ((this rudel-transport-backend)
abb2343 @scymtym * socket/rudel-socket.el (rudel-socket-listener): new class;
scymtym authored
142 info info-callback)
143 "Create and return listener object according to INFO.
144 INFO has to be a property list specifying desired properties of
145 the created listener.
d697d4d @scymtym * rudel-transport.el (rudel-transport-backend::rudel-make-connection):
scymtym authored
146
abb2343 @scymtym * socket/rudel-socket.el (rudel-socket-listener): new class;
scymtym authored
147 INFO-CALLBACK is called when the information provided in INFO is
148 not sufficient for creating the requested listener. INFO-CALLBACK
149 has to accept the backend object and a property list containing
150 the current information and return a property list containing
151 augmented information.")
f4da3b8 * Project.ede (target rudel): added rudel-transport.el
jan authored
152
153 (provide 'rudel-transport)
154 ;;; rudel-transport.el ends here
Something went wrong with that request. Please try again.