Skip navigation links
Oracle® Communications WebRTC Session Controller Android API Reference
E69507-03
7.2.0.1.2

Package oracle.wsc.android.session

Session API.

See: Description

Package oracle.wsc.android.session Description

Session API.

To create a session and listen for session state changes:

 

 void loginToWSC() throws URISyntaxException {
   final String username = "alice@example.com";
   final String webSocketURL = "ws://server:port/ws/webrtc/someapp";

   // Add more parameters to builder if required.
   final HttpContext httpContext = HttpContext.Builder.create().build();

   WSCSession.Builder builder = WSCSession.Builder.create(new URI(webSocketURL))
             .withConnectionCallback(new MyConnectionHandler())
             .withUserName(username)
             .withObserver(new MySessionObserver())
             .withPackage(new CallPackage())
             .withHttpContext(httpContext)
             .withIceServerConfig(new MyIceServerConfig());

   // Create the session.
   WSCSession session = builder.build();

 }

 // Handle connection status for the session.
 class MyConnectionHandler implements ConnectionCallback {

   public void onSuccess() {
     // update UI components if any
   }

   public void onFailure(StatusCode code) {
     // display error
   }

 }

 // Pass the configuration of ICE Server(s)...
 class MyIceServerConfig implements IceServerConfig {
    public Set<IceServer> getIceServers() {
       Set<IceServerConfig.IceServer> iceServers = new HashSet<IceServerConfig.IceServer>();
       //  iceServers.add(...);
       return iceServers;
    }
 }

 // Listener for changes in session state.
 class MySessionObserver extends WSCSession.Observer {

   public void stateChanged(final SessionState state) {
     runOnUiThread(new Runnable() {

       public void run() {
         switch (state) {
           case CONNECTED:
             // session is connected, update UI to reflect the change.
             break;
           case FAILED:
             // session is reconnecting, update UI to reflect change and possibly re-login.
             break;
           // handle other cases
         }
       }
     });
   }
 }

 
Skip navigation links
Oracle® Communications WebRTC Session Controller Android API Reference
E69507-03
7.2.0.1.2

Copyright © 2013, 2017, Oracle and/or its affiliates. All rights reserved.