|
|
@@ -58,7 +58,7 @@ int relay_new_msg(int fd, void *t) {
|
|
|
read_until(fd, msg, len);
|
|
|
|
|
|
if (!*req->visible)
|
|
|
- relay_broadcast(msg, fd, req);
|
|
|
+ relay_group_broadcast(msg, fd, req);
|
|
|
else
|
|
|
/* only send to somebody */
|
|
|
relay_send_to(msg, req->visible, fd, req);
|
|
|
@@ -152,3 +152,29 @@ int relay_broadcast(const char *restrict msg, int expect_fd, const struct vcc_re
|
|
|
}
|
|
|
|
|
|
|
|
|
+int relay_group_broadcast(const char *restrict msg, int expect_fd, const struct vcc_relay_header *restrict hdr) {
|
|
|
+ struct klist_node *session, *n;
|
|
|
+ int i, len;
|
|
|
+
|
|
|
+ vcc_write_all();
|
|
|
+ len = strlen(msg);
|
|
|
+
|
|
|
+ if (!hdr->session)
|
|
|
+ return relay_broadcast(msg, expect_fd, hdr);
|
|
|
+
|
|
|
+ if (!(session = find_session(ntohl(hdr->session))))
|
|
|
+ return 1;
|
|
|
+
|
|
|
+ for (n = session->session->next; n != session->session; n = n->next) {
|
|
|
+ if (n->value == expect_fd)
|
|
|
+ continue;
|
|
|
+
|
|
|
+ send_to(n->value, msg, 0, hdr, len);
|
|
|
+ i++;
|
|
|
+ }
|
|
|
+
|
|
|
+ vcc_log("Relay group message sent to %d users. \n", i);
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+
|