public boolean isConnected() {
   if (subspace != null) {
     return subspace.isConnected();
   } else {
     return false;
   }
 }
  @Override
  public void onDestroy() {

    // disconnect if we are connected
    if (subspace.isConnected()) {
      try {
        subspace.SSDisconnect();
      } catch (IOException ioe) {
        Log.e(TAG, Log.getStackTraceString(ioe));
      }
    }

    notification.cancel();

    // Tell the user we stopped.
    Toast.makeText(this, R.string.network_service_stopped, Toast.LENGTH_SHORT).show();
  }
 public LoginResponse Login(boolean isNewUser, String username, String password) {
   try {
     return subspace.Login(isNewUser, username, password);
   } catch (IOException e) {
     // TODO Auto-generated catch block
     Log.e(TAG, Log.getStackTraceString(e));
     return null;
   }
 }
  public void Connect(final String zoneName, final String ipAddress, final int port) {
    if (subspace != null && subspace.isConnected()) {
      new Thread(
              new Runnable() {
                public void run() {
                  try {
                    subspace.SSDisconnect();
                  } catch (IOException e) {
                    Log.e(TAG, Log.getStackTraceString(e));
                  }
                }
              })
          .start();
    }
    // create subspace object
    subspace = new NetworkGame(getApplicationContext(), zoneName);

    if (_networkThread == null || !_networkThread.isAlive()) {
      final Context context = this;
      new Thread(
              new Runnable() {
                public void run() {
                  SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
                  boolean logConnection = prefs.getBoolean("pref_logConnection", true);
                  boolean logCorePackets = prefs.getBoolean("pref_logCorePackets", true);
                  boolean logGamePackets = prefs.getBoolean("pref_logGamePackets", true);

                  try {

                    // setup logging as set in settings
                    NetworkGame.LOG_CONNECTION = logConnection;
                    NetworkGame.LOG_CORE_PACKETS = logCorePackets;
                    NetworkGame.LOG_GAME_PACKETS = logGamePackets;

                    // temp local test
                    subspace.SSConnect("ssmobile.subspace2.net", 2000);

                    // subspace.SSConnect(ipAddress,port);

                    // change notify we are connected
                    notification.connected(zoneName);
                  } catch (Exception e) {
                    Log.e(TAG, Log.getStackTraceString(e));
                  }
                }
              })
          .start();
    }
  }
 public Arena getArena() {
   return subspace.getArena();
 }
 public void setGameCallback(IGameCallback callback) {
   subspace.setGameCallback(callback);
 }
 public void setDownloadCallback(ISubspaceCallback callback) {
   subspace.setDownloadCallback(callback);
 }
 public void SendChat(String message) {
   subspace.SendChat(message);
 }
 public void EnterArena(String name) {
   subspace.EnterArena(name);
 }