Hello, I am unable to find examples where the login response has been decoded to check if login was successful or not. Can you help me with sample code or examples for the EMA Java SDK for the above use case?
Hello @Souradeep
Please refer to the EMA Java example ex333_Login_Streaming_DomainRep.
An application can register to the Login stream.
LoginReq loginReq = EmaFactory.Domain.createLoginReq(); consumer.registerClient(loginReq.message(), appClient);
Then an OmmConsumerClient implemented class can check incoming Refresh Message state object on the OnRefreshMsg() callback method.
public void onRefreshMsg(RefreshMsg refreshMsg, OmmConsumerEvent event){ ... // Print entire State object() System.out.println("Item State: " + refreshMsg.state()); if (refreshMsg.domainType() == EmaRdm.MMT_LOGIN){ .... //Check each state object attribute System.out.printf("Login: Stream State code: %d, Stream State text: %s%n", refreshMsg.state().streamState(), refreshMsg.state().streamStateAsString()); System.out.printf("Login: Data State code: %d, Data State text: %s%n", refreshMsg.state().dataState() ,refreshMsg.state().dataStateAsString()); System.out.printf("Login: Status Text: %s%n", refreshMsg.state().statusText()); } }
Example result:
Received Refresh. Item Handle: 1 Closure: null Item Name: user Service Name: <not set> Item State: Open / Ok / None / 'Login accepted by host efe37da22273.'.... Login: Stream State code: 1, Stream State text: Open Login: Data State code: 1, Data State text: Ok Login: Status Text: Login accepted by host efe37da22273.
Received Refresh. Item Handle: 1 Closure: null Item Name: user Service Name: <not set> Item State: Open / Ok / None / 'Login accepted by host efe37da22273.'
.... Login: Stream State code: 1, Stream State text: Open Login: Data State code: 1, Data State text: Ok Login: Status Text: Login accepted by host efe37da22273.