Project

General

Profile

SipMSRPApi » History » Version 4

Oliver Bril, 03/31/2009 11:42 AM

1 1 Adrian Georgescu
= MSRP API =
2
3
[[TOC(WikiStart, Sip*, depth=3)]]
4
5
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). 
6
7
 * MSRP sessions are defined in [http://tools.ietf.org/html/rfc4975 RFC 4975].
8
 * MSRP relay extension used for NAT traversal of instant messaging and file transfer sessions is defined in [http://tools.ietf.org/html/rfc4976 RFC 4976].
9
10 4 Oliver Bril
The MSRP protocol is implemented by [http://devel.ag-projects.com/cgi-bin/darcsweb.cgi?r=python-msrplib;a=summary msrplib] Python package. On top {{{sipsimple}}} provides
11
higher level classes integrated into middleware notification and configuration systems:
12 1 Adrian Georgescu
13 4 Oliver Bril
 * {{{sipsimple.msrp.MSRPChat}}}
14
 * {{{sipsimple.msrp.MSRPFileTransfer}}}
15
 * {{{sipsimple.msrp.MSRPDesktopSharing}}}
16 1 Adrian Georgescu
17 4 Oliver Bril
== MSRPChat ==
18
19
{{{sipsimple.msrp.MSRPChat}}} 
20
21
== MSRPFileTransfer ==
22
23
== MSRPDesktopSharing ==
24
25
== msrplib ==
26
27
=== Architecture ===
28
29 1 Adrian Georgescu
{{{msrplib}}} is based upon [http://twistedmatrix.com twisted] and [http://devel.ag-projects.com/~denis/eventlet/ eventlet] and provides a set of
30
classes for establishing and managing MSRP connection.
31
32
The library consist of the following modules:
33
34
 '''msrplib.transport'''::
35
 Defines {{{MSRPTransport}}} class, which provides low level control over MSRP connection.
36 2 Redmine Admin
37 1 Adrian Georgescu
 '''msrplib.connect'''::
38
 Defines means to establish a connection, bind it, and provide an initialized {{{MSRPTransport}}} instance.
39
40
 '''msrplib.session'''::
41
 Defines {{{MSRPSession}}} class, which provides high level control over a MSRP connection.
42
43
 '''msrplib.protocol'''::
44
 Provides representation and parsing of MSRP entities - chunks and URIs.
45
46
 '''msrplib.trafficlog'''::
47
 Defines {{{Logger}}} class that is used through out the library to log the connection state.
48
  
49 4 Oliver Bril
=== Usage ===
50 1 Adrian Georgescu
51 4 Oliver Bril
==== Establish a connection ====
52 3 Oliver Bril
53 1 Adrian Georgescu
{{{msrplib.connect}}} provides a number of classes to establish a connection, so the first
54
thing to do is to select which one applies to your situation:
55
56
    1. Calling endpoint, not using a relay ({{{ConnectorDirect}}})
57
    2. Answering endpoint, not using a relay ({{{AcceptorDirect}}})
58
    3. Calling endpoint, using a relay ({{{ConnectorRelay}}})
59
    4. Answering endpoint, using a relay ({{{AcceptorRelay}}})
60
61
The answering endpoint may skip using the relay if sure that it's accessible
62
directly. The calling endpoint is unlikely to need the relay.
63
64
Once you have an instance of the right class (use the convenience functions
65
{{{get_connector()}}} and {{{get_acceptor()}}} to get one), the procedure to establish the
66
connection is the same:
67
68
{{{
69
full_local_path = connector.prepare()
70
try:
71
    ... put full_local_path in SDP 'a:path' attribute
72
    ... get full_remote_path from remote's 'a:path: attribute
73
    ... (the order of the above steps is reversed if you're the
74
    ... answering party, but that does not affect connector's usage)
75
    msrptransport = connector.complete(full_remote_path)
76
finally:
77
    connector.cleanup()
78
}}}
79
80
To customize connection's parameters, create a new {{{protocol.URI}}} object and pass
81
it to prepare() function, e.g.
82
{{{
83
local_uri = protocol.URI(use_tls=False, port=5000)
84
connector.prepare(local_uri)
85
}}}
86
87
{{{prepare()}}} may update {{{local_uri}}} in place with the actual connection parameters
88
used (e.g. if you specified port=0). 'port' attribute of {{{local_uri}}} is currently
89
only respected by {{{AcceptorDirect}}}.
90
91
Note that, acceptors and connectors are one-use only. Which means, that {{{AcceptorDirect}}}
92
will open a port just to handle one incoming connection and close it right after.
93
If your application behaves more like a server, i.e. opens a port and listens on it
94
constantly, use {{{MSRPServer}}} class.
95 3 Oliver Bril
96 4 Oliver Bril
=== Components ===
97 1 Adrian Georgescu
98 4 Oliver Bril
==== a connector or acceptor ====
99 3 Oliver Bril
100 4 Oliver Bril
===== attributes =====
101
===== methods =====
102 1 Adrian Georgescu
103 4 Oliver Bril
==== transport.MSRPTransport ====
104 1 Adrian Georgescu
105
Low level access to MSRP connection.
106
107 4 Oliver Bril
===== attributes =====
108 3 Oliver Bril
109 4 Oliver Bril
===== methods =====
110 3 Oliver Bril
111
 '''make_chunk'''(''self'', ''transaction_id''={{{None}}}, ''method''={{{'SEND'}}}, ''code''={{{None}}}, ''comment''={{{None}}}, ''data''={{{''}}}, ''contflag''={{{None}}}, ''start''={{{1}}}, ''end''={{{None}}}, ''length''={{{None}}}, ''message_id''={{{None}}})::
112 1 Adrian Georgescu
 Make a new chunk ({{{protocol.MSRPData}}} instance) with proper {{{From-Path}}}, {{{To-Path}}}, {{{Byte-Range}}} and {{{Message-ID}}} headers set up based on MSRPTransport's state and the parameters provided. Use ''data'' for payload, and ''start''/''end''/''length'' to generate {{{Byte-Range}}} header. Generate new random strings for default values of ''transaction_id'' and ''message_id''. 
113
 [[BR]]''contflag'':[[BR]]
114
 MSRP chunk's continuation flag ({{{'$'}}}, {{{'+'}}} or {{{'#'}}}). Default is {{{'$'}}}, unless you have a partial {{{SEND}}} chunk, in which case it is {{{'+'}}}
115
116 4 Oliver Bril
==== session.MSRPSession ====
117
===== attributes =====
118
===== methods =====
119 1 Adrian Georgescu
120 4 Oliver Bril
==== connect.MSRPServer ====
121
===== attributes =====
122
===== methods =====