Esempio n. 1
0
void RangerAsebaBridge::emit(int event, vector<int> args) {
    UserMessage::DataVector data;
    for (vector<int>::iterator it = args.begin() ; it != args.end(); ++it) {data.push_back(*it);}
    UserMessage userMessage(event, data);
    userMessage.serialize(targetStream);
    targetStream->flush();
}
Esempio n. 2
0
bool HttpDashelTarget::sendEvent(const std::vector<std::string>& args)
{
	if(args.empty()) {
		return false;
	}

	size_t eventPos;

	if(interface->getProgram().getCommonDefinitions().events.contains(UTF8ToWString(args[0]), &eventPos)) {
		try {
			// build event and emit
			UserMessage::DataVector data;
			for(size_t i = 1; i < args.size(); ++i) {
				data.push_back(atoi(args[i].c_str()));
			}
			UserMessage userMessage(eventPos, data);
			userMessage.serialize(stream);
			stream->flush();
		} catch(Dashel::DashelException e) {
			if(interface->isVerbose()) {
				cerr << "Target " << address << " failed to send event message to stream: " << e.what() << endl;
			}
			return false;
		}

		return true;
	} else {
		if(interface->isVerbose()) {
			cerr << "Target " << address << " failed to send event: No event " << args[0] << endl;
		}
		return false;
	}
}
Esempio n. 3
0
void RangerAsebaBridge::emit(int event, const vector<string>& args)
{
    // build event and emit
    UserMessage::DataVector data;
    for (size_t i=2; i<args.size(); ++i)
        data.push_back(atoi(args[i].c_str()));
    UserMessage userMessage(event, data);
    userMessage.serialize(targetStream);
    targetStream->flush();
}
Esempio n. 4
0
void DashelInterface::sendEvent(const char * event, const int * args, int argsNumber) {
  size_t pos;
  if (!commonDefinitions.events.contains(widen(event), &pos)) {
    fprintf(stderr, "event %s is unknown\n", event);
    return;
  }

  // build event and emit
  UserMessage::DataVector data;
  for (int i=0; i<argsNumber; ++i)
    data.push_back(args[i]);
  UserMessage userMessage(pos, data);
  userMessage.serialize(stream);
  stream->flush();
}
Esempio n. 5
0
 void HttpInterface::sendEvent(const std::string nodeName, const strings& args)
 {
     size_t eventPos;
     
     if (commonDefinitions.events.contains(UTF8ToWString(args[0]), &eventPos))
     {
         // build event and emit
         UserMessage::DataVector data;
         for (size_t i=1; i<args.size(); ++i)
             data.push_back(atoi(args[i].c_str()));
         UserMessage userMessage(eventPos, data);
         userMessage.serialize(asebaStream);
         asebaStream->flush();
     }
     else if (verbose)
         cerr << "sendEvent " << nodeName << ": no event " << args[0] << endl;
 }