virtual status_t ReadLine(const BString& line) { if (fInvoker == NULL) return B_OK; BMessage messageCopy(*fInvoker->Message()); BString lineCopy(line); lineCopy.RemoveLast("\n"); messageCopy.AddString("line", lineCopy); fInvoker->Invoke(&messageCopy); return B_OK; }
bool CGUIDialogKeyboardGeneric::OnMessage(CGUIMessage& message) { switch ( message.GetMessage() ) { case GUI_MSG_CLICKED: { int iControl = message.GetSenderId(); switch (iControl) { case CTL_BUTTON_DONE: OnOK(); break; case CTL_BUTTON_CANCEL: Close(); break; case CTL_BUTTON_SHIFT: OnShift(); break; case CTL_BUTTON_CAPS: if (m_keyType == LOWER) m_keyType = CAPS; else if (m_keyType == CAPS) m_keyType = LOWER; UpdateButtons(); break; case CTL_BUTTON_LAYOUT: OnLayout(); break; case CTL_BUTTON_SYMBOLS: OnSymbols(); break; case CTL_BUTTON_LEFT: MoveCursor( -1); break; case CTL_BUTTON_RIGHT: MoveCursor(1); break; case CTL_BUTTON_IP_ADDRESS: OnIPAddress(); break; case CTL_BUTTON_CLEAR: SetEditText(""); break; case CTL_EDIT: { CGUIMessage msg(GUI_MSG_ITEM_SELECTED, GetID(), CTL_EDIT); OnMessage(msg); // update callback I guess? if (m_pCharCallback) { // we did _something_, so make sure our search message filter is reset m_pCharCallback(this, msg.GetLabel()); } m_text = msg.GetLabel(); return true; } default: OnClickButton(iControl); break; } } break; case GUI_MSG_SET_TEXT: case GUI_MSG_INPUT_TEXT_EDIT: { // the edit control only handles these messages if it is either focues // or its specific control ID is set in the message. As neither is the // case here (focus is on one of the keyboard buttons) we have to force // the control ID of the message to the control ID of the edit control // (unfortunately we have to create a whole copy of the message object for that) CGUIMessage messageCopy(message.GetMessage(), message.GetSenderId(), CTL_EDIT, message.GetParam1(), message.GetParam2(), message.GetItem()); messageCopy.SetLabel(message.GetLabel()); // ensure this goes to the edit control CGUIControl *edit = GetControl(CTL_EDIT); if (edit) edit->OnMessage(messageCopy); // close the dialog if requested if (message.GetMessage() == GUI_MSG_SET_TEXT && message.GetParam1() > 0) OnOK(); return true; } } return CGUIDialog::OnMessage(message); }
bool Server::read(MsgData& message, ServerPlayer &player) { MsgType msgType; MsgData messageCopy(message); bool isRead(false); message >> msgType; std::cout << "[Serv][Read][Start] \t Read message(" << static_cast<int> (msgType) << ") from " << player.getName() << std::endl; switch (msgType) { case MsgType::Action: if (m_stateInWait) return readAction(message, player); break; case MsgType::ClientPlayerInfo: { // Receive info from Client std::cout << "[Serv][Read] \t Read ClientPlayerInfo" << std::endl; // auto msgCPI = static_cast<MsgClientPlayerInfo> (*message); sf::Uint16 sfPort; std::string name; message >> sfPort >> name; // std::cout << "[Serv][Read] \t cast done : " << msgCPI << std::endl; player.setUdpPort(sfPort); player.setName(name); std::cout << "[Serv][Read] \t Read info client(" << player.getName() << "@" << player.getAddress().toString() << ":" << player.getUdpPort() << ")" << std::endl; // Send info to Client unsigned short port = m_network.getUDPManager().getPort(); MsgData msgServer; msgServer << MsgType::ServerPlayerInfo << sf::Uint16(port) << sf::Int16(player.getId()); std::cout << "[Serv][Read] \t Send info serv. ServUdpPort(" << port << "), playerId(" << sf::Int16(player.getId()) << ")" << std::endl; m_network.getTCPManager().send(msgServer, player.getTCPSocket()); m_players.setPlayerReady(player); isRead = true; } break; case MsgType::Acknowledgment: { std::cout << "Ack" << std::endl; m_acknowledgment.release(); isRead = true; } break; case MsgType::Disconnect: { isRead |= readDisconnect(message, player); } break; case MsgType::Undef: { std::cout << "Undefined" << std::endl; } break; default: { } } if (m_game) isRead = m_game->read(messageCopy, player); return isRead; }