Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Daniel DePaolo
- // 10-25-10
- // CS 450
- // Client.cpp
- #include <string>
- #include "Client.h"
- using namespace std;
- Client::Client( string name, ChatRoom * defaultCR )
- {
- clientID = name;
- defaultChatRoom = defaultCR;
- rSock = -1;
- wSock = -1;
- }
- string Client::getID()
- {
- return clientID;
- }
- bool Client::isActive()
- {
- return (rSock > -1 && wSock > -1);
- }
- void Client::closeWriter()
- {
- }
- void Client::closeReader()
- {
- }
- void Client::setWriteSockDesc( int wsd )
- {
- wSock = wsd;
- }
- void Client::setReadSockDesc( int rsd )
- {
- rSock = rsd;
- }
- int Client::getWriteSockDesc()
- {
- return wSock;
- }
- int Client::getReadSockDesc()
- {
- return rSock;
- }
- void Client::setDefaultChatRoom( ChatRoom *chatRoom)
- {
- defaultChatRoom = chatRoom;
- }
- ChatRoom * getDefaultChatRoom()
- {
- return defaultChatRoom;
- }
- string Client::readChatMessage()
- {
- }
- void Client::writeChatMessage( string msg )
- {
- }
- void Client::postMessageToDefaultChatRoom( string msg )
- {
- }
- ///////////////////////////////
- // Daniel DePaolo
- // 10-25-10
- // CS 450
- // ChatRoom.cpp
- #include <string>
- #include "ChatRoom.h"
- using namespace std;
- ChatRoom::ChatRoom(string roomName, string roomTitle)
- {
- _name = roomName;
- _title = roomTitle;
- }
- void ChatRoom::addClient(ChatRoom *client)
- {
- clients.push_back(client);
- }
- bool ChatRoom::removeClient(string clientToRemove)
- {
- int i;
- for (i = 0; i < clients.size(); i++)
- if (clients[i]->getID() == clientToRemove)
- {
- delete clients[i];
- return true;
- }
- return false;
- }
- int ChatRoom::numClients()
- {
- return clients.size();
- }
- void ChatRoom::postMessage(std::string message)
- {
- }
- void ChatRoom::distributeMessages()
- {
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement