Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.72 KB | None | 0 0
  1. // Daniel DePaolo
  2. // 10-25-10
  3. // CS 450
  4. // Client.cpp
  5.  
  6. #include <string>
  7. #include "Client.h"
  8.  
  9. using namespace std;
  10.  
  11. Client::Client( string name, ChatRoom * defaultCR )
  12. {
  13.   clientID = name;
  14.   defaultChatRoom = defaultCR;
  15.   rSock = -1;
  16.   wSock = -1;
  17. }
  18.  
  19. string Client::getID()
  20. {
  21.     return clientID;
  22. }
  23.  
  24. bool Client::isActive()
  25. {
  26.   return (rSock > -1 && wSock > -1);
  27. }
  28.  
  29. void Client::closeWriter()
  30. {
  31. }
  32.  
  33. void Client::closeReader()
  34. {
  35. }
  36.  
  37. void Client::setWriteSockDesc( int wsd )
  38. {
  39.   wSock = wsd;
  40. }
  41.  
  42. void Client::setReadSockDesc( int rsd )
  43. {
  44.   rSock = rsd;
  45. }
  46.  
  47. int Client::getWriteSockDesc()
  48. {
  49.   return wSock;
  50. }
  51.  
  52. int Client::getReadSockDesc()
  53. {
  54.   return rSock;
  55. }
  56.  
  57. void Client::setDefaultChatRoom( ChatRoom *chatRoom)
  58. {
  59.   defaultChatRoom = chatRoom;
  60. }
  61.  
  62. ChatRoom * getDefaultChatRoom()
  63. {
  64.     return defaultChatRoom;
  65. }
  66.  
  67. string Client::readChatMessage()
  68. {
  69. }
  70.  
  71. void Client::writeChatMessage( string msg )
  72. {
  73. }
  74.  
  75. void Client::postMessageToDefaultChatRoom( string msg )
  76. {
  77. }
  78.  
  79. ///////////////////////////////
  80.  
  81. // Daniel DePaolo
  82. // 10-25-10
  83. // CS 450
  84. // ChatRoom.cpp
  85.  
  86. #include <string>
  87. #include "ChatRoom.h"
  88. using namespace std;
  89.  
  90. ChatRoom::ChatRoom(string roomName, string roomTitle)
  91. {
  92.     _name = roomName;
  93.     _title = roomTitle;
  94. }
  95.  
  96. void ChatRoom::addClient(ChatRoom *client)
  97. {
  98.     clients.push_back(client);
  99. }
  100.  
  101. bool ChatRoom::removeClient(string clientToRemove)
  102. {
  103.     int i;
  104.     for (i = 0; i < clients.size(); i++)
  105.         if (clients[i]->getID() == clientToRemove)
  106.         {
  107.             delete clients[i];
  108.             return true;
  109.         }
  110.     return false;
  111. }
  112.  
  113. int ChatRoom::numClients()
  114. {
  115.     return clients.size();
  116. }
  117.  
  118. void ChatRoom::postMessage(std::string message)
  119. {
  120.  
  121. }
  122.  
  123. void ChatRoom::distributeMessages()
  124. {
  125.  
  126. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement