Skip to content

Low level API access

Pallab edited this page Mar 8, 2021 · 1 revision

The SDK exposes the low-level communication interface with the method getSession() in the NinchatSession class. The host app may use this object to communicate to the server, bypassing the SDK logic.

Furthermore, the host application can register itself (or its property/properties) as a listener to the low-level API events and/or logs by creating the NinchatSession instance with the listeners as constructor arguments:

Following constructors deprecated in 0.6.0

session = new NinchatSession(applicationContext, configurationKey, sessionCredentials, eventListener);
session = new NinchatSession(applicationContext, configurationKey, sessionCredentials, preferredEnvironments, eventListener);
session = new NinchatSession(applicationContext, configurationKey, sessionCredentials, logListener);
session = new NinchatSession(applicationContext, configurationKey, sessionCredentials, preferredEnvironments, logListener);
session = new NinchatSession(applicationContext, configurationKey, sessionCredentials, eventListener, logListener);
session = new NinchatSession(applicationContext, configurationKey, sessionCredentials, preferredEnvironments, eventListener, logListener);
session = new NinchatSession(applicationContext, configurationKey, sessionCredentials, ninchatConfiguration);
session = new NinchatSession(applicationContext, configurationKey, sessionCredentials, ninchatConfiguration, preferredEnvironments);
session = new NinchatSession(applicationContext, configurationKey, sessionCredentials, ninchatConfiguration, eventListener);
session = new NinchatSession(applicationContext, configurationKey, sessionCredentials, ninchatConfiguration, logListener);
session = new NinchatSession(applicationContext, configurationKey, sessionCredentials, ninchatConfiguration, preferredEnvironments, eventListener);
session = new NinchatSession(applicationContext, configurationKey, sessionCredentials, ninchatConfiguration, preferredEnvironments, logListener);
session = new NinchatSession(applicationContext, configurationKey, sessionCredentials, ninchatConfiguration, eventListener, logListener);
session = new NinchatSession(applicationContext, configurationKey, sessionCredentials, ninchatConfiguration, preferredEnvironments, eventListener, logListener);

The argument eventListener, when non-null, must be an instance of the NinchatSDKEventListener class, the logListener an instance of the NinchatSDKLogListenerinterface, and ninchatConfiguration is an instance of NinchatConfiguration class.

As of version 0.5.0 sessionCredentials can be added to open up a previous session. Passing null will open a new session. Passing invalid/outdated sessionCredentials will cause onSessionInitFailed to be invoked.

As of version 0.6.0 aforementioned NinchatSession constructors are deprecated and a builder pattern has been introduced. NinchatSession object needs to be initialized the following way:

NinchatSession.Builder builder = new NinchatSession.Builder(applicationContext, configurationKey);
builder.setSessionCredentials(sessionCredentials); // optional
builder.setConfiguration(ninchatConfiguration); // optional
builder.setPreferredEnvironments(preferredEnvironments); // optional
builder.setEventListener(eventListener); // optional
builder.setLogListener(logListener); // optional
NinchatSession session = builder.create();

See Ninchat API Reference for information about the API's outbound Actions and inbound Events.

Clone this wiki locally