protected override void OnCreate(Bundle bundle)
		{
			base.OnCreate(bundle);

            LogManager.LogFactory = new GenericLogFactory(Console.WriteLine);

			// Set our view from the "main" layout resource
			SetContentView(Resource.Layout.Main);
			// Get our button from the layout resource,
			// and attach an event to it
			Button sendButton = FindViewById<Button>(Resource.Id.sendMessageButton);
			messageBox = FindViewById<EditText>(Resource.Id.message);
			SupportToolbar mToolbar = FindViewById<SupportToolbar>(Resource.Id.toolbar);
			mDrawerLayout = FindViewById<DrawerLayout>(Resource.Id.drawer_layout);
			navigationView = FindViewById<NavigationView>(Resource.Id.nav_view);
			mRightDrawer = FindViewById<ListView>(Resource.Id.right_drawer);
			var messageHistoryList = FindViewById<ListView>(Resource.Id.messageHistory);
            var chatBackground = FindViewById<ImageView>(Resource.Id.chat_background);
            InitDefaultBackground(chatBackground);

            navigationView.Tag = 0;
			mRightDrawer.Tag = 1;

			var messageHistoryAdapter = new MessageListViewAdapter(this, new List<ChatMessage>(), () => this.subscriberList);
			messageHistoryList.Adapter = messageHistoryAdapter;

		    var txtUser = FindViewById<TextView>(Resource.Id.txtUserName);
		    var imgProfile = FindViewById<ImageView>(Resource.Id.imgProfile);
		    var channels = new[] {"home"};
			cmdReceiver = new ChatCommandHandler (this, messageHistoryAdapter, "home");

		    client = new ServerEventsClient(BaseUrl, channels)
		    {
		        OnConnect = connectMsg =>
		        {
		            client.UpdateChatHistory(cmdReceiver).ConfigureAwait(false);
		            connectMsg.UpdateUserProfile(txtUser, imgProfile);
		        },
                OnCommand = command =>
                {
                    if (command is ServerEventJoin)
                    {
						client.GetSubscribers().ContinueWith(result => {
							result.Wait();
                            subscriberList = result.Result;
                            Application.SynchronizationContext.Post(_ =>
                            {
                                // Refresh profile icons when users join
                                messageHistoryAdapter.NotifyDataSetChanged();
                            }, null);
						});
                    }  
                },
		        OnException =
		            error =>
		            {
		                Application.SynchronizationContext.Post(
		                    _ => { Toast.MakeText(this, "Error : " + error.Message, ToastLength.Long); }, null);
		            },
		        //ServiceClient = new JsonHttpClient(BaseUrl),
		        Resolver = new MessageResolver(cmdReceiver)
		    };
		    client.RegisterNamedReceiver<ChatReceiver>("cmd");
            client.RegisterNamedReceiver<TvReciever>("tv");
            client.RegisterNamedReceiver<CssReceiver>("css");
            
            SetSupportActionBar(mToolbar);

		    var mRightDataSet = new List<string>(commands.Keys);
		    var mRightAdapter = new ActionListViewAdapter(this, mRightDataSet);
			mRightDrawer.Adapter = mRightAdapter;
		    mRightDrawer.ItemClick += (sender, args) =>
		    {
               Application.SynchronizationContext.Post(_ =>
               {
                   messageBox.Text = commands[mRightDataSet[args.Position]];
                   mDrawerLayout.CloseDrawer(mRightDrawer);
               },null);
		    };

			mDrawerToggle = new ChatActionBarDrawerToggle(
				this,							//Host Activity
				mDrawerLayout,					//DrawerLayout
				mToolbar,						// Instance of toolbar, if you use other ctor, the hamburger icon/arrow animation won't work..
				Resource.String.openDrawer,		//Opened Message
				Resource.String.closeDrawer		//Closed Message
			);

			SupportActionBar.SetHomeButtonEnabled(true);
			SupportActionBar.SetDisplayShowTitleEnabled(true);

			mDrawerLayout.SetDrawerListener(mDrawerToggle);
			mDrawerToggle.SyncState();

		    navigationView.NavigationItemSelected += OnChannelClick;
            sendButton.Click += OnSendClick;
		}
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            LogManager.LogFactory = new GenericLogFactory(Console.WriteLine);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);
            // Get our button from the layout resource,
            // and attach an event to it
            Button sendButton = FindViewById <Button>(Resource.Id.sendMessageButton);

            messageBox = FindViewById <EditText>(Resource.Id.message);
            SupportToolbar toolbar = FindViewById <SupportToolbar>(Resource.Id.toolbar);

            drawerLayout   = FindViewById <DrawerLayout>(Resource.Id.drawer_layout);
            navigationView = FindViewById <NavigationView>(Resource.Id.nav_view);
            rightDrawer    = FindViewById <ListView>(Resource.Id.right_drawer);
            var messageHistoryList = FindViewById <ListView>(Resource.Id.messageHistory);
            var chatBackground     = FindViewById <ImageView>(Resource.Id.chat_background);

            InitDefaultBackground(chatBackground);

            navigationView.Tag = 0;
            rightDrawer.Tag    = 1;

            var messageHistoryAdapter = new MessageListViewAdapter(this, new List <ChatMessage>(), () => this.subscriberList);

            messageHistoryList.Adapter = messageHistoryAdapter;

            var channels = new[] { "home" };

            cmdReceiver = new ChatCommandHandler(this, messageHistoryAdapter, "home");
            var activity = this;

            client = new ServerEventsClient(BaseUrl, channels)
            {
                OnConnect = connectMsg =>
                {
                    client.UpdateChatHistory(cmdReceiver)
                    .ContinueWith(t =>
                                  connectMsg.UpdateUserProfile(activity));
                },
                OnCommand = command =>
                {
                    if (command is ServerEventJoin)
                    {
                        client.GetChannelSubscribersAsync()
                        .ContinueWith(t => {
                            subscriberList = t.Result;
                            Application.SynchronizationContext.Post(_ => {
                                // Refresh profile icons when users join
                                messageHistoryAdapter.NotifyDataSetChanged();
                            }, null);
                        });
                    }
                },
                OnException = error => {
                    Application.SynchronizationContext.Post(
                        _ => { Toast.MakeText(this, "Error : " + error.Message, ToastLength.Long); }, null);
                },
                //ServiceClient = new JsonHttpClient(BaseUrl),
                Resolver = new MessageResolver(cmdReceiver)
            };
            client.RegisterNamedReceiver <ChatReceiver>("cmd");
            client.RegisterNamedReceiver <TvReciever>("tv");
            client.RegisterNamedReceiver <CssReceiver>("css");

            SetSupportActionBar(toolbar);

            var rightDataSet = new List <string>(commands.Keys);
            var rightAdapter = new ActionListViewAdapter(this, rightDataSet);

            rightDrawer.Adapter    = rightAdapter;
            rightDrawer.ItemClick += (sender, args) =>
            {
                Application.SynchronizationContext.Post(_ =>
                {
                    messageBox.Text = commands[rightDataSet[args.Position]];
                    drawerLayout.CloseDrawer(rightDrawer);
                }, null);
            };

            drawerToggle = new ChatActionBarDrawerToggle(
                this,                          //Host Activity
                drawerLayout,                  //DrawerLayout
                toolbar,                       // Instance of toolbar, if you use other ctor, the hamburger icon/arrow animation won't work..
                Resource.String.openDrawer,    //Opened Message
                Resource.String.closeDrawer    //Closed Message
                );

            SupportActionBar.SetHomeButtonEnabled(true);
            SupportActionBar.SetDisplayShowTitleEnabled(true);

            drawerLayout.SetDrawerListener(drawerToggle);
            drawerToggle.SyncState();

            navigationView.NavigationItemSelected += OnChannelClick;
            sendButton.Click += async(e, args) => { await OnSendClick(e, args); };
        }