Package beepy :: Package core :: Module channel :: Class Channel
[show private | hide private]
[frames | no frames]

Class Channel


A Channel object is an abstraction of a BEEP channel running over some form of transport.
Method Summary
  __init__(self, channelnum, profile, session)
  allocateLocalAnsno(self, msgno)
Similar to allocateMsgno(), allocates a local ansno for a given msgno.
  allocateLocalSeqno(self, msgsize)
Identical to allocateRemoteSeqno() only used for the local side of a Channel connection.
  allocateMsgno(self)
allocateMsgno() allocates a unique msgno for a message by checking a list of allocated msgnos and picking the lowest number not already allocated.
  allocateRemoteSeqno(self, msgsize)
Allocate the next sequence number for the remote side of a channel connection.
  close(self)
close() attempts to close the Channel.
  deallocateMsgno(self, msgno)
deallocateMsgno() deallocates a previously allocated msgno.
  isMessageOutstanding(self, msgno)
isMessageOutstanding() checks to see if a particular message that was previously sent has been acknowledged.
  processFrame(self, theframe)
Called by a Session when it receives a frame on this Channel to process the frame.
  send(self, msg)
Used to send a frame over this channel.
  sendAnswer(self, msgno, data)
sendAnswer() is used for sending a frame of type ANS
  sendError(self, msgno, data)
sendError() is used for sending a frame of type ERR
  sendGreetingReply(self, data)
sendGreetingReply() is used to send the initial greeting message when a peer connects.
  sendMessage(self, data, cb, errback)
sendMessage() is used for sending a Message of type MSG
  sendNul(self, msgno)
sendNul() is used for sending a frame of type NUL
  sendReply(self, msgno, data, cb, errback, *args)
sendReply() is used for sending a frame of type RPY
  setPriority(self, priority)
Set the priority level of this channel to priority.
  validateFrame(self, theframe)
Performs sanity checking on an inbound Frame before it is passed to a profile for processing.

Class Variable Summary
int channelnum = -1                                                                    
long localSeqno = -1L
NoneType profile = None                                                                  
long remoteSeqno = -1L

Method Details

__init__(self, channelnum, profile, session)
(Constructor)

Parameters:
channelnum - The number to assign to this Channel object
           (type=integer)
profile - The Profile object to bind to this channel
           (type=Profile)
session - The Session object this Channel belongs to
           (type=Session)
Raises:
ChannelException - when the channel number is out of bounds.

allocateLocalAnsno(self, msgno)

Similar to allocateMsgno(), allocates a local ansno for a given msgno.

Wraps to MIN_ANSNO at MAX_ANSNO.
Parameters:
msgno - the msgno to associate with the ansno
           (type=integer)
Returns:
integer, The allocated ansno

allocateLocalSeqno(self, msgsize)

Identical to allocateRemoteSeqno() only used for the local side of a Channel connection.

Wraps to zero at MAX_SEQNO.
Parameters:
msgsize - the size of the message this seqno is for
           (type=integer)
Returns:
an integer sequence number for the message

allocateMsgno(self)

allocateMsgno() allocates a unique msgno for a message by checking a list of allocated msgnos and picking the lowest number not already allocated. Allocated msgnos should be removed from the list when the complete reply to the message is received. See deallocateMsgno().
Raises:
ChannelException - if no more msgnos can be allocated for this channel. This shouldn't ever happen, but if it does, messages are not being acknowledged by the remote peer. Alternately, the transport layer may be experiencing delays.

allocateRemoteSeqno(self, msgsize)

Allocate the next sequence number for the remote side of a channel connection.

Wraps to zero at MAX_SEQNO.
Parameters:
msgsize - the size of the message this seqno is for
           (type=integer)
Returns:
an integer sequence number for the message

close(self)

close() attempts to close the Channel.

A Channel is not supposed to close unless all messages sent on the channel have been acknowledged and any messages inbound have been completely received.
Raises:
ChannelMessagesOutstanding - if not all sent messages have been acknowledged.

deallocateMsgno(self, msgno)

deallocateMsgno() deallocates a previously allocated msgno. This should be called when a complete reply to a message is received and processed. This is most likely to be used from within a profile to signify that the message has been completely dealt with.
Parameters:
msgno - the msgno of a received message reply.
           (type=integer)

isMessageOutstanding(self, msgno=None)

isMessageOutstanding() checks to see if a particular message that was previously sent has been acknowledged. If no msgno is supplies, checks to see if there are any outstanding messages on this channel.
Parameters:
msgno - msgno to check
           (type=integer)

processFrame(self, theframe)

Called by a Session when it receives a frame on this Channel to process the frame.
Parameters:
theframe - the DataFrame to process
           (type=DataFrame)

send(self, msg)

Used to send a frame over this channel. Predominantly used by the Profile bound to this channel to send messages. send() passes the Message to the Session and its associated transport layer.

If messages are sent asynchronously (such as with fragmentation) then you should use the callback as a way to signify that the call finished.
Parameters:
msg - the DataFrame to send
           (type=a DataFrame object)

sendAnswer(self, msgno, data)

sendAnswer() is used for sending a frame of type ANS
Parameters:
msgno - the msgno this ANS is in reply to
data - the payload of the ANS frame

sendError(self, msgno, data)

sendError() is used for sending a frame of type ERR
Parameters:
msgno - the msgno this error is raised in reply to
data - the payload of the ERR frame

sendGreetingReply(self, data)

sendGreetingReply() is used to send the initial greeting message when a peer connects. It is identical to sendReply except that it doesn't check for a received Msgno as there isn't one. The msgno for this message is set to 0 as this must be the first frame sent.
Parameters:
data - the greeting frame payload

sendMessage(self, data, cb=None, errback=None)

sendMessage() is used for sending a Message of type MSG
Parameters:
data - the payload of the message
Returns:
integer, the msgno of the message that was sent

sendNul(self, msgno)

sendNul() is used for sending a frame of type NUL

NUL frames are used to finish a series of ANS frames in response to a MSG. The msgno here is the msgno of the message to which the previous ANS frames were an answer to.
Parameters:
msgno - the msgno all previous ANS frames have been in response to, and to which this is the final response frame.

sendReply(self, msgno, data, cb=None, errback=None, *args)

sendReply() is used for sending a frame of type RPY

The msgno here is the msgno of the message to which this is a reply.
Parameters:
msgno - The msgno for which this is the reply.
           (type=integer)
data - The RPY payload

setPriority(self, priority)

Set the priority level of this channel to priority. priority must be between -10 and 10.

validateFrame(self, theframe)

Performs sanity checking on an inbound Frame before it is passed to a profile for processing.
Parameters:
theframe - the DataFrame to validate
           (type=DataFrame)
Raises:
ChannelStateException - if Channel is not active
ChannelOutOfSequence - if frame seqno is not expected value
ChannelException - if frametype is incorrect
ChannelException - if frame msgno is not expected value
ChannelMsgnoInvalid - if frame msgno is invalid

Class Variable Details

channelnum

Type:
int
Value:
-1                                                                    

localSeqno

Type:
long
Value:
-1L                                                                    

profile

Type:
NoneType
Value:
None                                                                  

remoteSeqno

Type:
long
Value:
-1L                                                                    

Generated by Epydoc 2.0 on Thu Sep 30 14:39:26 2004 http://epydoc.sf.net