Revision history [back]

click to hide/show revision 1
initial version

Some background: The bind API(BusAttachment::BindSessionPort) is used by a host application to bind a port that will be used by joiners while making the BusAttachment::JoinSession method call. The host application MUST call BindSessionPort if it wants joiners to be able to join a session to it.

SessionMap maps a std::pair of qcc::String and SessionId to a SessionMapEntry. For simplicity, lets call the qcc::String as "name".

Entries are added into the sessionMap in the following circumstances:

  1. AllJoynObj::BindSessionPort(AllJoynObj.cc:433): This is called when an AllJoyn service calls BusAttachment::BindSessionPort. The code (while loop in AllJoynObj.cc:415) checks to see if the caller has already called BindSessionPort with the same port, and returns an ALLJOYN_BINDSESSIONPORT_REPLY_ALREADY_EXISTS error in that case. If not, a sessionMap entry is created with the name as the caller to BindSessionPort and sessionId as 0.
  2. AllJoynObj::JoinSessionThread::RunJoin(AllJoynObj.cc:664): This adds a creator side entry since the creator is also locally connected to the Routing Node(RN). i.e. in this case the session creator and session joiner are connected to the same RN. Entry is added with name of the creator and the newly allocated sessionId.
  3. AllJoynObj::JoinSessionThread::RunJoin(AllJoynObj.cc:719): This adds a joiner side entry to the sessionMap for a session created with SessionOpts::TRAFFIC_MESSAGES. In this case the session creator and session joiner are connected to the same RN.Entry is added with name of the joiner and the newly allocated sessionId.
  4. AllJoynObj::JoinSessionThread::RunJoin(AllJoynObj.cc:742): This adds a joiner side entry to the sessionMap for a raw session.In this case the session creator and session joiner are connected to the same RN. Entry is added with name of the joiner and the newly allocated sessionId.
  5. AllJoynObj::JoinSessionThread::RunJoin(AllJoynObj.cc:980): This adds a joiner side entry to the sessionMap for a raw session.In this case the session creator and session joiner are connected to the different RNs. Entry is added with name of the creator and the sessionId obtained from the creator by calling the ajObj.SendAttachSession method Call on line AllJoynObj.cc:930.
  6. AllJoynObj::JoinSessionThread::RunAttach(AllJoynObj.cc:1589): This adds a creator side entry in the case that the session creator and session joiner are connected to the different RNs. Entry is added with name of the creator and the newly allocated sessionId.

Coming back to your questions:

  1. what String means in the above code line, dose it stand for the joiner's name ? and what's the meaning of the data stored in the sessionMap ? Please find answers to this above.

  2. why dose the code to check if a creator of a session is joining itself check the sessionid == 0 ? what means if the sessionid == 0 in the sessionMap ? I believe that the case you are talking about is in the while loop AllJoynObj.cc:612. In this case, since the creator is also local to the RN, the RN is verifying that the creator has called BindSessionPort with the specified sessionport.

  3. why dose add two entries when join a session ?(creator side entry and joiner side entry), and what are the functions of the two entries ?</pair<string,&gt;>The creator side entry is added in RunJoin ONLY when the creator is also local to the RN(If condition if (rSessionEp->IsValid()) line AllJoynObj.cc:603).

Hope this helps