Android with node.js server

package com.github.nkzawa.socketio.androidchat;

import android.content.Intent;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import com.github.nkzawa.emitter.Emitter;
import com.github.nkzawa.socketio.client.IO;
import com.github.nkzawa.socketio.client.Socket;

import org.json.JSONException;
import org.json.JSONObject;

import java.net.URISyntaxException;

public class GameActivity extends ActionBarActivity{

private Socket mSocket;
{
try {
mSocket = IO.socket(“http://6trix.com:8598/”);
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
}

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_game);
mSocket.connect();
mSocket.emit(“adduser”, “uspmca”);
mSocket.on(“existingUserOnTable”, SetUserInfo);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_game, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();

//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}

return super.onOptionsItemSelected(item);
}

private Emitter.Listener SetUserInfo = new Emitter.Listener() {
@Override
public void call(Object… args) {
// JSONObject data = (JSONObject) args[0];

Log.i(“Existing Users”,”Yes Uma”);
}
};

}

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *