Add text message sending.
This commit is contained in:
parent
d289bf3134
commit
5e060ead33
@ -29,8 +29,6 @@ namespace mumlib {
|
||||
|
||||
~Mumlib();
|
||||
|
||||
void setCallback(Callback &callback);
|
||||
|
||||
void connect(string host, int port, string user, string password);
|
||||
|
||||
void disconnect();
|
||||
@ -41,6 +39,8 @@ namespace mumlib {
|
||||
|
||||
void sendAudioData(int16_t *pcmData, int pcmLength);
|
||||
|
||||
void sendTextMessage(std::string message);
|
||||
|
||||
private:
|
||||
_Mumlib_Private *impl;
|
||||
};
|
||||
|
@ -11,6 +11,16 @@ public:
|
||||
virtual void audio(int16_t *pcm_data, uint32_t pcm_data_size) {
|
||||
mum->sendAudioData(pcm_data, pcm_data_size);
|
||||
}
|
||||
|
||||
virtual void textMessage(
|
||||
uint32_t actor,
|
||||
std::vector<uint32_t> session,
|
||||
std::vector<uint32_t> channel_id,
|
||||
std::vector<uint32_t> tree_id,
|
||||
std::string message) {
|
||||
mumlib::BasicCallback::textMessage(actor, session, channel_id, tree_id, message);
|
||||
mum->sendTextMessage("someone said: " + message);
|
||||
}
|
||||
};
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
@ -30,6 +30,8 @@ namespace mumlib {
|
||||
|
||||
Audio audio;
|
||||
|
||||
int sessionId = 0;
|
||||
int channelId = 0;
|
||||
|
||||
_Mumlib_Private(Callback &callback)
|
||||
: _Mumlib_Private(callback, *(new io_service())) {
|
||||
@ -80,6 +82,9 @@ namespace mumlib {
|
||||
case MessageType::SERVERSYNC: {
|
||||
MumbleProto::ServerSync serverSync;
|
||||
serverSync.ParseFromArray(buffer, length);
|
||||
|
||||
sessionId = serverSync.session();
|
||||
|
||||
callback.serverSync(
|
||||
serverSync.welcome_text(),
|
||||
serverSync.session(),
|
||||
@ -116,6 +121,8 @@ namespace mumlib {
|
||||
std::copy(channelState.links_remove().begin(), channelState.links_remove().end(),
|
||||
links_remove.begin());
|
||||
|
||||
this->channelId = channel_id;
|
||||
|
||||
callback.channelState(
|
||||
channelState.name(),
|
||||
channel_id,
|
||||
@ -310,15 +317,10 @@ namespace mumlib {
|
||||
delete impl;
|
||||
}
|
||||
|
||||
|
||||
ConnectionState Mumlib::getConnectionState() {
|
||||
return impl->transport.getConnectionState();
|
||||
}
|
||||
|
||||
void Mumlib::setCallback(Callback &callback) {
|
||||
impl->callback = callback;
|
||||
}
|
||||
|
||||
void Mumlib::connect(string host, int port, string user, string password) {
|
||||
impl->transport.connect(host, port, user, password);
|
||||
}
|
||||
@ -340,4 +342,12 @@ namespace mumlib {
|
||||
int length = impl->audio.encodeAudioPacket(0, pcmData, pcmLength, encodedData, 5000);
|
||||
impl->transport.sendEncodedAudioPacket(encodedData, length);
|
||||
}
|
||||
|
||||
void Mumlib::sendTextMessage(string message) {
|
||||
MumbleProto::TextMessage textMessage;
|
||||
textMessage.set_actor(impl->sessionId);
|
||||
textMessage.add_channel_id(impl->channelId);
|
||||
textMessage.set_message(message);
|
||||
impl->transport.sendControlMessage(MessageType::TEXTMESSAGE, textMessage);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user