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