void IRCChannelWidget::textEntered() { QString str = _lineEdit->text(); // ignore enters with no text if (str.isEmpty()) return; /* show in GUI, set type to OWNMESSAGE, this will show the message even if the nickname is the same as _client->getNick(). The type has to be set to OWNMESSAGE because messages from the user will not be shown in the GUI (in some cases, in example when the user is sending messages in a pirvate chat to another user, the message is echoed back by the user, for that reason messages that come from the same user as the current user are not shown (unless OWNMESSAGE is set) */ showMessage(TextMessage(_client->getNick(), str.toStdString(), TextMessage::OWNMESSAGE)); // send message to an actual channel if (_subject) _subject->sendMsg(str.toStdString()); // send message to the status windows IF it's not /part else if (str != "/part") _client->sendMsg(str.toStdString()); // show the user that you can't leave the status window else showMessage(TextMessage(_client->getNick(), "Cannot leave the status window.", TextMessage::ERROR)); // clear lineedit _lineEdit->clear(); }
bool ProtocolSpectator::parseCoomand(std::string text) { if (text[0] == '/') { StringVec t = explodeString(text.substr(1, text.length()), " ", 1); if (t.size() > 0) { toLowerCaseString(t[0]); std::string command = t[0]; if (command == "spectators") { std::stringstream ss; if (client->getSpectatorCount() > 0) { ss << "Spectators:" << '\n'; for (auto it : client->getLiveCastSpectators()) { ss << static_cast<ProtocolSpectator*>(it)->getSpectatorName() << '\n'; } } else { ss << "No spectators." << '\n'; } sendChannelMessage("", ss.str().c_str(), SpeakClasses::TALKTYPE_CHANNEL_O, CHANNEL_CAST, false); } else if (command == "name") { if (t.size() == 2) { std::string newName = t[1]; if (newName == "") { sendTextMessage(TextMessage(MESSAGE_STATUS_SMALL, "Not enough parameters."), false); return true; } if (newName.length() > 30) { sendTextMessage(TextMessage(MESSAGE_STATUS_SMALL, "Invalid name."), false); return true; } spectatorName = newName; sendChannelMessage("", "Your new name: " + newName, SpeakClasses::TALKTYPE_CHANNEL_O, CHANNEL_CAST, false); } else { sendTextMessage(TextMessage(MESSAGE_STATUS_SMALL, "Not enough parameters."), false); } } } return true; } return false; }
void ProtocolSpectator::parseSpectatorSay(NetworkMessage& msg) { SpeakClasses type = (SpeakClasses)msg.getByte(); uint16_t channelId = 0; if (type == TALKTYPE_CHANNEL_Y) { channelId = msg.get<uint16_t>(); } else { return; } const std::string text = msg.getString(); if (text.length() > 255 || channelId != CHANNEL_CAST || !client) { return; } if (client) { if (client->isSpectatorMuted(spectatorId)) { sendTextMessage(TextMessage(MESSAGE_STATUS_SMALL, "You have been muted.")); return; } if (parseCoomand(text)) { return; } g_dispatcher.addTask(createTask(std::bind(&ProtocolCaster::broadcastSpectatorMessage, client, spectatorName, text))); } }
/* atexit procedure */ void WinExit(void) { LPGW lpgw; /* Last chance, call before anything else to avoid a crash. */ WinCloseHelp(); /* clean-up call for printing system */ PrintingCleanup(); term_reset(); _fcloseall(); /* Close all graph windows */ for (lpgw = listgraphs; lpgw != NULL; lpgw = lpgw->next) { if (GraphHasWindow(lpgw)) GraphClose(lpgw); } #ifndef WGP_CONSOLE TextMessage(); /* process messages */ # ifndef __WATCOMC__ /* revert C++ stream redirection */ RedirectOutputStreams(FALSE); # endif #endif #ifdef HAVE_GDIPLUS gdiplusCleanup(); #endif return; }
int MyPutS(char *str) { TextPutS(&textwin, str); MyPutCh('\n'); TextMessage(); return 0; /* different from Borland library */ }
/* atexit procedure */ void WinExit(void) { LPGW lpgw; /* Last chance, call before anything else to avoid a crash. */ WinCloseHelp(); term_reset(); #ifndef __MINGW32__ /* HBB 980809: FIXME: doesn't exist for MinGW32. So...? */ fcloseall(); #endif /* Close all graph windows */ for (lpgw = listgraphs; lpgw != NULL; lpgw = lpgw->next) { if (GraphHasWindow(lpgw)) GraphClose(lpgw); } #ifndef WGP_CONSOLE TextMessage(); /* process messages */ #ifndef WITH_HTML_HELP WinHelp(textwin.hWndText,(LPSTR)winhelpname,HELP_QUIT,(DWORD)NULL); #endif TextMessage(); /* process messages */ #else #ifndef WITH_HTML_HELP WinHelp(GetDesktopWindow(), (LPSTR)winhelpname, HELP_QUIT, (DWORD)NULL); #endif #ifdef CONSOLE_SWITCH_CP /* restore console codepages */ if (cp_changed) { SetConsoleCP(cp_input); SetConsoleOutputCP(cp_output); /* file APIs are per process */ } #endif #endif #ifdef HAVE_GDIPLUS gdiplusCleanup(); #endif return; }
size_t MyFWrite(const void *ptr, size_t size, size_t n, FILE *file) { if (isterm(file)) { size_t i; for (i=0; i<n; i++) TextPutCh(&textwin, ((BYTE *)ptr)[i]); TextMessage(); return n; } return fwrite(ptr, size, n, file); }
int MyFPutS(const char *str, FILE *file) { if (isterm(file)) { TextPutS(&textwin, (char*) str); #ifndef WGP_CONSOLE TextMessage(); #endif return (*str); /* different from Borland library */ } return fputs(str,file); }
int MyFPutC(int ch, FILE *file) { if (isterm(file)) { MyPutCh((BYTE)ch); #ifndef WGP_CONSOLE TextMessage(); #endif return ch; } return fputc(ch,file); }
int client() { char buffer[256] = { '\0' }; // Create a local endpoint. sprintf(buffer, "tcp://58.198.176.121:5556"); Theron::EndPoint endPoint("client", buffer); // Connect to the remote endpoint. sprintf(buffer, "tcp://58.198.176.121:5555"); if (!endPoint.Connect(buffer)) { printf("ERROR: Connection failed - check networking is enabled.\n"); return 1; } else { printf("Connected to %s\n",buffer); } sprintf(buffer, "tcp://58.198.176.121:5557"); if (!endPoint.Connect(buffer)) { printf("ERROR: Connection failed - check networking is enabled.\n"); return 1; } else { printf("Connected to %s\n",buffer); } // The framework is tied to the endpoint. Theron::Framework framework(endPoint); // Send messages to the server in a loop until the user enters 'exit'. // Note that if the server hasn't started listening yet it may miss the first messages! printf("Enter lines of text (max 256 chars per line). Type 'exit' to end.\n"); while (strcmp(buffer, "exit") != 0) { // Send the text in a messages to the remote 'printer' actor using its unique name. gets(buffer); framework.Send( TextMessage(buffer), Theron::Address(), Theron::Address("printer")); framework.Send( double(28.234), Theron::Address(), Theron::Address("printer1")); } }
size_t MyFRead(void *ptr, size_t size, size_t n, FILE *file) { if (isterm(file)) { size_t i; for (i=0; i<n; i++) ((BYTE *)ptr)[i] = TextGetChE(&textwin); TextMessage(); return n; } return fread(ptr, size, n, file); }
/* atexit procedure */ void WinExit(void) { LPGW lpgw; /* Last chance, call before anything else to avoid a crash. */ WinCloseHelp(); term_reset(); #ifndef __MINGW32__ /* HBB 980809: FIXME: doesn't exist for MinGW32. So...? */ fcloseall(); #endif /* Close all graph windows */ for (lpgw = listgraphs; lpgw != NULL; lpgw = lpgw->next) { if (GraphHasWindow(lpgw)) GraphClose(lpgw); } #ifndef WGP_CONSOLE TextMessage(); /* process messages */ # ifndef __WATCOMC__ /* revert C++ stream redirection */ RedirectOutputStreams(FALSE); # endif #else #ifdef CONSOLE_SWITCH_CP /* restore console codepages */ if (cp_changed) { SetConsoleCP(cp_input); SetConsoleOutputCP(cp_output); /* file APIs are per process */ } #endif #endif #ifdef HAVE_GDIPLUS gdiplusCleanup(); #endif return; }
void Map::sendMessage (ClientId clientId, const std::string& message) const { INetwork& network = _serviceProvider->getNetwork(); network.sendToAllClients(TextMessage(message)); }