]> git.evergreen-ils.org Git - OpenSRF.git/blob - src/javascript/opensrf_transport.js
added connect/disconnect support, with onconnect callback
[OpenSRF.git] / src / javascript / opensrf_transport.js
1 /** @file oils_transport.js
2   * Houses the top level transport 'abstract' classes
3   * You can think of this like a header file which provides the 
4   * interface that any transport code must implement
5   */
6
7
8 // ------------------------------------------------------------------
9 // TRANSPORT_CONNECTION
10
11 /** Constructor */
12 function transport_connection( username, password, resource ) { }
13
14 /** Connects to the transport host */
15 transport_connection.prototype.connect = function(  host, /*int*/ port, /*int*/ timeout ) {}
16
17 /** Sends a new message to recipient, with session_id and body */
18 transport_connection.prototype.send = function( recipient, session_id, body ) {}
19
20
21 /** Returns a transport_message.  This function will return 
22   * immediately if there is a message available.  Otherwise, it will
23   * wait at most 'timeout' seconds for one to arrive.  Returns
24   * null if a message does not arrivae in time.
25
26   * 'timeout' is specified in milliseconds
27   */
28 transport_connection.prototype.recv = function( /*int*/ timeout ) {}
29
30 /** This method calls recv and then passes the contents on to the
31   * message processing stack.
32   */
33 transport_connection.prototype.process_msg = function( /*int*/ timeout ) {
34         var msg = this.recv( timeout );
35         if( msg ) { Transport.handler( msg ); }
36 }
37
38 /** Disconnects from the transpot host */
39 transport_connection.prototype.disconnect = function() {}
40
41 /** Returns true if this connection instance is currently connected
42   * to the transport host.
43   */
44 transport_connection.prototype.connected = function() {}
45
46
47
48 // ------------------------------------------------------------------
49 // TRANSPORT_MESSAGE
50         
51
52 /** Constructor */
53 function transport_message( sender, recipient, session_id, body ) {}
54
55 /** Returns the sender of the message */
56 transport_message.prototype.get_sender = function() {}
57
58 /** Returns the session id */
59 transport_message.prototype.get_session = function() {}
60
61 /** Returns the message body */
62 transport_message.prototype.get_body = function() {}
63         
64