MCPcopy Create free account
hub / github.com/TactilityProject/Tactility / sendMessage

Method sendMessage

Tactility/Source/app/chat/ChatApp.cpp:93–122  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

91}
92
93void ChatApp::sendMessage(const std::string& text) {
94 if (text.empty()) return;
95
96 std::string nickname = state.getLocalNickname();
97 std::string channel = state.getCurrentChannel();
98
99 std::vector<uint8_t> wireMsg;
100 if (!serializeTextMessage(settings.senderId, BROADCAST_ID, nickname, channel, text, wireMsg)) {
101 LOGGER.error("Failed to serialize message");
102 return;
103 }
104
105 if (!service::espnow::send(BROADCAST_ADDRESS, wireMsg.data(), wireMsg.size())) {
106 LOGGER.error("Failed to send message");
107 return;
108 }
109
110 StoredMessage msg;
111 msg.displayText = nickname + ": " + text;
112 msg.target = channel;
113 msg.isOwn = true;
114
115 state.addMessage(msg);
116
117 {
118 auto lock = lvgl::getSyncLock()->asScopedLock();
119 lock.lock();
120 view.displayMessage(msg);
121 }
122}
123
124void ChatApp::applySettings(const std::string& nickname, const std::string& keyHex) {
125 bool needRestart = false;

Callers 1

onSendClickedMethod · 0.80

Calls 10

serializeTextMessageFunction · 0.85
sendFunction · 0.85
getSyncLockFunction · 0.85
getLocalNicknameMethod · 0.80
getCurrentChannelMethod · 0.80
errorMethod · 0.80
addMessageMethod · 0.80
asScopedLockMethod · 0.80
displayMessageMethod · 0.80
lockMethod · 0.45

Tested by

no test coverage detected