Example #1
0
static PyObject* mqttv3_unsubscribeMany(PyObject* self, PyObject *args)
{
	MQTTClient c;
	PyObject* topicList;

	int count;
	char** topics;

	int i, rc = 0;

	if (!PyArg_ParseTuple(args, "kOO", &c, &topicList))
		return NULL;

	if (!PySequence_Check(topicList))
	{
		PyErr_SetString(PyExc_TypeError, "3rd parameter must be sequences");
		return NULL;
	}

	count = PySequence_Length(topicList);
	topics = malloc(count * sizeof(char*));
	for (i = 0; i < count; ++i)
		topics[i] = PyString_AsString(PySequence_GetItem(topicList, i));

	Py_BEGIN_ALLOW_THREADS rc = MQTTClient_unsubscribeMany(c, count, topics);
	Py_END_ALLOW_THREADS

	free( topics);

	return Py_BuildValue("i", rc);
}
Example #2
0
int MQTTClient_unsubscribe(MQTTClient handle, const char* topic)
{
	int rc = 0;
	char *const topics[] = {(char*)topic};
	FUNC_ENTRY;
	rc = MQTTClient_unsubscribeMany(handle, 1, topics);
	FUNC_EXIT_RC(rc);
	return rc;
}
Example #3
0
int MQTTClient_unsubscribe(MQTTClient handle, char* topic)
{
	int rc = 0;

	FUNC_ENTRY;
	rc = MQTTClient_unsubscribeMany(handle, 1, &topic);
	FUNC_EXIT_RC(rc);
	return rc;
}