void Display::displayRequirements(CmdParser c) { try { Verbose v(true); Verbose::show("******** REQUIREMENT 4 ********"); Verbose::show("Refer to files Message.h and Message.cpp\n"); Verbose::show("******** REQUIREMENT 6 ********"); Verbose::show("Refer to files Communiation.h and Communication.cpp\n"); Verbose::show("******** REQUIREMENT 8 ********"); Verbose::show("Refer to files Executive.h, Display.h, Display.cpp and Executive.cpp\n"); Verbose::show("******** DEMONSTRATING REQUIREMENT 3, 5 & 7 ********\n"); ObjectFactory of; IRecvr *recv = of.createRecvr(stoi(c.getSelfPortNo())); ISendr *sender = of.createSendr(); IMessage *msg = of.createMessage(); Peer *peer_ = new Peer(sender,recv,msg); peer_->start(); std::cout.flush(); Verbose::show("\n\n Press Enter to Exit."); std::cin.get(); peer_->stop(); } catch (exception ex) { string s = ex.what(); Verbose::show("Exception thrown: "+s); } }
WPFCppCliDemo::WPFCppCliDemo() { // set up channel ObjectFactory* pObjFact = new ObjectFactory; pSendr_ = pObjFact->createSendr(); pRecvr_ = pObjFact->createRecvr(); pChann_ = pObjFact->createMockChannel(pSendr_, pRecvr_); pChann_->start(); delete pObjFact; // client's receive thread recvThread = gcnew Thread(gcnew ThreadStart(this, &WPFCppCliDemo::getMessage)); recvThread->Start(); // set event handlers this->Loaded += gcnew System::Windows::RoutedEventHandler(this, &WPFCppCliDemo::OnLoaded); this->Closing += gcnew CancelEventHandler(this, &WPFCppCliDemo::Unloading); hSendButton->Click += gcnew RoutedEventHandler(this, &WPFCppCliDemo::sendMessage); hClearButton->Click += gcnew RoutedEventHandler(this, &WPFCppCliDemo::clear); hFolderBrowseButton->Click += gcnew RoutedEventHandler(this, &WPFCppCliDemo::browseForFolder); hConnectButton->Click += gcnew RoutedEventHandler(this, &WPFCppCliDemo::connect); hUploadBrowseButton->Click += gcnew RoutedEventHandler(this, &WPFCppCliDemo::uploadBrowseFolder); hUploadFileButton->Click += gcnew RoutedEventHandler(this, &WPFCppCliDemo::uploadFile); hDownloadBrowseButton->Click += gcnew RoutedEventHandler(this, &WPFCppCliDemo::downloadBrowseFolder); hDownloadFileButton->Click += gcnew RoutedEventHandler(this, &WPFCppCliDemo::downloadFile); hTextSearchButton->Click += gcnew RoutedEventHandler(this, &WPFCppCliDemo::textSearch); // set Window properties this->Title = "WPF C++/CLI Demo"; this->Width = 800; this->Height = 600; // attach dock panel to Window this->Content = hDockPanel; hDockPanel->Children->Add(hStatusBar); hDockPanel->SetDock(hStatusBar, Dock::Bottom); hDockPanel->Children->Add(hGrid); // setup Window controls and views setUpTabControl(); setUpStatusBar(); setUpSendMessageView(); setUpConnectionView(); setUpFileUploadView(); setUpFileDownloadView(); setUpTextSearchView(); setUpFileSearchView(); }
int main() { ObjectFactory objFact; ISendr* pSendr = objFact.createSendr(); IRecvr* pRecvr = objFact.createRecvr(); IMockChannel* pMockChannel = objFact.createMockChannel(pSendr, pRecvr); pMockChannel->start(); pSendr->postMessage("Hello World"); pSendr->postMessage("CSE687 - Object Oriented Design"); Message msg = pRecvr->getMessage(); std::cout << "\n received message = \"" << msg << "\""; msg = pRecvr->getMessage(); std::cout << "\n received message = \"" << msg << "\""; pSendr->postMessage("stopping"); msg = pRecvr->getMessage(); std::cout << "\n received message = \"" << msg << "\""; pMockChannel->stop(); pSendr->postMessage("quit"); std::cin.get(); }