|
|
@@ -200,6 +200,38 @@ int session_broadcast(int sid, char *msg, char *usrname, int except, int flags)
|
|
|
}
|
|
|
|
|
|
|
|
|
+int session_name(int fd, struct vcc_request *req) {
|
|
|
+ struct klist_node *n;
|
|
|
+ struct vcc_request *out;
|
|
|
+
|
|
|
+ if (unlikely(!(out = amalloc(sizeof(struct vcc_request))))) {
|
|
|
+ vcc_log("*** malloc() failed\n");
|
|
|
+
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ out->magic = htonl(VCC_MAGIC);
|
|
|
+ out->reqtype = htonl(REQ_CTL_SENAME);
|
|
|
+
|
|
|
+ if (unlikely(!(n = find_session(ntohl(req->session))))) {
|
|
|
+ out->session = htonl(-1);
|
|
|
+ vcc_send_req(find_connection(fd), out);
|
|
|
+
|
|
|
+ vcc_log("%d sends a bad session number. \n", fd);
|
|
|
+
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ out->session = req->session;
|
|
|
+ strcpy(out->msg, n->usrname);
|
|
|
+ vcc_send_req(find_connection(fd), out);
|
|
|
+
|
|
|
+ vcc_log("sename: %s sent to %d\n", n->usrname, fd);
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
int send_sessions(int fd) {
|
|
|
struct klist_node *c, *n;
|
|
|
struct vcc_request *req;
|