public void Login(string username) { if (socket != null) { socket.Close(); } socket = IO.Socket("http://chat.socket.io/"); socket.Connect(); var alert = new AlertDialog.Builder(this).SetMessage("Logging in...").Show(); var chat = new ChatFragment(username, socket, alert); FragmentManager.BeginTransaction() .Replace(Resource.Id.frameLayout, chat) .Commit(); // Tell the server your username (login) socket.Emit("add user", username); }