client_t *c = NULL;
buffer[0] = (uint8_t) (type | 2);
Log_debug("Whisper session %d", vt->sessions[i]);
- while (Client_iterate(&c) != NULL) {
- if (c->sessionId == vt->sessions[i]) {
- Client_send_voice(client, c, buffer, pds->offset + 1, poslen);
- break;
- }
+
+ c = Client_find_by_session(vt->sessions[i]);
+
+ if (c != NULL) {
+ Client_send_voice(client, c, buffer, pds->offset + 1, poslen);
}
}
}
break;
}
if (msg->payload.userState->has_session && msg->payload.userState->session != client->sessionId) {
- while (Client_iterate(&target) != NULL) {
- if (target->sessionId == msg->payload.userState->session)
- break;
- }
+ target = Client_find_by_session(msg->payload.userState->session);
+
if (target == NULL) {
Log_warn("Client with sessionID %d not found", msg->payload.userState->session);
break;
int i;
client_t *itr;
for (i = 0; i < msg->payload.textMessage->n_session; i++) {
- itr = NULL;
- while (Client_iterate(&itr) != NULL) {
- if (!IS_AUTH(itr))
- continue;
- if (itr->sessionId == msg->payload.textMessage->session[i]) {
- if (!itr->deaf && !itr->self_deaf) {
- Msg_inc_ref(msg);
- Client_send_message(itr, msg);
- Log_debug("Text message to session ID %d", itr->sessionId);
- }
- break;
- }
- }
+ itr = Client_find_by_session(msg->payload.textMessage->session[i]);
+
if (itr == NULL)
Log_warn("TextMessage: Session ID %d not found", msg->payload.textMessage->session[i]);
+ else if (IS_AUTH(itr) && !itr->deaf && !itr->self_deaf) {
+ Msg_inc_ref(msg);
+ Client_send_message(itr, msg);
+ Log_debug("Text message to session ID %d", itr->sessionId);
+ }
} /* for */
}
break;
if (!msg->payload.userStats->has_session)
sendPermissionDenied(client, "Not supported by uMurmur");
- while (Client_iterate(&target) != NULL) {
- if (!IS_AUTH(target))
- continue;
- if (target->sessionId == msg->payload.userStats->session)
- break;
- }
+
+ target = Client_find_by_session(msg->payload.userStats->session);
+
if (!target) /* Not found */
break;
+ if (!IS_AUTH(target)) /* Not authenticated. */
+ break;
+
/*
* Differences from Murmur:
* o Ignoring certificates intentionally
sendPermissionDenied(client, "Permission denied");
break;
}
- while (Client_iterate(&target) != NULL) {
- if (target->sessionId == msg->payload.userRemove->session)
- break;
- }
+
+ target = Client_find_by_session(msg->payload.userRemove->session);
+
if (target == NULL) {
Log_warn("Client with sessionId %d not found", msg->payload.userRemove->session);
break;