/*! Creates a new private conference and invites additional attendees. The conference will get a random password. JSON Parameters: - participants (Array with fingerprints) */ bool ConferenceModule::Private::processJsonConferenceCreate(TcpSocketHandler &socket, const TcpProtocol::RequestHeader &header, const QVariant &data) { auto json = data.toMap(); auto participants = json.value("participants").toList(); auto server = _pOwner->_serverBase; auto selfInfo = socket.getClientInfo(); // Create invisible channel with random password. auto channel = server->createChannel(); if (!server->joinChannel(selfInfo->id, channel->id)) { QVariantMap m; m["status"] = 500; m["error_message"] = "Can not create channel."; return socket.sendJsonResponse(header, m); } // Invite participants. foreach (auto o, participants) { auto fingerprint = o.toByteArray(); auto sock = server->findSocket(fingerprint); if (sock) { QVariantMap m; m["method"] = "/conference/notify/invite"; m["initiator"] = socket._key.fingerprint(); m["channel"] = channel->toVariant(); sock->sendJsonPackage(m); } }
int HandleIOProcessTCPServer::threadrun(void * pBuf) { while(TRUE) { // 等待网络事件 int nIndex = ::WSAWaitForMultipleEvents(nSocketCount+1,events, FALSE, WSA_INFINITE, FALSE); nIndex = nIndex - WSA_WAIT_EVENT_0; // 查看受信的事件对象 for(int i=nIndex; i<nSocketCount + 1; i++) { nIndex = ::WSAWaitForMultipleEvents(1, &events[i], TRUE, 1000, FALSE); if(nIndex == WSA_WAIT_FAILED || nIndex == WSA_WAIT_TIMEOUT) { continue; } else { if(i == 0) // events[0]受信,重建数组 { RebuildEventArray(); // 如果没有客户I/O要处理了,则本线程退出 if(nSocketCount == 0||m_exitCode==1) { DestroyAllSocket(); _endthreadex(0); return 0; } ::WSAResetEvent(events[0]); } else// 处理网络事件 { // 查找对应的套节字对象指针,调用HandleIO处理网络事件 //nIndex-WSA_WAIT_EVENT_0 //WSA_MAXIMUM_WAIT_EVENTS PSOCKET_OBJ pSocket = (PSOCKET_OBJ)findSocket(events[i]); if(pSocket != NULL) { if(!HandleIO(pSocket)) RebuildEventArray(); } else printf(" Unable to find socket object \n "); } } } } }