Establishing session
This section introduces how to establish a session using the UNICOM® Digital Transformation Toolkit (UDTT™) Mobile Channel.
See
See also
Establishing session in the client side
After the configuration, you need to invoke the establishSession method to establish the session with the UNICOM® Digital Transformation Toolkit (UDTT™) server. It returns true if the session is successfully established with the server. Following is the code example:
if (adapter==null){ adapter=new MobileAdapter(); if (adapter.establishSession()==false){ System.out.println("Establish session failed!"); adapter=null; } }
See also
Establishing session in the server side
To establish session in the server side, perform the following steps:
1 Define startup operation CreateSessionOpStep , which is defined in btt.xml:
<?xml version="1.0" encoding="UTF-8"?> <CreateSessionOpStep.xml> <operation id="CreateSessionOperation" context="myContext" implClass="com.ibm.btt.mobile. operation.CreateSessionOperation"></operation> <kColl id="myCtxData"> <field id="test" /> </kColl> <context id="myContext" type="op"> <refKColl refId="myCtxData" /> </context> </CreateSessionOpStep.xml>
2 Implement startup operation CreateSessionOpStep :
package com.ibm.btt.mobile.operation; import java.io.ObjectOutput; import java.util.Enumeration; import com.ibm.btt.base.BTTServerOperation; import com.ibm.btt.base.Context; import com.ibm.btt.base.ContextFactory; import com.ibm.btt.http.WebChannelContext; @SuppressWarnings("serial") public class CreateSessionOperation extends BTTServerOperation { @Override public void execute() throws Exception { Context root = ContextFactory.getRoot(); if (root == null) { System.out.println("Creating root ctx"); root = ContextFactory.createContext("branchServer", false); } Context sessionCtx = ContextFactory.createContext("sessionCtx", false); sessionCtx.setValueAt("sessionID", WebChannelContext.getChannelSession().getId()); sessionCtx.chainTo(root); Context ctx = getContext(); ctx.chainTo(sessionCtx); } }
See also
This site works best with JavaScript enabled