本文整理汇总了C++中osc::ReceivedMessage::ArgumentStream方法的典型用法代码示例。如果您正苦于以下问题:C++ ReceivedMessage::ArgumentStream方法的具体用法?C++ ReceivedMessage::ArgumentStream怎么用?C++ ReceivedMessage::ArgumentStream使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osc::ReceivedMessage
的用法示例。
在下文中一共展示了ReceivedMessage::ArgumentStream方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ProcessMessage
void OSCHandler::ProcessMessage(const osc::ReceivedMessage& m, const IpEndpointName& /*remoteEndpoint*/)
{
const String stripWildcard = OSCPrefix + "strip/*";
try
{
String msgPattern = m.AddressPattern();
if (msgPattern.equalsIgnoreCase(OSCPrefix + "press"))
{
// we need three arguments for button presses
const int numArgs = m.ArgumentCount();
if (numArgs != 3) throw osc::Exception();
osc::ReceivedMessageArgumentStream args = m.ArgumentStream();
// unpack the monome button, row and state (button up or down)
osc::int32 row, col, state;
args >> row >> col >> state >> osc::EndMessage;
buttonPressCallback(row, col, state == 1);
}
else if (msgPattern.matchesWildcard(stripWildcard, false))
{
// strip off the /mlrvst/strip/ part of the message
msgPattern = msgPattern.substring(stripWildcard.length() - 1);
// and extract the SampleStrip rowID from the message
const String rowIDStr = msgPattern.upToFirstOccurrenceOf("/", false, false);
const int stripID = rowIDStr.getIntValue();
handleStripMessage(stripID, m);
}
}
示例2: ProcessMessage
// Process incoming OSC. Used for Kyma communication.
//
void SoundplaneModel::ProcessMessage(const osc::ReceivedMessage& m, const IpEndpointName& remoteEndpoint)
{
osc::ReceivedMessageArgumentStream args = m.ArgumentStream();
osc::int32 a1;
try
{
if( std::strcmp( m.AddressPattern(), "/osc/response_from" ) == 0 )
{
args >> a1 >> osc::EndMessage;
// set Kyma mode
if (mOSCOutput.getKymaMode())
{
mKymaIsConnected = true;
}
}
else if (std::strcmp( m.AddressPattern(), "/osc/notify/midi/Soundplane" ) == 0 )
{
args >> a1 >> osc::EndMessage;
// set voice count to a1
int newTouches = clamp((int)a1, 0, kSoundplaneMaxTouches);
if(mKymaIsConnected)
{
// Kyma is sending 0 sometimes, which there is probably
// no reason to respond to
if(newTouches > 0)
{
setProperty("max_touches", newTouches);
}
}
}
示例3: get_group_users_info
void get_group_users_info( const osc::ReceivedMessage& m,
const IpEndpointName& remoteEndpoint )
{
(void) remoteEndpoint; // suppress unused parameter warning
// /groupserver/get_group_users_info group-name group-password
osc::ReceivedMessageArgumentStream args = m.ArgumentStream();
const char *groupName, *groupPassword;
args >> groupName >> groupPassword >> osc::EndMessage;
Group *group = groupServer_.FindGroup( groupName );
if( group && group->password.compare( groupPassword ) == 0 ){
std::time_t currentTime = time(0);
for( Group::const_user_iterator i = group->users_begin();
i != group->users_end(); ++i )
MakeUserInfoMessage( resultStream_, *i, currentTime );
}
// we don't return a result to the client in the case where the group
// doesn't exist, or the password is wrong because legitimate clients
// will have already successfully joined the group, or they will have
// received an error message when they tried to join.
}
示例4: handleObjectPadMessage
void Network::handleObjectPadMessage(const osc::ReceivedMessage& m,
const IpEndpointName& remoteEndpoint)
{
// Utility data structures
char buffer[1024];
osc::OutboundPacketStream ps(buffer, 1024);
// Parse OSC message
float x, y, radius;
osc::Symbol uuid;
m.ArgumentStream() >> uuid >> x >> y >> radius >> osc::EndMessage;
std::cerr << uuid << ", " << x << ", " << y << ", " << radius << std::endl;
// Check for known pad, add & broadcast if unknown
WidgetMap* widgets = Widget::getAll();
WidgetMap::iterator wit = widgets->find(std::string(uuid));
if (wit == widgets->end()) {
RoundPad* newPad = new RoundPad(Point2D(x, y), radius);
newPad->setUuid(uuid);
widgets->insert(WidgetData(std::string(uuid), newPad));
m_engine->addChild(newPad);
// Tell the world
newPad->toOutboundPacketStream(ps);
broadcast(ps);
}
}
示例5: handlePeerTextMessage
void Network::handlePeerTextMessage(const osc::ReceivedMessage& m,
const IpEndpointName& remoteEndpoint)
{
// Utility data structures
char buffer[1024];
osc::OutboundPacketStream ps(buffer, 1024);
// Parse OSC message
osc::Symbol text;
osc::int64 address;
osc::int32 port;
m.ArgumentStream() >> address >> port >> text >> osc::EndMessage;
if (address == 0)
address = remoteEndpoint.address;
char ipStr[INET_ADDRSTRLEN];
uint32_t endian = htonl(address);
std::cerr << inet_ntop(AF_INET, &(endian), ipStr, INET_ADDRSTRLEN) << ": " << text << std::endl;
// Check for known peer, add & broadcast if unknown
IpEndpointName peerEndpoint((unsigned long)address, (int)port);
PeerMap::iterator peer = m_peers.find(peerEndpoint);
if (peer != m_peers.end())
peer->second->setDisplayName(std::string(text));
}
示例6: handlePeerDownMessage
void Network::handlePeerDownMessage(const osc::ReceivedMessage& m,
const IpEndpointName& remoteEndpoint)
{
// Utility data structures
char buffer[1024];
osc::OutboundPacketStream ps(buffer, 1024);
// Parse OSC message
osc::int32 port;
osc::int64 address;
m.ArgumentStream() >> address >> port >> osc::EndMessage;
if (address == 0)
address = remoteEndpoint.address;
char ipStr[INET_ADDRSTRLEN];
uint32_t endian = htonl(address);
std::cerr << inet_ntop(AF_INET, &(endian), ipStr, INET_ADDRSTRLEN) << ", " << (int)port << std::endl;
// Check for known peer, add & broadcast if unknown
IpEndpointName peerEndpoint((unsigned long)address, (int)port);
PeerMap::iterator peer = m_peers.find(peerEndpoint);
if (peer != m_peers.end()) {
m_peers.erase(peer);
// Tell the world
ps << osc::BeginMessage("/network/peer/down") << address << port << osc::EndMessage;
broadcast(ps);
}
}
示例7: processServerStatusMessage
void ScServer::processServerStatusMessage(const osc::ReceivedMessage &message )
{
if (!isRunning())
return;
int unused;
int ugenCount;
int synthCount;
int groupCount;
int defCount;
float avgCPU;
float peakCPU;
auto args = message.ArgumentStream();
try
{
args >> unused
>> ugenCount
>> synthCount
>> groupCount
>> defCount
>> avgCPU
>> peakCPU;
}
catch (osc::MissingArgumentException)
{
qCritical("Misformatted server status message.");
return;
}
emit updateServerStatus(ugenCount, synthCount,
groupCount, defCount,
avgCPU, peakCPU);
}
示例8: if
void MLT3DHub::ProcessMessage(const osc::ReceivedMessage& msg, const IpEndpointName&)
{
osc::TimeTag frameTime;
osc::int32 frameID, touchID, deviceID;
float x, y, z, note;
// todo keep track of alive touches again to fix deadbeats
// int alive[MLProcInputToSignals::kFrameHeight] = {0};
try
{
osc::ReceivedMessageArgumentStream args = msg.ArgumentStream();
const char * addy = msg.AddressPattern();
//debug() << "t3d: " << addy << "\n";
// frame message.
// /t3d/frm (int)frameID int)deviceID
if (strcmp(addy, "/t3d/frm") == 0)
{
args >> frameID >> deviceID;
mT3DWaitTime = 0;
if(!mConnected)
{
mConnected = true;
notifyListeners("connected", 1);
}
//debug() << "FRM " << frameID << "\n";
}
// match tch[n] message
else if (strncmp(addy, "/t3d/tch", 8) == 0)
{
// get trailing number
touchID = 1;
int len = strlen(addy);
if(len == 9)
{
touchID = addy[8] - 48;
}
else if(len == 10)
{
touchID = 10*(addy[8] - 48) + (addy[9] - 48);
}
touchID = clamp(touchID - 1, (osc::int32)0, (osc::int32)16);
// t3d/tch[ID], (float)x, (float)y, (float)z, (float)note
args >> x >> y >> z >> note;
//debug() << "TCH " << touchID << " " << x << " " << y << " " << z << " " << note << "\n";
mOutputFrame(0, touchID) = x;
mOutputFrame(1, touchID) = y;
mOutputFrame(2, touchID) = z;
mOutputFrame(3, touchID) = note;
}
示例9: handleObjectStringMessage
void Network::handleObjectStringMessage(const osc::ReceivedMessage& m,
const IpEndpointName& remoteEndpoint)
{
// Utility data structures
char buffer[1024];
osc::OutboundPacketStream ps(buffer, 1024);
// Parse OSC message
osc::Symbol uuid, padUuid;
float startX, startY, endX, endY;
m.ArgumentStream() >> uuid >> padUuid >> startX >> startY
>> endX >> endY >> osc::EndMessage;
std::cerr << uuid << ", " << padUuid << ", "
<< startX << ", " << startY << ", "
<< endX << ", " << endY << std::endl;
// Check for known arc, add & broadcast if unknown
bool unlocked = false;
SoundSource::lockGlobals();
SoundSourceMap* soundSources = SoundSource::getAllForEngine();
WidgetMap* widgets = Widget::getAll();
if (soundSources->find(std::string(uuid)) == soundSources->end()) {
WidgetMap::iterator wit = m_orphans.find(std::string(uuid));
if (wit == m_orphans.end()) {
// Search for pad
wit = widgets->find(std::string(padUuid));
if (wit != widgets->end()) {
String* newString = new String(Point2D(startX, startY), Point2D(endX, endY), 1);
newString->setUuid(uuid);
// Add string to soundsource
soundSources->insert(SoundSourceData(newString->getUuid(), newString));
wit->second->addChild(newString);
newString->setPadRadius(((RoundPad*)wit->second)->getRadius());
// Tell the world
newString->toOutboundPacketStream(ps);
broadcast(ps);
} else {// orphan if we don't know about its pad yet
String* newString = new String(Point2D(startX, startY), Point2D(endX, endY), 1);
newString->setUuid(uuid);
m_orphans.insert(WidgetData(std::string(padUuid), newString));
}
SoundSource::unlockGlobals();
unlocked = true;
}
}
if (!unlocked)
SoundSource::unlockGlobals();
}
示例10: handlePeerUpMessage
void Network::handlePeerUpMessage(const osc::ReceivedMessage& m,
const IpEndpointName& remoteEndpoint)
{
// Utility data structures
char buffer[1024];
osc::OutboundPacketStream ps(buffer, 1024);
// Parse OSC message
osc::int32 port;
osc::int64 address;
m.ArgumentStream() >> address >> port >> osc::EndMessage;
if ((long)address == 0)
address = remoteEndpoint.address;
char ipStr[INET_ADDRSTRLEN];
uint32_t endian = htonl(address);
std::cerr << inet_ntop(AF_INET, &(endian), ipStr, INET_ADDRSTRLEN) << ", " << (int)port << std::endl;
// Check for known peer, add & broadcast if unknown
IpEndpointName peerEndpoint((unsigned long)address, (int)port);
PeerMap::iterator peer = m_peers.find(peerEndpoint);
if (peer == m_peers.end()) {
PeerData peerData(peerEndpoint, new Peer(peerEndpoint));
// Tell the world
for (PeerMap::iterator pit = m_peers.begin(); pit != m_peers.end(); pit++) {
std::cerr << "sending " << (int)port << " to " << pit->first.port << std::endl;
ps.Clear();
ps << osc::BeginMessage("/network/peer/up") << address << port << osc::EndMessage;
pit->second->sendMessage(ps);
ps.Clear();
ps << osc::BeginMessage("/network/peer/up")
<< (osc::int64)(pit->first.address)
<< (osc::int32)(pit->first.port)
<< osc::EndMessage;
peerData.second->sendMessage(ps);
}
peer = m_peers.insert(peerData).first;
sendPeerUpMessage();
// Tell our new friend everything we know
/*
* This doesn't work terribly well, so it's disabled for now
*
WidgetMap* widgets = Widget::getAll();
for (WidgetMap::iterator wit = widgets->begin(); wit != widgets->end(); wit++) {
wit->second->toOutboundPacketStream(ps);
peer->second->sendMessage(ps);
}
*/
}
}
示例11: ProcessMessage
void MyPacketListener::ProcessMessage(const osc::ReceivedMessage &m, const IpEndpointName &remoteEndpoint)
{
(void) remoteEndpoint;
try {
auto args = m.ArgumentStream();
const char* msg;
args >> msg >> osc::EndMessage;
emit parent_->message(m.AddressPattern(), msg);
} catch (const osc::Exception& e) {
std::cerr << "[OSCReceiver] Error while parsing process message." << std::endl;
std::cerr << m.AddressPattern() << ": " << e.what() << std::endl;
}
}
示例12: handleMousePositionMessage
void Network::handleMousePositionMessage(const osc::ReceivedMessage& m,
const IpEndpointName& remoteEndpoint)
{
// Parse OSC message
osc::int32 port;
float x, y;
bool down;
m.ArgumentStream() >> port >> x >> y >> down >> osc::EndMessage;
PeerMap::iterator pit = m_peers.find(IpEndpointName(remoteEndpoint.address, (int)port));
if (pit != m_peers.end()) {
pit->second->setMousePosition(x, y);
pit->second->setMouseDown(down);
}
}
示例13: get_users_list
void get_users_list(const osc::ReceivedMessage& m,
const IpEndpointName& remoteEndpoint )
{
(void) remoteEndpoint; // suppress unused parameter warning
osc::ReceivedMessageArgumentStream args = m.ArgumentStream();
resultStream_ << osc::BeginMessage("/groupclient/user_list");
while( !args.Eos() )
{
const char *groupName;
const char *groupPassword;
args >> groupName >> groupPassword;
Group *group = groupServer_.FindGroup( groupName );
if(group && group->password.compare(groupPassword) == 0)
{
std::cout << "group found:" << groupName << std::endl;
Group::const_user_iterator user_iter = group->users_begin();
for(; user_iter != group->users_end(); ++user_iter )
{
User *user = *user_iter;
resultStream_ << user->name.c_str()
<< ~((osc::int32)user->privateEndpoint.address)
<< (osc::int32)user->privateEndpoint.port
<< ~((osc::int32)user->publicEndpoint.address)
<< (osc::int32)user->publicEndpoint.port
<< groupName;
std::cout << "Add userinfo:"
<< user->name.c_str()
<< ~((osc::int32)user->privateEndpoint.address)
<< (osc::int32)user->privateEndpoint.port
<< ~((osc::int32)user->publicEndpoint.address)
<< (osc::int32)user->publicEndpoint.port
<< groupName;
}
}
else
{
std::cout << "group name or gourp password is not correct:" << groupName << std::endl;
}
}
resultStream_ << osc::EndMessage;
}
示例14: handleObjectPadTextMessage
void Network::handleObjectPadTextMessage(const osc::ReceivedMessage& m,
const IpEndpointName& remoteEndpoint)
{
// Utility data structures
char buffer[1024];
osc::OutboundPacketStream ps(buffer, 1024);
// Parse OSC message
osc::Symbol uuid, text;
m.ArgumentStream() >> uuid >> text >> osc::EndMessage;
std::cerr << uuid << ", " << text << std::endl;
WidgetMap* widgets = Widget::getAll();
WidgetMap::iterator wit = widgets->find(std::string(uuid));
if (wit != widgets->end() && dynamic_cast<RoundPad*>(wit->second))
((RoundPad*)wit->second)->setCommentText(std::string(text));
}
示例15: handlePluckerMessage
void Network::handlePluckerMessage(const osc::ReceivedMessage& m,
const IpEndpointName& remoteEndpoint)
{
// Utility data structures
char buffer[1024];
osc::OutboundPacketStream ps(buffer, 1024);
// Parse OSC message
osc::Symbol uuid;
m.ArgumentStream() >> uuid >> osc::EndMessage;
std::cerr << uuid << std::endl;
WidgetMap* widgets = Widget::getAll();
WidgetMap::iterator wit = widgets->find(std::string(uuid));
if (wit != widgets->end() && dynamic_cast<Track*>(wit->second))
((Track*)wit->second)->addPlucker();
}