SipMSRPApi

Version 1 (Tijmen de Mes, 05/08/2012 06:06 pm)

1 1 Tijmen de Mes
h1. MSRP API
2 1 Tijmen de Mes
3 1 Tijmen de Mes
4 1 Tijmen de Mes
5 1 Tijmen de Mes
6 1 Tijmen de Mes
Message Session Relay Protocol (MSRP) is a protocol for transmitting a series of related Instant Messages in the context of a session. Message sessions are treated like any other media stream when set up via a rendezvous or session creation protocol such as the Session Initiation Protocol (SIP).  MSRP can be used for any application that requires a reliable stream of data, for example File Transfer or Desktop Sharing.
7 1 Tijmen de Mes
8 1 Tijmen de Mes
* MSRP sessions are defined in "RFC 4975":http://tools.ietf.org/html/rfc4975
9 1 Tijmen de Mes
* MSRP relay extension for NAT traversal is defined in "RFC 4976":http://tools.ietf.org/html/rfc4976
10 1 Tijmen de Mes
11 1 Tijmen de Mes
The MSRP protocol stack is implemented by "python-msrplib":http://download.ag-projects.com/SipClient package. 
12 1 Tijmen de Mes
13 1 Tijmen de Mes
@msrplib@ is based upon "twisted":http://twistedmatrix.com and "eventlet":http://download.ag-projects.com/SipClient/ and provides a set of classes for establishing and managing MSRP connections.
14 1 Tijmen de Mes
15 1 Tijmen de Mes
The library consists of the following modules:
16 1 Tijmen de Mes
17 1 Tijmen de Mes
*msrplib.transport*
18 1 Tijmen de Mes
 Defines @MSRPTransport@ class, which provides low level control over MSRP connections.
19 1 Tijmen de Mes
20 1 Tijmen de Mes
*msrplib.connect*
21 1 Tijmen de Mes
 Defines means to establish a connection, bind it, and provide an initialized @MSRPTransport@ instance.
22 1 Tijmen de Mes
23 1 Tijmen de Mes
*msrplib.session*
24 1 Tijmen de Mes
 Defines @MSRPSession@ class, which provides high level control over a MSRP connection.
25 1 Tijmen de Mes
26 1 Tijmen de Mes
*msrplib.protocol*
27 1 Tijmen de Mes
 Provides representation and parsing of MSRP entities - chunks and MSRP URIs.  
28 1 Tijmen de Mes
29 1 Tijmen de Mes
30 1 Tijmen de Mes
h2. URI
31 1 Tijmen de Mes
32 1 Tijmen de Mes
33 1 Tijmen de Mes
This class is implemented in the @msrplib.protocol@ module and is used to represent an MSRP URI.
34 1 Tijmen de Mes
35 1 Tijmen de Mes
36 1 Tijmen de Mes
h4. methods
37 1 Tijmen de Mes
38 1 Tijmen de Mes
39 1 Tijmen de Mes
*<notextile>__init__</notextile>*(_self_, *host*=@None@, *use_tls*=@False@, *user*=@None@, *port*=@None@, *session_id*=@None@, *parameters*=@None@, *credentials*=@None@)
40 1 Tijmen de Mes
>Constructs a new @URI@. All the arguments specified here are also attributes on the object. For more information on these attributes, see RFC4975.
41 1 Tijmen de Mes
  
42 1 Tijmen de Mes
>+_host_+:
43 1 Tijmen de Mes
44 1 Tijmen de Mes
>The hostname or IP address which forms the URI.
45 1 Tijmen de Mes
  
46 1 Tijmen de Mes
>+_use_tls_+:
47 1 Tijmen de Mes
48 1 Tijmen de Mes
>Whether this identifies an msrps or msrp URI.
49 1 Tijmen de Mes
  
50 1 Tijmen de Mes
>+_user_+:
51 1 Tijmen de Mes
52 1 Tijmen de Mes
>The user part of the URI.
53 1 Tijmen de Mes
  
54 1 Tijmen de Mes
>+_port_+:
55 1 Tijmen de Mes
56 1 Tijmen de Mes
>The port in the URI.
57 1 Tijmen de Mes
  
58 1 Tijmen de Mes
>+_session_id_+:
59 1 Tijmen de Mes
60 1 Tijmen de Mes
>The session identifier part of the URI.
61 1 Tijmen de Mes
  
62 1 Tijmen de Mes
>+_parameters_+:
63 1 Tijmen de Mes
64 1 Tijmen de Mes
>A @dict@ containing the parameters which will be appended to the URI.
65 1 Tijmen de Mes
  
66 1 Tijmen de Mes
>+_credentials_+:
67 1 Tijmen de Mes
68 1 Tijmen de Mes
>A @gnutls.interfaces.twisted.X509Credentials@ object which will be used if this identifies a TLS URI to authenticate to the other endpoint.
69 1 Tijmen de Mes
70 1 Tijmen de Mes
71 1 Tijmen de Mes
h2. MSRPRelaySettings
72 1 Tijmen de Mes
73 1 Tijmen de Mes
74 1 Tijmen de Mes
This class is implemented in the @msrplib.connect@ module and is used to specify the MSRP relay which will be used when connecting via a relay (using the @ConnectorRelay@ or @AcceptorRelay@ classes).
75 1 Tijmen de Mes
76 1 Tijmen de Mes
77 1 Tijmen de Mes
h4. methods
78 1 Tijmen de Mes
79 1 Tijmen de Mes
80 1 Tijmen de Mes
*<notextile>__init__</notextile>*(_self_, *domain*, *username*, *password*, *host*=@None@, *use_tls*=@False@, *port*=@None@, *credentials*=@None@)
81 1 Tijmen de Mes
>Constructs a new @URI@. All the arguments specified here are also attributes on the object. For more information on these attributes, see RFC4975.
82 1 Tijmen de Mes
  
83 1 Tijmen de Mes
>+_domain_+:
84 1 Tijmen de Mes
85 1 Tijmen de Mes
>The DNS domain in which to search for a MSRP relay using SRV queries.
86 1 Tijmen de Mes
  
87 1 Tijmen de Mes
>+_username_+:
88 1 Tijmen de Mes
89 1 Tijmen de Mes
>The username which will be used to authenticate to the relay.
90 1 Tijmen de Mes
  
91 1 Tijmen de Mes
>+_password_+:
92 1 Tijmen de Mes
93 1 Tijmen de Mes
>The password which will be used to authenticate to the relay.
94 1 Tijmen de Mes
  
95 1 Tijmen de Mes
>+_host_+:
96 1 Tijmen de Mes
97 1 Tijmen de Mes
>The hostname or IP address of the MSRP relay.
98 1 Tijmen de Mes
  
99 1 Tijmen de Mes
>+_use_tls_+:
100 1 Tijmen de Mes
101 1 Tijmen de Mes
>Whether this identifies an msrps or msrp URI.
102 1 Tijmen de Mes
  
103 1 Tijmen de Mes
>+_port_+:
104 1 Tijmen de Mes
105 1 Tijmen de Mes
>The port in the URI.
106 1 Tijmen de Mes
  
107 1 Tijmen de Mes
>+_credentials_+:
108 1 Tijmen de Mes
109 1 Tijmen de Mes
>A @gnutls.interfaces.twisted.X509Credentials@ object which will be used to authenticate to the relay if TLS is used.
110 1 Tijmen de Mes
111 1 Tijmen de Mes
112 1 Tijmen de Mes
h2. ConnectorDirect
113 1 Tijmen de Mes
114 1 Tijmen de Mes
115 1 Tijmen de Mes
This class is implemented in the @msrplib.connect@ module and is used for outbound MSRP connections without a relay.
116 1 Tijmen de Mes
117 1 Tijmen de Mes
118 1 Tijmen de Mes
h4. methods
119 1 Tijmen de Mes
120 1 Tijmen de Mes
121 1 Tijmen de Mes
*<notextile>__init__</notextile>*(_self_, *loger*=@None@, *use_sessmatch*=@False@)
122 1 Tijmen de Mes
 Constructs a new ConnectorDirect.
123 1 Tijmen de Mes
 
124 1 Tijmen de Mes
>+_logger_+:
125 1 Tijmen de Mes
126 1 Tijmen de Mes
 The logger which will be used for this MSRP connection. See the [[SipMSRPApi#Logging|Logging]] section for more information.
127 1 Tijmen de Mes
 
128 1 Tijmen de Mes
>+_use_sessmatch_+:
129 1 Tijmen de Mes
130 1 Tijmen de Mes
 Indicates if the connector should use the session matching mechanism defined by the "sessmatch draft version 10":http://tools.ietf.org/html/draft-ietf-simple-msrp-sessmatch-10
131 1 Tijmen de Mes
132 1 Tijmen de Mes
*prepare*(_self_, *local_uri*=@None@)
133 1 Tijmen de Mes
 This method returns a full local path - list of @protocol.URI@ instances, suitable to be put in SDP @'a:path'@ attribute.
134 1 Tijmen de Mes
 
135 1 Tijmen de Mes
>+_local_uri_+:
136 1 Tijmen de Mes
137 1 Tijmen de Mes
 This attribute will be used to construct the local path, but other than that it is not used anywhere else in case of the ConnectorDirect. If not provided, one
138 1 Tijmen de Mes
 will be automatically generated
139 1 Tijmen de Mes
 
140 1 Tijmen de Mes
*complete*(_self_, *full_remote_path*)
141 1 Tijmen de Mes
 This method establishes the connection and binds it (sends an empty chunk to verify each other's From-Path and To-Path). It returns @transport.MSRPTransport@ instance, ready to read and send chunks.
142 1 Tijmen de Mes
 
143 1 Tijmen de Mes
>+_full_remote_path_+:
144 1 Tijmen de Mes
145 1 Tijmen de Mes
 A list of @protocol.URI@ instances, obtained by parsing @'a:path'@ put in SDP by the remote party.
146 1 Tijmen de Mes
147 1 Tijmen de Mes
*cleanup*(_self_)
148 1 Tijmen de Mes
 This method cleans up after @prepare()@; it should be called if @complete()@ will not be called for whatever reason.
149 1 Tijmen de Mes
150 1 Tijmen de Mes
151 1 Tijmen de Mes
h2. AcceptorDirect
152 1 Tijmen de Mes
153 1 Tijmen de Mes
154 1 Tijmen de Mes
This class is implemented in the @msrplib.connect@ module and is used for inbound MSRP connections without using a relay.
155 1 Tijmen de Mes
156 1 Tijmen de Mes
157 1 Tijmen de Mes
h4. methods
158 1 Tijmen de Mes
159 1 Tijmen de Mes
160 1 Tijmen de Mes
*<notextile>__init__</notextile>*(_self_, *loger*=@None@, *use_sessmatch*=@False@)
161 1 Tijmen de Mes
>Constructs a new AcceptorDirect.
162 1 Tijmen de Mes
 
163 1 Tijmen de Mes
>+_logger_+:
164 1 Tijmen de Mes
165 1 Tijmen de Mes
 The logger which will be used for this MSRP connection. See the [[SipMSRPApi#Logging|Logging]] section for more information.
166 1 Tijmen de Mes
 
167 1 Tijmen de Mes
>+_use_sessmatch_+:
168 1 Tijmen de Mes
169 1 Tijmen de Mes
 Indicates if the connector should use the session matching mechanism defined by the "sessmatch draft version 10":http://tools.ietf.org/html/draft-ietf-simple-msrp-sessmatch-10
170 1 Tijmen de Mes
171 1 Tijmen de Mes
*prepare*(_self_, *local_uri*=@None@)
172 1 Tijmen de Mes
 This method starts listening on a socket identified by the parameters in the @local_uri@ argument. It returns a full local path - list of @protocol.URI@ instances, suitable to be put in SDP @'a:path'@ attribute.
173 1 Tijmen de Mes
 
174 1 Tijmen de Mes
>+_local_uri_+:
175 1 Tijmen de Mes
176 1 Tijmen de Mes
 This attribute will be used to construct the local path and to listen for incomming connections. If not provided, one
177 1 Tijmen de Mes
 will be automatically generated. Note that the object may be changed in place: for example, if the port specified is 0,
178 1 Tijmen de Mes
 a random one will be selected and the object will be updated accordingly.
179 1 Tijmen de Mes
 
180 1 Tijmen de Mes
*complete*(_self_, *full_remote_path*)
181 1 Tijmen de Mes
 This method waits for an incoming connection and a chunk sent by the other party. It returns @transport.MSRPTransport@ instance, ready to read and send chunks.
182 1 Tijmen de Mes
 
183 1 Tijmen de Mes
>+_full_remote_path_+:
184 1 Tijmen de Mes
185 1 Tijmen de Mes
 A list of @protocol.URI@ instances, obtained by parsing @'a:path'@ put in SDP by the remote party. This is checked agains the From-Path header in the binding chunk.
186 1 Tijmen de Mes
187 1 Tijmen de Mes
*cleanup*(_self_)
188 1 Tijmen de Mes
 This method cleans up after @prepare()@; it should be called if @complete()@ will not be called for whatever reason.
189 1 Tijmen de Mes
190 1 Tijmen de Mes
191 1 Tijmen de Mes
192 1 Tijmen de Mes
h2. RelayConnection
193 1 Tijmen de Mes
194 1 Tijmen de Mes
195 1 Tijmen de Mes
This class is implemented in the @msrplib.connect@ module and is used for inbound and outbound MSRP connections using a relay.
196 1 Tijmen de Mes
197 1 Tijmen de Mes
198 1 Tijmen de Mes
h4. methods
199 1 Tijmen de Mes
200 1 Tijmen de Mes
201 1 Tijmen de Mes
*<notextile>__init__</notextile>*(_self_, *relay*, *mode*, *loger*=@None@, *use_sessmatch*=@False@)
202 1 Tijmen de Mes
 Constructs a new RelayConnection.
203 1 Tijmen de Mes
 
204 1 Tijmen de Mes
>+_relay_+:
205 1 Tijmen de Mes
206 1 Tijmen de Mes
 An instance of @MSRPRelaySettings@ which identifies the relay which is to be used.
207 1 Tijmen de Mes
 
208 1 Tijmen de Mes
>+_mode_+:
209 1 Tijmen de Mes
210 1 Tijmen de Mes
 A string indicating if this connection should be _active_, an empty SEND should be sent when @complete@ is called, or                         _passive_, where it will wait for one.
211 1 Tijmen de Mes
 
212 1 Tijmen de Mes
>+_logger_+:
213 1 Tijmen de Mes
214 1 Tijmen de Mes
 The logger which will be used for this MSRP connection. See the [[SipMSRPApi#Logging|Logging]] section for more information.
215 1 Tijmen de Mes
 
216 1 Tijmen de Mes
>+_use_sessmatch_+:
217 1 Tijmen de Mes
218 1 Tijmen de Mes
 Indicates if the connector should use the session matching mechanism defined by the "sessmatch draft version 10":http://tools.ietf.org/html/draft-ietf-simple-msrp-sessmatch-10
219 1 Tijmen de Mes
220 1 Tijmen de Mes
*prepare*(_self_, *local_uri*=@None@)
221 1 Tijmen de Mes
 This method returns a full local path - list of @protocol.URI@ instances, suitable to be put in SDP @'a:path'@ attribute.
222 1 Tijmen de Mes
 
223 1 Tijmen de Mes
>+_local_uri_+:
224 1 Tijmen de Mes
225 1 Tijmen de Mes
 This attribute will be used to construct the local path, but other than that it is not used anywhere else in case of the ConnectorRelay. If not provided, one
226 1 Tijmen de Mes
 will be automatically generated
227 1 Tijmen de Mes
 
228 1 Tijmen de Mes
*complete*(_self_, *full_remote_path*)
229 1 Tijmen de Mes
 This method establishes the connection to the relay and binds it (sends an empty chunk or waits for one, depending on the mode, to verify each other's From-Path and To-Path). It returns @transport.MSRPTransport@ instance, ready to read and send chunks.
230 1 Tijmen de Mes
 
231 1 Tijmen de Mes
>+_full_remote_path_+:
232 1 Tijmen de Mes
233 1 Tijmen de Mes
 A list of @protocol.URI@ instances, obtained by parsing @'a:path'@ put in SDP by the remote party.
234 1 Tijmen de Mes
235 1 Tijmen de Mes
*cleanup*(_self_)
236 1 Tijmen de Mes
 This method cleans up after @prepare()@; it should be called if @complete()@ will not be called for whatever reason.
237 1 Tijmen de Mes
238 1 Tijmen de Mes
239 1 Tijmen de Mes
240 1 Tijmen de Mes
h2. MSRPTransport
241 1 Tijmen de Mes
242 1 Tijmen de Mes
243 1 Tijmen de Mes
This class is implemented in the @msrplib.transport@ module and provies low level access to the MSRP connection. This class should not be constructed directly, but rather its intances should be obtained by using the various connector/acceptor classes documented above.
244 1 Tijmen de Mes
245 1 Tijmen de Mes
246 1 Tijmen de Mes
h4. methods
247 1 Tijmen de Mes
248 1 Tijmen de Mes
249 1 Tijmen de Mes
*make_chunk*(_self_, *transaction_id*=@None@, *method*=@'SEND'@, *code*=@None@, *comment*=@None@, *data*=@''@, *contflag*=@None@, *start*=@1@, *end*=@None@, *length*=@None@, *message_id*=@None@)
250 1 Tijmen de Mes
 Creates a new chunk (@protocol.MSRPData@ instance), which is either an MSRP request or a response. Proper @From-Path@, @To-Path@, @Byte-Range@ and @Message-ID@ headers are added based on MSRPTransport's state and the parameters provided. Use _data_ for payload, and _start_/_end_/_length_ to generate the @Byte-Range@ header.
251 1 Tijmen de Mes
 
252 1 Tijmen de Mes
>+_transaction_id_+:
253 1 Tijmen de Mes
254 1 Tijmen de Mes
 The transaction id which will be put in the chunk. If it is not provided, one will be randomly generated.
255 1 Tijmen de Mes
 
256 1 Tijmen de Mes
>+_method_+:
257 1 Tijmen de Mes
258 1 Tijmen de Mes
 The method of the new MSRP request, or @None@ if a response is required.
259 1 Tijmen de Mes
 
260 1 Tijmen de Mes
>+_code_+:
261 1 Tijmen de Mes
262 1 Tijmen de Mes
 The code of the new MSRP response, or @None@ if a request is required.
263 1 Tijmen de Mes
 
264 1 Tijmen de Mes
>+_code_+:
265 1 Tijmen de Mes
266 1 Tijmen de Mes
 The comment of the new MSRP response, or @None@ if a request is required or a comment on the response is not.
267 1 Tijmen de Mes
 
268 1 Tijmen de Mes
>+_data_+:
269 1 Tijmen de Mes
270 1 Tijmen de Mes
 The payload of the new chunk, or an empty string if no payload is required.
271 1 Tijmen de Mes
 
272 1 Tijmen de Mes
>+_contflag_+:
273 1 Tijmen de Mes
274 1 Tijmen de Mes
 MSRP chunk's continuation flag (@'$'@, @'+'@ or @'#'@). Default is @'$'@ for a full message, unless a partial @SEND@ chunk required, in which case it should be set to @'+'@. If @None@ is provided, either @'$'@ or @'+'@ will be used depending on whether this chunk seems to carry the last part of the message data.
275 1 Tijmen de Mes
 
276 1 Tijmen de Mes
>+_start_+:
277 1 Tijmen de Mes
278 1 Tijmen de Mes
 The first byte's index within the whole message payload this chunk will carry as its own payload.
279 1 Tijmen de Mes
 
280 1 Tijmen de Mes
>+_end_+:
281 1 Tijmen de Mes
282 1 Tijmen de Mes
 The last byte's index within the whole message payload this chunk will carry as its own payload. Note that this is an inclusive index. If this is not provided, it's computed based on the number of bytes in data and @start@.
283 1 Tijmen de Mes
 
284 1 Tijmen de Mes
>+_length_+:
285 1 Tijmen de Mes
286 1 Tijmen de Mes
 The total number of bytes of the whole message payload. If this is not provided, it is computed as if this chunk carries that last part of the message payload.
287 1 Tijmen de Mes
 
288 1 Tijmen de Mes
>+_message_id_+:
289 1 Tijmen de Mes
290 1 Tijmen de Mes
 The ID of the message this chunk is part of. If it is not provided, one will be randomly generated.
291 1 Tijmen de Mes
292 1 Tijmen de Mes
*write_chunk*(_self_, *chunk*, *wait*=@True@)
293 1 Tijmen de Mes
 Writes the chunk provided to the underlying socket.
294 1 Tijmen de Mes
 
295 1 Tijmen de Mes
>+_chunk_+:
296 1 Tijmen de Mes
297 1 Tijmen de Mes
 The chunk which is to be written, an instance of @MSRPData@.
298 1 Tijmen de Mes
 
299 1 Tijmen de Mes
>+_wait_+:
300 1 Tijmen de Mes
301 1 Tijmen de Mes
 If @True@, waits for the operation to complete.
302 1 Tijmen de Mes
303 1 Tijmen de Mes
*write_response*(_self_, *chunk*, *code*, *comment*, *wait*=@True@):
304 1 Tijmen de Mes
 Creates a response which is suitable as a reply to the specified chunk and writes it to the underlying socket.
305 1 Tijmen de Mes
 
306 1 Tijmen de Mes
>+_chunk_+:
307 1 Tijmen de Mes
308 1 Tijmen de Mes
 The chunk for which to create a response.
309 1 Tijmen de Mes
 
310 1 Tijmen de Mes
>+_code_+:
311 1 Tijmen de Mes
312 1 Tijmen de Mes
 The status code of the response which is to be created.
313 1 Tijmen de Mes
 
314 1 Tijmen de Mes
>+_comment_+:
315 1 Tijmen de Mes
316 1 Tijmen de Mes
 The comment of the response which is to be created.
317 1 Tijmen de Mes
 
318 1 Tijmen de Mes
>+_wait_+:
319 1 Tijmen de Mes
320 1 Tijmen de Mes
 If @True@, waits for the operation to complete.
321 1 Tijmen de Mes
322 1 Tijmen de Mes
*read_chunk*(_self_, *size*=@None@)
323 1 Tijmen de Mes
 Waits for a new chunk and returns it.
324 1 Tijmen de Mes
 If there was an error, closes the connection and raises @ChunkParseError@.
325 1 Tijmen de Mes
326 1 Tijmen de Mes
 In case of unintelligible input, loses the connection and returns @None@.
327 1 Tijmen de Mes
 When the connection is closed, raises the reason of the closure (e.g. @ConnectionDone@).
328 1 Tijmen de Mes
329 1 Tijmen de Mes
 If the data already read exceeds _size_, stops reading the data and returns
330 1 Tijmen de Mes
 a "virtual" chunk, i.e. the one that does not actually correspond the the real
331 1 Tijmen de Mes
 MSRP chunk. Such chunks have Byte-Range header changed to match the number of
332 1 Tijmen de Mes
 bytes read and continuation that is @'+'@; they also possess @segment@ attribute,
333 1 Tijmen de Mes
 an integer, starting with 1 and increasing with every new segment of the chunk.
334 1 Tijmen de Mes
335 1 Tijmen de Mes
 Note, that _size_ only hints when to interrupt the segment but does not affect
336 1 Tijmen de Mes
 how the data is read from socket. You may have segments bigger than _size_ and it's
337 1 Tijmen de Mes
 legal to set _size_ to zero (which would mean return a chunk as long as you get
338 1 Tijmen de Mes
 some data, regardless how small).
339 1 Tijmen de Mes
 
340 1 Tijmen de Mes
 
341 1 Tijmen de Mes
>+_size_+:
342 1 Tijmen de Mes
343 1 Tijmen de Mes
 The hint towards how much to read from the socket. If the data already read is larger, then all the data will be returned, even if it exceeds @size@ bytes.
344 1 Tijmen de Mes
345 1 Tijmen de Mes
*check_incoming_SEND_chunk*(_self_, *chunk*)
346 1 Tijmen de Mes
 Checks the 'To-Path' and 'From-Path' of the incoming SEND chunk.
347 1 Tijmen de Mes
 Returns None is the paths are valid for this connection.
348 1 Tijmen de Mes
 If an error is detected an MSRPError is created and returned.
349 1 Tijmen de Mes
350 1 Tijmen de Mes
351 1 Tijmen de Mes
h2. MSRPData
352 1 Tijmen de Mes
353 1 Tijmen de Mes
354 1 Tijmen de Mes
This class is implemented in the @msrplib.protocol@ module and represents an MSRP chunk, either a request or a response.
355 1 Tijmen de Mes
356 1 Tijmen de Mes
357 1 Tijmen de Mes
h4. attributes
358 1 Tijmen de Mes
359 1 Tijmen de Mes
360 1 Tijmen de Mes
 The following attributes are read-only.
361 1 Tijmen de Mes
362 1 Tijmen de Mes
*content_type*
363 1 Tijmen de Mes
>The MIME type of the payload carried by this chunk, which is stored in the Content-Type header.
364 1 Tijmen de Mes
365 1 Tijmen de Mes
*message_id*
366 1 Tijmen de Mes
>The ID of the message this chunk is part of, which is stored in the Message-ID header.
367 1 Tijmen de Mes
368 1 Tijmen de Mes
*byte_range*
369 1 Tijmen de Mes
>A 3-tuple containing the start, end and length values (in this order) from the Byte-Range header.
370 1 Tijmen de Mes
371 1 Tijmen de Mes
*status*
372 1 Tijmen de Mes
>The value of the Status header.
373 1 Tijmen de Mes
374 1 Tijmen de Mes
*failure_report*
375 1 Tijmen de Mes
>The value of the Failure-Report header, whether it exists or it is implied; one of @'yes'@, @'no'@, @'partial'@.
376 1 Tijmen de Mes
377 1 Tijmen de Mes
*success_report*
378 1 Tijmen de Mes
>The value of the Success-Report header, whether it exists or it is implied; one of @'yes'@ or @'no'@.
379 1 Tijmen de Mes
380 1 Tijmen de Mes
*size*
381 1 Tijmen de Mes
>The size of the payload of this chunk, in bytes.
382 1 Tijmen de Mes
383 1 Tijmen de Mes
384 1 Tijmen de Mes
h4. methods
385 1 Tijmen de Mes
386 1 Tijmen de Mes
387 1 Tijmen de Mes
*<notextile>__init__</notextile>*(_self_, *transaction_id*, *method*=@None@, *code*=@None@, *comment*=@None@, *headers*=@None@, *data*=@''@, *contflag*=@'$'@)
388 1 Tijmen de Mes
>Initializes a new MSRPData instance. All the arguments are also available as attributes.
389 1 Tijmen de Mes
  
390 1 Tijmen de Mes
>+_transaction_id_+:
391 1 Tijmen de Mes
392 1 Tijmen de Mes
>The transaction identified of this chunk.
393 1 Tijmen de Mes
  
394 1 Tijmen de Mes
>+_method_+:
395 1 Tijmen de Mes
396 1 Tijmen de Mes
>The method of this chunk if it a request and @None@ if it is a response.
397 1 Tijmen de Mes
  
398 1 Tijmen de Mes
>+_code_+:
399 1 Tijmen de Mes
400 1 Tijmen de Mes
>The status code of this chunk if it is a response and @None@ if it is a request.
401 1 Tijmen de Mes
  
402 1 Tijmen de Mes
>+_comment_+:
403 1 Tijmen de Mes
404 1 Tijmen de Mes
>The comment of this chunk if it is a response and @None@ if it is a request.
405 1 Tijmen de Mes
  
406 1 Tijmen de Mes
>+_headers_+:
407 1 Tijmen de Mes
408 1 Tijmen de Mes
>A dict containing the headers which are to be added to this chunk, or @None@ if no headers are to be added.
409 1 Tijmen de Mes
  
410 1 Tijmen de Mes
>+_data_+:
411 1 Tijmen de Mes
412 1 Tijmen de Mes
>The payload of this chunk, or an empty string if no payload is to be added.
413 1 Tijmen de Mes
  
414 1 Tijmen de Mes
>+_contflag_+:
415 1 Tijmen de Mes
416 1 Tijmen de Mes
>The MSRP continuation flag of this chunk, one of @'$'@, @'#'@ or @'+'@.
417 1 Tijmen de Mes
418 1 Tijmen de Mes
*copy*(_self_)
419 1 Tijmen de Mes
>Returns a new MSRPData instance with exactly the same attributes as this object.
420 1 Tijmen de Mes
421 1 Tijmen de Mes
*add_header*(_self_, *header*)
422 1 Tijmen de Mes
>Add a MSRP header to this chunk.
423 1 Tijmen de Mes
  
424 1 Tijmen de Mes
>+_header_+:
425 1 Tijmen de Mes
426 1 Tijmen de Mes
>The header object which is to be added to this chunk.
427 1 Tijmen de Mes
428 1 Tijmen de Mes
*verify_headers*(_self_)
429 1 Tijmen de Mes
>Verifies that the chunk contains a To-Path and a From-Path header and that all the headers are valid.
430 1 Tijmen de Mes
431 1 Tijmen de Mes
*encode_start*(_self_)
432 1 Tijmen de Mes
>Returns a string containing the MSRP header of this chunk.
433 1 Tijmen de Mes
434 1 Tijmen de Mes
*encode_end*(_self_, *continuation*)
435 1 Tijmen de Mes
>Returns a string containing the MSRP end line of this chunk: 7 commas followed by the transaction identifier and the continuation flag specified.
436 1 Tijmen de Mes
  
437 1 Tijmen de Mes
>+_continuation_+:
438 1 Tijmen de Mes
439 1 Tijmen de Mes
>The continuation flag which is to be used in the end line.
440 1 Tijmen de Mes
441 1 Tijmen de Mes
*encode*(_self_):
442 1 Tijmen de Mes
>Returns a string containing the whole of this MSRP chunk.
443 1 Tijmen de Mes
444 1 Tijmen de Mes
445 1 Tijmen de Mes
446 1 Tijmen de Mes
h2. OutgoingFile
447 1 Tijmen de Mes
448 1 Tijmen de Mes
449 1 Tijmen de Mes
This class is implemented in the @msrplib.session@ module and represents a file which is to be sent via MSRP.
450 1 Tijmen de Mes
451 1 Tijmen de Mes
452 1 Tijmen de Mes
h4. attributes
453 1 Tijmen de Mes
454 1 Tijmen de Mes
455 1 Tijmen de Mes
*headers*
456 1 Tijmen de Mes
>A dict which maps header names to header objects. These headers will be sent in the MSRP message used to send the file.
457 1 Tijmen de Mes
458 1 Tijmen de Mes
459 1 Tijmen de Mes
h4. methods
460 1 Tijmen de Mes
461 1 Tijmen de Mes
462 1 Tijmen de Mes
*<notextile>__init__</notextile>*(_self_, *fileobj*, *size*, *content_type*=@None@, *position*=@0@, *message_id*=@None@)
463 1 Tijmen de Mes
>Initializes a new OutgoingFile using the specified file object. All arguments are available as attributes, except for @content_type@ which will be part of the @headers@ attribute.
464 1 Tijmen de Mes
  
465 1 Tijmen de Mes
>+_fileobj_+:
466 1 Tijmen de Mes
467 1 Tijmen de Mes
>A file-like object which will be used for reading the data to be sent.
468 1 Tijmen de Mes
  
469 1 Tijmen de Mes
>+_size_+:
470 1 Tijmen de Mes
471 1 Tijmen de Mes
>The size of the whole file.
472 1 Tijmen de Mes
  
473 1 Tijmen de Mes
>+_content_type_+:
474 1 Tijmen de Mes
475 1 Tijmen de Mes
>The MIME type associated with the file's data. If provided, it will be added as a Content-Type header.
476 1 Tijmen de Mes
  
477 1 Tijmen de Mes
>+_position_+:
478 1 Tijmen de Mes
479 1 Tijmen de Mes
>The position within the file from which data will be sent. The file object must already be seeked to this position.
480 1 Tijmen de Mes
  
481 1 Tijmen de Mes
>+_message_id_+:
482 1 Tijmen de Mes
483 1 Tijmen de Mes
>The message ID which will be used for sending this file.
484 1 Tijmen de Mes
485 1 Tijmen de Mes
486 1 Tijmen de Mes
h2. MSRPSession
487 1 Tijmen de Mes
488 1 Tijmen de Mes
489 1 Tijmen de Mes
This class is implemented in the @msrplib.session@ module and provides a high level API for MSRP sessions.
490 1 Tijmen de Mes
491 1 Tijmen de Mes
492 1 Tijmen de Mes
h4. methods
493 1 Tijmen de Mes
494 1 Tijmen de Mes
495 1 Tijmen de Mes
*<notextile>__init__</notextile>*(_self_, *msrptransport*, *accept_types*=@['*']@, *on_incoming_cb*=@None@)
496 1 Tijmen de Mes
 Initializes MSRPSession instance over the specified transport. The incoming chunks are reported through the _on_incoming_cb_ callback.
497 1 Tijmen de Mes
 
498 1 Tijmen de Mes
>+_msrptransport_+:
499 1 Tijmen de Mes
500 1 Tijmen de Mes
 An instance of @MSRPTransport@ over which this session will operate.
501 1 Tijmen de Mes
 
502 1 Tijmen de Mes
>+_accept_types_+:
503 1 Tijmen de Mes
504 1 Tijmen de Mes
 A list of MIME types which are acceptable over this session. If data is received with a Content-Type header which doesn't match this list, a negative response is sent back and the application does not get the received data. The special strings @'*'@ and @'<type>/*'@ can be used to match multiple MIME types.
505 1 Tijmen de Mes
 
506 1 Tijmen de Mes
>+_on_incoming_cb_+:
507 1 Tijmen de Mes
508 1 Tijmen de Mes
 A function which receives two arguments, both optional with default values of @None@: _chunk_ and _error_. This will be called when a new chunk is received.
509 1 Tijmen de Mes
510 1 Tijmen de Mes
*send_chunk*(_self_, *chunk*, *response_cb*=@None@)
511 1 Tijmen de Mes
 Sends the specified chunk and reports the result via the _response_cb_ callback.
512 1 Tijmen de Mes
513 1 Tijmen de Mes
 When _response_cb_ argument is present, it will be used to report
514 1 Tijmen de Mes
 the transaction response to the caller. When a response is received or generated
515 1 Tijmen de Mes
 locally, _response_cb_ is called with one argument. The function must do something
516 1 Tijmen de Mes
 quickly and must not block, because otherwise it would block the reader greenlet.
517 1 Tijmen de Mes
518 1 Tijmen de Mes
 If no response was received after @RESPONSE_TIMEOUT@ seconds,
519 1 Tijmen de Mes
* 408 response is generated if Failure-Report was @'yes'@ or absent
520 1 Tijmen de Mes
* 200 response is generated if Failure-Report was @'partial'@ or @'no'@
521 1 Tijmen de Mes
522 1 Tijmen de Mes
 Note that it's rather wasteful to provide _response_cb_ argument other than @None@
523 1 Tijmen de Mes
 for chunks with Failure-Report='no' since it will always fire 30 seconds later
524 1 Tijmen de Mes
 with 200 result (unless the other party is broken and ignores Failure-Report header)
525 1 Tijmen de Mes
526 1 Tijmen de Mes
 If sending is not possible, @MSRPSessionError@ is raised.
527 1 Tijmen de Mes
528 1 Tijmen de Mes
 
529 1 Tijmen de Mes
>+_chunk_+:
530 1 Tijmen de Mes
531 1 Tijmen de Mes
 The chunk which is to be sent. It must be an instance of @MSRPData@ which represents a request.
532 1 Tijmen de Mes
 
533 1 Tijmen de Mes
>+_response_cb_+:
534 1 Tijmen de Mes
535 1 Tijmen de Mes
 A function receiving a single argument which will be the response received for the sent chunk.
536 1 Tijmen de Mes
537 1 Tijmen de Mes
*deliver_chunk*(_self_, *chunk*, *event*=@None@)
538 1 Tijmen de Mes
 Sends the specified chunk and waits for the transaction response (if Failure-Report header is not @'no'@).
539 1 Tijmen de Mes
 Returns the transaction response if it's a success or raise @MSRPTransactionError@ if it's not.
540 1 Tijmen de Mes
541 1 Tijmen de Mes
 If chunk's Failure-Report is @'no'@, returns @None@ immediately.
542 1 Tijmen de Mes
543 1 Tijmen de Mes
 
544 1 Tijmen de Mes
>+_chunk_+:
545 1 Tijmen de Mes
546 1 Tijmen de Mes
 The chunk which is to be sent. It must be an intance of @MSRPData@ which represents a request.
547 1 Tijmen de Mes
 
548 1 Tijmen de Mes
>+_event_+:
549 1 Tijmen de Mes
550 1 Tijmen de Mes
 The @eventlet.coros.event@ object which will be used to wait for a response. It's send method will be called when a response is received. If it is not provided, one will be constructed automatically and used.
551 1 Tijmen de Mes
 
552 1 Tijmen de Mes
*send_file*(_self_, *outgoing_file*)
553 1 Tijmen de Mes
 Adds the specified file to the queue of files to be sent. The method returns immediately.
554 1 Tijmen de Mes
 
555 1 Tijmen de Mes
>+_outgoing_file_+:
556 1 Tijmen de Mes
557 1 Tijmen de Mes
 An instance of @OutgoingFile@ which represents the file to be sent.
558 1 Tijmen de Mes
559 1 Tijmen de Mes
*shutdown*(_self_, *sync*=@True@)
560 1 Tijmen de Mes
 Sends the messages already in queue then closes the connection.
561 1 Tijmen de Mes
562 1 Tijmen de Mes
563 1 Tijmen de Mes
h2. MSRPServer
564 1 Tijmen de Mes
565 1 Tijmen de Mes
566 1 Tijmen de Mes
This class is implemented in the @msrplib.connect@ module.
567 1 Tijmen de Mes
    
568 1 Tijmen de Mes
MSRPServer solves the problem with AcceptorDirect: concurrent using of 2
569 1 Tijmen de Mes
or more AcceptorDirect instances on the same non-zero port is not possible.
570 1 Tijmen de Mes
If you initialize() those instances, one after another, one will listen on
571 1 Tijmen de Mes
the socket and another will get BindError.
572 1 Tijmen de Mes
573 1 Tijmen de Mes
MSRPServer avoids the problem by sharing the listening socket between multiple connections.
574 1 Tijmen de Mes
It has a slightly different interface from AcceptorDirect, so it cannot be considered a drop-in
575 1 Tijmen de Mes
replacement.
576 1 Tijmen de Mes
577 1 Tijmen de Mes
It manages the listening sockets and binds incoming requests.
578 1 Tijmen de Mes
579 1 Tijmen de Mes
580 1 Tijmen de Mes
h4. methods
581 1 Tijmen de Mes
582 1 Tijmen de Mes
583 1 Tijmen de Mes
*<notextile>__init__</notextile>*(_self_, *logger*)
584 1 Tijmen de Mes
 Constructs a new MSRPServer which will be using the specifed logger for its connections.
585 1 Tijmen de Mes
 
586 1 Tijmen de Mes
>+_logger_+:
587 1 Tijmen de Mes
588 1 Tijmen de Mes
 The default logger which will be used for this object's MSRP connections. See the [[SipMSRPApi#Logging|Logging]] section for more information.
589 1 Tijmen de Mes
590 1 Tijmen de Mes
*prepare*(_self_, _local_uri_=@None@, _logger_=@None@)
591 1 Tijmen de Mes
 Starts a listening port specified by _local_uri_ if there isn't one on that port/interface already.
592 1 Tijmen de Mes
 Adds _local_uri_ to the list of expected URIs, so that incoming connections featuring this URI won't be rejected.
593 1 Tijmen de Mes
 If _logger_ is provided, it uses it for this connection instead of the one specified in @__init___@.
594 1 Tijmen de Mes
 
595 1 Tijmen de Mes
>+_local_uri_+:
596 1 Tijmen de Mes
597 1 Tijmen de Mes
 The URI which will be added to the list of expected URIs. Connections from this URI will be accepted.
598 1 Tijmen de Mes
 
599 1 Tijmen de Mes
>+_logger_+:
600 1 Tijmen de Mes
601 1 Tijmen de Mes
 The logger which will be used for connections from the specified URI. See the [[SipMSRPApi#Logging|Logging]] section for more information.
602 1 Tijmen de Mes
603 1 Tijmen de Mes
*complete*(_self_, _full_remote_path_)
604 1 Tijmen de Mes
 Waits until one of the incoming connections binds using the provided _full_remote_path_.
605 1 Tijmen de Mes
 Returns the connected and bound @MSRPTransport@ instance.
606 1 Tijmen de Mes
 If no such binding was made within @MSRPBindSessionTimeout.seconds@, @MSRPBindSessionTimeout@ is raised.
607 1 Tijmen de Mes
 
608 1 Tijmen de Mes
>+_full_remote_path_+:
609 1 Tijmen de Mes
610 1 Tijmen de Mes
 A list of @protocol.URI@ instances, obtained by parsing @'a:path'@ put in SDP by the remote party.
611 1 Tijmen de Mes
612 1 Tijmen de Mes
*cleanup*(_self_, _local_uri_)
613 1 Tijmen de Mes
 Removes _local_uri_ from the list of expected URIs.
614 1 Tijmen de Mes
 
615 1 Tijmen de Mes
>+_local_uri_+:
616 1 Tijmen de Mes
617 1 Tijmen de Mes
 The URI which is to be removed from the list of expected URIs.
618 1 Tijmen de Mes
619 1 Tijmen de Mes
620 1 Tijmen de Mes
h2. Headers
621 1 Tijmen de Mes
622 1 Tijmen de Mes
623 1 Tijmen de Mes
The MSRP headers are represented using objects from the @msrplib.protocol module@. All MSRP header object provide three properties:
624 1 Tijmen de Mes
 _name_:
625 1 Tijmen de Mes
626 1 Tijmen de Mes
 The name of the header, as it appears in MSRP chunks.
627 1 Tijmen de Mes
 
628 1 Tijmen de Mes
>+_encode_+:
629 1 Tijmen de Mes
630 1 Tijmen de Mes
 The MSRP encoded header value, as it appears in MSRP chunks.
631 1 Tijmen de Mes
 
632 1 Tijmen de Mes
>+_decode_+:
633 1 Tijmen de Mes
634 1 Tijmen de Mes
 The high-level object representing the header value.
635 1 Tijmen de Mes
636 1 Tijmen de Mes
All headers can be constructed by passing either the encoded or decoded objects to @__init__@. The following headers are provided:
637 1 Tijmen de Mes
638 1 Tijmen de Mes
639 1 Tijmen de Mes
h3. ToPathHeader
640 1 Tijmen de Mes
641 1 Tijmen de Mes
642 1 Tijmen de Mes
The name of the header is @'To-Path'@ and the decoded value is a deque of @URI@ objects.
643 1 Tijmen de Mes
644 1 Tijmen de Mes
645 1 Tijmen de Mes
h3. FromPathHeader
646 1 Tijmen de Mes
647 1 Tijmen de Mes
648 1 Tijmen de Mes
The name of the header is @'From-Path'@ and the decoded value is a deque of @URI@ objects.
649 1 Tijmen de Mes
650 1 Tijmen de Mes
651 1 Tijmen de Mes
h3. MessageIDHeader
652 1 Tijmen de Mes
653 1 Tijmen de Mes
654 1 Tijmen de Mes
The name of the header is @'Message-ID'@ and the decoded value is the string containing the message ID.
655 1 Tijmen de Mes
656 1 Tijmen de Mes
657 1 Tijmen de Mes
h3. SuccessReportHeader
658 1 Tijmen de Mes
659 1 Tijmen de Mes
660 1 Tijmen de Mes
The name of the header is @'Success-Report'@ and the decoded value is one of @'yes'@ or @'no'@.
661 1 Tijmen de Mes
662 1 Tijmen de Mes
663 1 Tijmen de Mes
h3. FailureReportHeader
664 1 Tijmen de Mes
665 1 Tijmen de Mes
666 1 Tijmen de Mes
The name of the header is @'Failure-Report'@ and the decoded value is one of @'yes'@, @'partial'@ or @'no'@.
667 1 Tijmen de Mes
668 1 Tijmen de Mes
669 1 Tijmen de Mes
h3. ByteRangeHeader
670 1 Tijmen de Mes
671 1 Tijmen de Mes
672 1 Tijmen de Mes
The name of the header is @'Byte-Range'@ and the decoded value is a 3-tuple containing the start, end and length values.
673 1 Tijmen de Mes
674 1 Tijmen de Mes
675 1 Tijmen de Mes
h4. attributes
676 1 Tijmen de Mes
677 1 Tijmen de Mes
678 1 Tijmen de Mes
*fro*
679 1 Tijmen de Mes
>The start value of the header: the index within the whole message payload where a chunk's payload starts.
680 1 Tijmen de Mes
*end*
681 1 Tijmen de Mes
>The end value of the header: the index within the whole message payload where a chunk's payload ends. Note that this index is inclusive.
682 1 Tijmen de Mes
*length*
683 1 Tijmen de Mes
>The total size of the message payload.
684 1 Tijmen de Mes
685 1 Tijmen de Mes
686 1 Tijmen de Mes
h3. StatusHeader
687 1 Tijmen de Mes
688 1 Tijmen de Mes
689 1 Tijmen de Mes
The name of the header is @'Status'@ and the decoded value is a 2-tuple containing the status code and comment.
690 1 Tijmen de Mes
691 1 Tijmen de Mes
692 1 Tijmen de Mes
h4. attributes
693 1 Tijmen de Mes
694 1 Tijmen de Mes
695 1 Tijmen de Mes
*code*
696 1 Tijmen de Mes
>The code component of the header.
697 1 Tijmen de Mes
*comment*
698 1 Tijmen de Mes
>The comment component of the header.
699 1 Tijmen de Mes
700 1 Tijmen de Mes
701 1 Tijmen de Mes
h3. ExpiresHeader
702 1 Tijmen de Mes
703 1 Tijmen de Mes
704 1 Tijmen de Mes
The name of the header is @'Expires'@ and the decoded value is an integer.
705 1 Tijmen de Mes
706 1 Tijmen de Mes
707 1 Tijmen de Mes
h3. MinExpiresHeader
708 1 Tijmen de Mes
709 1 Tijmen de Mes
710 1 Tijmen de Mes
The name of the header is @'Min-Expires'@ and the decoded value is an integer.
711 1 Tijmen de Mes
712 1 Tijmen de Mes
713 1 Tijmen de Mes
h3. MaxExpiresHeader
714 1 Tijmen de Mes
715 1 Tijmen de Mes
716 1 Tijmen de Mes
The name of the header is @'Max-Expires'@ and the decoded value is an integer.
717 1 Tijmen de Mes
718 1 Tijmen de Mes
719 1 Tijmen de Mes
h3. UsePathHeader
720 1 Tijmen de Mes
721 1 Tijmen de Mes
722 1 Tijmen de Mes
The name of the header is @'Use-Path'@ and the decoded value is a deque of @URI@ objects.
723 1 Tijmen de Mes
724 1 Tijmen de Mes
725 1 Tijmen de Mes
h3. WWWAuthenticateHeader
726 1 Tijmen de Mes
727 1 Tijmen de Mes
728 1 Tijmen de Mes
The name of the header is @'WWW-Authenticate'@ and the decoded value is a dictionary of the parameters within the header.
729 1 Tijmen de Mes
730 1 Tijmen de Mes
731 1 Tijmen de Mes
h3. AuthorizationHeader
732 1 Tijmen de Mes
733 1 Tijmen de Mes
734 1 Tijmen de Mes
The name of the header is @'Authorization'@ and the decoded value is a dictionary of the parameters within the header.
735 1 Tijmen de Mes
736 1 Tijmen de Mes
737 1 Tijmen de Mes
h3. AuthenticationInfoHeader
738 1 Tijmen de Mes
739 1 Tijmen de Mes
740 1 Tijmen de Mes
The name of the header is @'Authentication-Info'@ and the decoded value is a dictionary of the parameters within the header.
741 1 Tijmen de Mes
742 1 Tijmen de Mes
743 1 Tijmen de Mes
h3. ContentTypeHeader
744 1 Tijmen de Mes
745 1 Tijmen de Mes
746 1 Tijmen de Mes
The name of the header is @'Content-Type'@ and the decoded value is the string representing the MIME type.
747 1 Tijmen de Mes
748 1 Tijmen de Mes
749 1 Tijmen de Mes
h3. ContentIDHeader
750 1 Tijmen de Mes
751 1 Tijmen de Mes
752 1 Tijmen de Mes
The name of the header is @'Content-ID'@ and the decoded value is the string with the value of the header.
753 1 Tijmen de Mes
754 1 Tijmen de Mes
755 1 Tijmen de Mes
h3. ContentDescriptionHeader
756 1 Tijmen de Mes
757 1 Tijmen de Mes
758 1 Tijmen de Mes
The name of the header is @'Content-Description'@ and the decoded value is the string with the value of the header.
759 1 Tijmen de Mes
760 1 Tijmen de Mes
761 1 Tijmen de Mes
h3. ContentDispositionHeader
762 1 Tijmen de Mes
763 1 Tijmen de Mes
764 1 Tijmen de Mes
The name of the header is @'Content-Disposition'@ and the decoded value is a list with two elements: the disposition and a dict with the parameters.
765 1 Tijmen de Mes
766 1 Tijmen de Mes
767 1 Tijmen de Mes
768 1 Tijmen de Mes
h2. Logging
769 1 Tijmen de Mes
770 1 Tijmen de Mes
771 1 Tijmen de Mes
Logging is done throughout the library using objects defined by the application, called loggers. If logging is not desired, the @application.python.Null@ object of @python-application@ can be used. These loggers must define the following methods:
772 1 Tijmen de Mes
773 1 Tijmen de Mes
774 1 Tijmen de Mes
h4. methods
775 1 Tijmen de Mes
776 1 Tijmen de Mes
777 1 Tijmen de Mes
*received_new_chunk*(*data*, *transport*, *chunk*)
778 1 Tijmen de Mes
>This method is called when the start of a new chunk is received.
779 1 Tijmen de Mes
  
780 1 Tijmen de Mes
>+_data_+:
781 1 Tijmen de Mes
782 1 Tijmen de Mes
>The data which came along with the start of the chunk.
783 1 Tijmen de Mes
  
784 1 Tijmen de Mes
>+_transport_+:
785 1 Tijmen de Mes
786 1 Tijmen de Mes
>The @MSRPTransport@ instance on which the chunk was received.
787 1 Tijmen de Mes
  
788 1 Tijmen de Mes
>+_chunk_+:
789 1 Tijmen de Mes
790 1 Tijmen de Mes
>The actual chunk object.
791 1 Tijmen de Mes
792 1 Tijmen de Mes
*received_chunk_data*(*data*, *transport*, *transaction_id*)
793 1 Tijmen de Mes
>This method is called when data is received as part of a chunk previously announced via *received_new_chunk*.
794 1 Tijmen de Mes
  
795 1 Tijmen de Mes
>+_data_+:
796 1 Tijmen de Mes
797 1 Tijmen de Mes
>The data received as part of the chunk.
798 1 Tijmen de Mes
  
799 1 Tijmen de Mes
>+_transport_+:
800 1 Tijmen de Mes
801 1 Tijmen de Mes
>The @MSRPTransport@ instance on which the chunk was received.
802 1 Tijmen de Mes
  
803 1 Tijmen de Mes
>+_transaction_id_+:
804 1 Tijmen de Mes
805 1 Tijmen de Mes
>The transaction ID which identifies the chunk for which data was received.
806 1 Tijmen de Mes
807 1 Tijmen de Mes
*received_chunk_end*(*data*, *transport*, *transaction_id*)
808 1 Tijmen de Mes
>This method is called when the last data of a chunk is received. The chunk was previously announced via *received_new_chunk*.
809 1 Tijmen de Mes
  
810 1 Tijmen de Mes
>+_data_+:
811 1 Tijmen de Mes
812 1 Tijmen de Mes
>The last data received as part of the chunk.
813 1 Tijmen de Mes
  
814 1 Tijmen de Mes
>+_transport_+:
815 1 Tijmen de Mes
816 1 Tijmen de Mes
>The @MSRPTransport@ instance on which the chunk was received.
817 1 Tijmen de Mes
  
818 1 Tijmen de Mes
>+_transaction_id_+:
819 1 Tijmen de Mes
820 1 Tijmen de Mes
>The transaction ID which identifies the chunk which was ended.
821 1 Tijmen de Mes
822 1 Tijmen de Mes
*sent_new_chunk*(*data*, *transport*, *chunk*)
823 1 Tijmen de Mes
>This method is called when the start of a new chunk is sent.
824 1 Tijmen de Mes
  
825 1 Tijmen de Mes
>+_data_+:
826 1 Tijmen de Mes
827 1 Tijmen de Mes
>The data which was sent along with the start of the chunk.
828 1 Tijmen de Mes
  
829 1 Tijmen de Mes
>+_transport_+:
830 1 Tijmen de Mes
831 1 Tijmen de Mes
>The @MSRPTransport@ instance on which the chunk was sent.
832 1 Tijmen de Mes
  
833 1 Tijmen de Mes
>+_chunk_+:
834 1 Tijmen de Mes
835 1 Tijmen de Mes
>The actual chunk object.
836 1 Tijmen de Mes
837 1 Tijmen de Mes
*sent_chunk_data*(*data*, *transport*, *transaction_id*)
838 1 Tijmen de Mes
>This method is called when data is sent as part of a chunk previously announced via *sent_new_chunk*.
839 1 Tijmen de Mes
  
840 1 Tijmen de Mes
>+_data_+:
841 1 Tijmen de Mes
842 1 Tijmen de Mes
>The data sent as part of the chunk.
843 1 Tijmen de Mes
  
844 1 Tijmen de Mes
>+_transport_+:
845 1 Tijmen de Mes
846 1 Tijmen de Mes
>The @MSRPTransport@ instance on which the chunk was sent.
847 1 Tijmen de Mes
  
848 1 Tijmen de Mes
>+_transaction_id_+:
849 1 Tijmen de Mes
850 1 Tijmen de Mes
>The transaction ID which identifies the chunk for which data was sent.
851 1 Tijmen de Mes
852 1 Tijmen de Mes
*sent_chunk_end*(*data*, *transport*, *transaction_id*)
853 1 Tijmen de Mes
>This method is called when the last data of a chunk is sent. The chunk was previously announced via *sent_new_chunk*.
854 1 Tijmen de Mes
  
855 1 Tijmen de Mes
>+_data_+:
856 1 Tijmen de Mes
857 1 Tijmen de Mes
>The last data sent as part of the chunk.
858 1 Tijmen de Mes
  
859 1 Tijmen de Mes
>+_transport_+:
860 1 Tijmen de Mes
861 1 Tijmen de Mes
>The @MSRPTransport@ instance on which the chunk was sent.
862 1 Tijmen de Mes
  
863 1 Tijmen de Mes
>+_transaction_id_+:
864 1 Tijmen de Mes
865 1 Tijmen de Mes
>The transaction ID which identifies the chunk which was ended.
866 1 Tijmen de Mes
867 1 Tijmen de Mes
*debug*(*message*)
868 1 Tijmen de Mes
>This method is called when a debug level message is sent by the library.
869 1 Tijmen de Mes
870 1 Tijmen de Mes
*info*(*message*)
871 1 Tijmen de Mes
>This method is called when a info level message is sent by the library.
872 1 Tijmen de Mes
873 1 Tijmen de Mes
*warn*(*message*)
874 1 Tijmen de Mes
>This method is called when a warning level message is sent by the library.
875 1 Tijmen de Mes
876 1 Tijmen de Mes
*error*(*message*)
877 1 Tijmen de Mes
>This method is called when a error level message is sent by the library.
878 1 Tijmen de Mes
879 1 Tijmen de Mes
*fatal*(*message*)
880 1 Tijmen de Mes
>This method is called when a fatal level message is sent by the library.
881 1 Tijmen de Mes
882 1 Tijmen de Mes
883 1 Tijmen de Mes
h2. Examples
884 1 Tijmen de Mes
885 1 Tijmen de Mes
886 1 Tijmen de Mes
887 1 Tijmen de Mes
h3. Creating an outbound connection
888 1 Tijmen de Mes
889 1 Tijmen de Mes
890 1 Tijmen de Mes
When creating an outbound connection, a relay is not usually used because NAT traversal is not a problem for the endpoing creating the connection. If one is nevertheless desired, a @ConnectorRelay@ can be used instead:
891 1 Tijmen de Mes
892 1 Tijmen de Mes
<pre>
893 1 Tijmen de Mes
from msrplib.connect import ConnectorDirect
894 1 Tijmen de Mes
from msrplib.session import MSRPSession
895 1 Tijmen de Mes
896 1 Tijmen de Mes
connector = ConnectorDirect()
897 1 Tijmen de Mes
full_local_path = connector.prepare()
898 1 Tijmen de Mes
try:
899 1 Tijmen de Mes
    # put full_local_path in SDP 'a:path' attribute of offer
900 1 Tijmen de Mes
    # get full_remote_path from remote's 'a:path: attribute of reply
901 1 Tijmen de Mes
    msrp_transport = connector.complete(full_remote_path)
902 1 Tijmen de Mes
except:
903 1 Tijmen de Mes
    connector.cleanup()
904 1 Tijmen de Mes
    raise
905 1 Tijmen de Mes
906 1 Tijmen de Mes
def handle_incoming(chunk=None, error=None):
907 1 Tijmen de Mes
    if error is not None:
908 1 Tijmen de Mes
       print 'Error: %s' % error
909 1 Tijmen de Mes
       session.shutdown()
910 1 Tijmen de Mes
    elif chunk is not None:
911 1 Tijmen de Mes
       print 'Got data: %s' % chunk.data
912 1 Tijmen de Mes
913 1 Tijmen de Mes
session = MSRPSession(msrp_transport, on_incoming_cb=handle_incoming)
914 1 Tijmen de Mes
session.send_chunk(msrp_transport.make_chunk(data='Hello world!'))
915 1 Tijmen de Mes
</pre>
916 1 Tijmen de Mes
917 1 Tijmen de Mes
918 1 Tijmen de Mes
h3. Waiting for an inbound connection
919 1 Tijmen de Mes
920 1 Tijmen de Mes
921 1 Tijmen de Mes
When creating an inbound connection, a relay must be used for NAT traversal. However, if one is not desired, an @AceptorDirect@ can be used instead:
922 1 Tijmen de Mes
923 1 Tijmen de Mes
<pre>
924 1 Tijmen de Mes
from msrplib.connect import RelayConnection, MSRPRelaySettings
925 1 Tijmen de Mes
from msrplib.session import MSRPSession
926 1 Tijmen de Mes
927 1 Tijmen de Mes
relay = MSRPRelaySettings(domain='example.org', username='user', password='pass')
928 1 Tijmen de Mes
connector = RelayConnection(relay, 'passive')
929 1 Tijmen de Mes
full_local_path = connector.prepare()
930 1 Tijmen de Mes
try:
931 1 Tijmen de Mes
    # get full_remote_path from remote's 'a:path: attribute of offer
932 1 Tijmen de Mes
    # put full_local_path in SDP 'a:path' attribute of reply
933 1 Tijmen de Mes
    msrp_transport = connector.complete(full_remote_path)
934 1 Tijmen de Mes
except:
935 1 Tijmen de Mes
    connector.cleanup()
936 1 Tijmen de Mes
    raise
937 1 Tijmen de Mes
938 1 Tijmen de Mes
def handle_incoming(chunk=None, error=None):
939 1 Tijmen de Mes
    if error is not None:
940 1 Tijmen de Mes
       print 'Error: %s' % error
941 1 Tijmen de Mes
       session.shutdown()
942 1 Tijmen de Mes
    elif chunk is not None:
943 1 Tijmen de Mes
       print 'Got data: %s' % chunk.data
944 1 Tijmen de Mes
945 1 Tijmen de Mes
session = MSRPSession(msrp_transport, on_incoming_cb=handle_incoming)
946 1 Tijmen de Mes
session.send_chunk(msrp_transport.make_chunk(data='Hello world!'))
947 1 Tijmen de Mes
</pre>