Click here to Skip to main content
15,893,588 members
Articles / Programming Languages / C++

Push Framework - A C++ toolkit for high performance server development

Rate me:
Please Sign up or sign in to vote.
4.96/5 (86 votes)
23 May 2012Apache15 min read 261.9K   26.9K   316  
Write asynchronous, multithreaded servers in a few lines of code. Monitor realtime activity with a deploy-only dashboard.
// RoomChatTab.cpp : implementation file
//

#include "stdafx.h"
#include "ChatClient.h"
#include "RoomChatTab.h"


// CRoomChatTab dialog

IMPLEMENT_DYNAMIC(CRoomChatTab, CDialog)

CRoomChatTab::CRoomChatTab(CWnd* pParent /*=NULL*/)
	: CDialog(CRoomChatTab::IDD, pParent),
	CChatInboxManager(m_chatHistoryEdit, m_roomsComboBox)
{

}

CRoomChatTab::~CRoomChatTab()
{
}

void CRoomChatTab::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_COMBO1, m_roomsComboBox);
	DDX_Control(pDX, IDC_EDIT1, m_chatHistoryEdit);
	DDX_Control(pDX, IDC_EDIT2, m_chatInputEdit);
}


BEGIN_MESSAGE_MAP(CRoomChatTab, CDialog)
	ON_BN_CLICKED(IDC_JOIN_ROOM, &CRoomChatTab::OnBnClickedJoinRoom)
	ON_CBN_SELCHANGE(IDC_COMBO1, &CRoomChatTab::OnCbnSelchangeCombo)
	ON_BN_CLICKED(IDC_SEND, &CRoomChatTab::OnBnClickedSend)
END_MESSAGE_MAP()


// CRoomChatTab message handlers

void CRoomChatTab::OnBnClickedJoinRoom()
{
	// TODO: Add your control notification handler code here
	std::string room = CChatInboxManager::getCurView();
	if (room == joinedRoom)
	{
		return;
	}
	//
	theApp.getChatAPI().JoinRoom(room);
}

void CRoomChatTab::DeliverRooms( std::vector<std::string>& roomsList )
{
	for (int i=0;i<roomsList.size();i++)
	{
		CChatInboxManager::AddView(roomsList.at(i));
	}
}

void CRoomChatTab::DeliverJoinRoom( std::string roomName )
{
	this->joinedRoom = roomName;
}

void CRoomChatTab::DeliverRoomChat( std::string sender, std::string msg, std::string room )
{
	std::string printMsg = "[" + sender + "] "+ msg;
	CChatInboxManager::DeliverChatToView(printMsg, room);
}

void CRoomChatTab::OnCbnSelchangeCombo()
{
	// TODO: Add your control notification handler code here
	CChatInboxManager::OnViewChanged();
	if (CChatInboxManager::getCurView() == "" || CChatInboxManager::getCurView()==joinedRoom)
	{
		GetDlgItem(IDC_JOIN_ROOM)->EnableWindow(FALSE);
	}
	else
		GetDlgItem(IDC_JOIN_ROOM)->EnableWindow(TRUE);
}

void CRoomChatTab::OnBnClickedSend()
{
	CString strText;
	m_chatInputEdit.GetWindowText(strText);
	std::string msg = (char*) CT2CA(strText);
	//
	theApp.getChatAPI().SendRoomChat(msg, CChatInboxManager::getCurView());
	//
	m_chatInputEdit.SetSel(0, -1);
	m_chatInputEdit.ReplaceSel(_T(""));
	//
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Apache License, Version 2.0


Written By
Technical Lead
Tunisia Tunisia
Services:
http://www.pushframework.com/?page_id=890

Comments and Discussions