|
|
@@ -69,6 +69,20 @@ int relay_new_msg(int fd, void *t) {
|
|
|
}
|
|
|
|
|
|
|
|
|
+int relay_send_packet(int fd, const char *restrict buf,
|
|
|
+ const struct vcc_relay_header *restrict hdr, int size) {
|
|
|
+ struct vcc_relay_header req;
|
|
|
+
|
|
|
+ memcpy(&req, hdr, sizeof(struct vcc_relay_header));
|
|
|
+ req.size = htonl(sizeof(struct vcc_relay_header) + size);
|
|
|
+
|
|
|
+ write(fd, &req, sizeof(struct vcc_relay_header));
|
|
|
+ write(fd, buf, size);
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
int send_to(int fd, const char *restrict msg, int is_only_visible,
|
|
|
const struct vcc_relay_header *restrict hdr, int size) {
|
|
|
struct vcc_relay_header req;
|
|
|
@@ -79,16 +93,9 @@ int send_to(int fd, const char *restrict msg, int is_only_visible,
|
|
|
req.reqtype = htonl(REQ_REL_NEW);
|
|
|
req.uid = htonl(is_only_visible);
|
|
|
req.session = 0;
|
|
|
- req.size = htonl(sizeof(struct vcc_relay_header) + size);
|
|
|
|
|
|
strncpy(req.usrname, hdr->usrname, USRNAME_SIZE);
|
|
|
-
|
|
|
- /* direct writes here
|
|
|
- * vcc_send_req(n, req);
|
|
|
- * */
|
|
|
-
|
|
|
- write(fd, &req, sizeof(struct vcc_relay_header));
|
|
|
- write(fd, msg, size);
|
|
|
+ relay_send_packet(fd, msg, &req, size);
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
@@ -98,6 +105,8 @@ int relay_send_to(const char *restrict msg, const char *restrict visible, int ex
|
|
|
struct klist_node *n;
|
|
|
struct user *u;
|
|
|
|
|
|
+ vcc_write_all();
|
|
|
+
|
|
|
for (n = logged_users.next; n != &logged_users; n = n->next) {
|
|
|
u = n->data;
|
|
|
|