background image
C H A P T E R 2 2
Transport Interface
22-14
Using the Transport Interface
for the item. This allows the transport an opportunity to add its own slots to the
item frame.
Most transports will want to add a
fromRef
slot to the item frame. This slot must
contain a name reference that identifies the sender. This information is usually
extracted from the sender's current owner card, or persona. You shouldn't just use
the value of
GetUserConfig('currentPersona)
because it is simply an alias
to a names file entry. Instead, construct a name reference from this value. For example:
persona := GetUserConfig('currentPersona);
dataDef := GetDataDefs(addressingClass);
fromRef := dataDef:MakeNameRef(persona,addressingClass);
Most transports will want to extract and send only the needed information from the
fromRef
name reference. For example, an e-mail transport would typically just
extract the sender name and e-mail address from the name reference and send them
as strings. One method of name reference data definitions that you can use to
extract useful information from a name card includes
GetRoutingInfo
. Here is
an example of using this method:
// extract just routing info using GetRoutingInfo
routeInfo:= datadef:GetRoutingInfo(fromRef);
// returns an array like this:
[{name: "Chris Smith", email: "cbsmith@apple.test.com"}]
The
GetRoutingInfo
method returns an array of at least one frame that has at
least a
name
slot containing a string. Depending on the
addressingClass
slot
passed to the
GetDataDefs
function, the returned frame also contains other
information particular to the type of address used for the transport. In the example
above, the frame also contains an
email
slot with an e-mail address.
If you want to add other slots to the
fromRef
frame, you can either define your
own name reference data definition and override the method
GetItemRoutingFrame
(called by
GetRoutingInfo
), or add the slots you
want to the
fromRef
frame by extracting them from the original name reference
with the
Get
method. For example:
// use Get to extract info from certain slots
fromRef.myInfo := dataDef:Get(fromRef,'myInfo,nil);
Note that a sender may have multiple e-mail addresses and the transport should set
the e-mail address in the
fromRef
frame to the one that is appropriate to itself. For
example, for an internet e-mail transport, you would typically set the
fromRef
© 2007-2017, o7 studio » при воспроизведении материала сайта ссылка обязательна