void LinkClient::OnLinkConnect() { char ipaddress[31]; UpdateData(TRUE); lanlink.type = m_prottype; lanlink.server = false; lanlink.speed = m_hacks==1 ? true : false; m_serverip.GetWindowText(ipaddress, 30); // These must be created on the heap - referenced from the connection thread ServerWait *dlg = new ServerWait(); dlg->Create(IDD_SERVERWAIT, this); dlg->ShowWindow(SW_SHOW); // Owns the ServerWait* Win32ClientInfoDisplay *dlginfo = new Win32ClientInfoDisplay(dlg); // lc thread will own the dlginfo if (!lc.Init(sf::IPAddress(std::string(ipaddress)), dlginfo)) { // Thread didn't get created delete dlginfo; MessageBox("Error occurred.\nPlease try again.", "Error", MB_OK); } return; }
void LinkServer::OnServerStart() { UpdateData(TRUE); lanlink.numslaves = m_numplayers+1; lanlink.type = m_prottype; lanlink.server = true; lanlink.speed = m_speed==1 ? true : false; sf::IPAddress addr; // These must be created on the heap - referenced from the connection thread ServerWait *dlg = new ServerWait(); dlg->Create(IDD_SERVERWAIT, this); dlg->ShowWindow(SW_SHOW); // Owns the ServerWait* Win32ServerInfoDisplay *dlginfo = new Win32ServerInfoDisplay(dlg); // ls thread will own the dlginfo if (!ls.Init(dlginfo)) { // Thread didn't get created delete dlginfo; MessageBox("Error occurred.\nPlease try again.", "Error", MB_OK); } return; }
void LinkServer::OnServerStart() { int errorcode; ServerWait dlg; UpdateData(TRUE); lanlink.numgbas = m_numplayers+1; lanlink.type = m_prottype; lanlink.server = 1; lanlink.speed = m_speed==1 ? true : false; if((errorcode=ls.Init(&dlg))!=0){ char message[50]; sprintf(message, _T("Error %d occured.\nPlease try again."), errorcode); MessageBox(message, _T("Error"), MB_OK); return; } dlg.DoModal(); return; }
void LinkClient::OnLinkConnect() { char ipaddress[31]; int errorcode; ServerWait dlg; UpdateData(TRUE); lanlink.type = m_prottype; lanlink.server = 0; lanlink.speed = m_hacks==1 ? true : false; m_serverip.GetWindowText(ipaddress, 30); if((errorcode=lc.Init(gethostbyname(ipaddress), &dlg))!=0){ char message[50]; sprintf(message, _T("Error %d occured.\nPlease try again."), errorcode); MessageBox(message, _T("Error"), MB_OK); return; } dlg.DoModal(); return; }
void LinkOptions::OnOk() { static const int length = 256; int timeout; CString timeoutStr; CString host; CString title; CString addressMessage; UpdateData(TRUE); // Close any previous link CloseLink(); m_serverip.GetWindowText(host); m_timeout.GetWindowText(timeoutStr); sscanf(timeoutStr, "%d", &timeout); SetLinkTimeout(timeout); LinkMode newMode = (LinkMode)m_type; if (newMode == LINK_DISCONNECTED) { linkTimeout = timeout; linkMode = LINK_DISCONNECTED; theApp.linkHostAddr = host; CDialog::OnOK(); return; } bool needsServerHost = newMode == LINK_GAMECUBE_DOLPHIN || (newMode == LINK_CABLE_SOCKET && !m_server) || (newMode == LINK_RFU_SOCKET && !m_server); if (needsServerHost) { bool valid = SetLinkServerHost(host); if (!valid) { AfxMessageBox("You must enter a valid host name", MB_OK | MB_ICONSTOP); return; } } EnableSpeedHacks(linkHacks); EnableLinkServer(m_server, linkNumPlayers + 1); if (m_server) { char localhost[length]; GetLinkServerHost(localhost, length); title = "Waiting for clients..."; addressMessage.Format("Server IP address is: %s\n", localhost); } else { title = "Waiting for connection..."; addressMessage.Format("Connecting to %s\n", host); } // Init link ConnectionState state = InitLink(newMode); // Display a progress dialog while the connection is establishing if (state == LINK_NEEDS_UPDATE) { ServerWait* dlg = new ServerWait(); dlg->Create(ServerWait::IDD, this); dlg->m_plconn[1] = title; dlg->m_serveraddress = addressMessage; dlg->ShowWindow(SW_SHOW); while (state == LINK_NEEDS_UPDATE) { // Ask the core for updates char message[length]; state = ConnectLinkUpdate(message, length); // Update the wait message if (strlen(message)) { dlg->m_plconn[1] = message; } // Step the progress bar and update dialog data dlg->m_prgctrl.StepIt(); dlg->UpdateData(false); // Process Windows messages MSG msg; while (PeekMessage(&msg, 0, 0, 0, PM_NOREMOVE)) { AfxGetApp()->PumpMessage(); } // Check whether the user has aborted if (dlg->m_userAborted) { state = LINK_ABORT; } } delete dlg; } // The user canceled the connection attempt if (state == LINK_ABORT) { CloseLink(); return; } // Something failed during init if (state == LINK_ERROR) { AfxMessageBox("Error occurred.\nPlease try again.", MB_OK | MB_ICONSTOP); return; } linkTimeout = timeout; linkMode = GetLinkMode(); theApp.linkHostAddr = host; CDialog::OnOK(); return; }