mirror of
https://github.com/eclipse/mosquitto.git
synced 2025-05-08 16:52:13 +08:00
Don't generate client ids in v5 mode.
This commit is contained in:
parent
fda66e8311
commit
5073d83bf8
@ -1011,7 +1011,7 @@ int client_id_generate(struct mosq_config *cfg, const char *id_base)
|
||||
return 1;
|
||||
}
|
||||
snprintf(cfg->id, strlen(cfg->id_prefix)+10, "%s%d", cfg->id_prefix, getpid());
|
||||
}else if(!cfg->id){
|
||||
}else if(!cfg->id && (cfg->protocol_version == MQTT_PROTOCOL_V31 || cfg->protocol_version == MQTT_PROTOCOL_V311)){
|
||||
hostname[0] = '\0';
|
||||
gethostname(hostname, 256);
|
||||
hostname[255] = '\0';
|
||||
|
@ -48,7 +48,7 @@ int my_publish(struct mosquitto *mosq, int *mid, const char *topic, int payloadl
|
||||
}
|
||||
|
||||
|
||||
void my_connect_callback(struct mosquitto *mosq, void *obj, int result)
|
||||
void my_connect_callback(struct mosquitto *mosq, void *obj, int result, int flags, const mosquitto_property *properties)
|
||||
{
|
||||
int rc = MOSQ_ERR_SUCCESS;
|
||||
|
||||
@ -262,7 +262,7 @@ int main(int argc, char *argv[])
|
||||
if(cfg.debug){
|
||||
mosquitto_log_callback_set(mosq, my_log_callback);
|
||||
}
|
||||
mosquitto_connect_callback_set(mosq, my_connect_callback);
|
||||
mosquitto_connect_v5_callback_set(mosq, my_connect_callback);
|
||||
mosquitto_disconnect_v5_callback_set(mosq, my_disconnect_callback);
|
||||
mosquitto_publish_callback_set(mosq, my_publish_callback);
|
||||
|
||||
|
@ -26,7 +26,7 @@ extern int status;
|
||||
extern struct mosq_config cfg;
|
||||
|
||||
|
||||
void my_connect_callback(struct mosquitto *mosq, void *obj, int result);
|
||||
void my_connect_callback(struct mosquitto *mosq, void *obj, int result, int flags, const mosquitto_property *properties);
|
||||
void my_disconnect_callback(struct mosquitto *mosq, void *obj, int rc, const mosquitto_property *properties);
|
||||
void my_publish_callback(struct mosquitto *mosq, void *obj, int mid);
|
||||
void my_log_callback(struct mosquitto *mosq, void *obj, int level, const char *str);
|
||||
|
@ -85,7 +85,7 @@ void my_message_callback(struct mosquitto *mosq, void *obj, const struct mosquit
|
||||
}
|
||||
}
|
||||
|
||||
void my_connect_callback(struct mosquitto *mosq, void *obj, int result, int flags)
|
||||
void my_connect_callback(struct mosquitto *mosq, void *obj, int result, int flags, const mosquitto_property *properties)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -281,7 +281,7 @@ int main(int argc, char *argv[])
|
||||
mosquitto_log_callback_set(mosq, my_log_callback);
|
||||
mosquitto_subscribe_callback_set(mosq, my_subscribe_callback);
|
||||
}
|
||||
mosquitto_connect_with_flags_callback_set(mosq, my_connect_callback);
|
||||
mosquitto_connect_v5_callback_set(mosq, my_connect_callback);
|
||||
mosquitto_message_callback_set(mosq, my_message_callback);
|
||||
|
||||
rc = client_connect(mosq, &cfg);
|
||||
|
Loading…
x
Reference in New Issue
Block a user