/** Websocketを開く. */ private void openWebsocket() { boolean isSSL = isSSL(); String host = getHost(); int port = getPort(); String sessionKey = getClientId(); if (sessionKey == null) { Toast.makeText(DConnectActivity.this, "Client is not created.", Toast.LENGTH_LONG).show(); return; } boolean result = HttpEventManager.INSTANCE.connect( host, port, isSSL, sessionKey, new CloseHandler() { @Override public void onClosed() { runOnUiThread( new Runnable() { @Override public void run() { Toast.makeText(DConnectActivity.this, "Websocket Close.", Toast.LENGTH_LONG) .show(); } }); } }); if (result) { Toast.makeText(DConnectActivity.this, "Websocket open.", Toast.LENGTH_LONG).show(); } else { Toast.makeText(DConnectActivity.this, "Failed to open websocket.", Toast.LENGTH_LONG).show(); } }
@Override protected void onCreate(final Bundle savedInstanceState) { if (BuildConfig.DEBUG) { AndroidHandler handler = new AndroidHandler("deviceconnect.uiapp"); handler.setFormatter(new SimpleFormatter()); handler.setLevel(Level.ALL); mLogger.addHandler(handler); mLogger.setLevel(Level.ALL); } else { mLogger.setLevel(Level.OFF); } mLogger.entering(getClass().getName(), "onCreate", savedInstanceState); super.onCreate(savedInstanceState); mDConnectClient = new HttpDConnectClient(); HttpEventManager.INSTANCE.setOrigin(getPackageName()); (new ServiceDiscoveryTask()).execute(); mLogger.exiting(getClass().getName(), "onCreate"); }