bool AcceptedSessionMgr::AddSession(Session* pSession) { if(NULL == pSession) { LOG_DEBUG( "accepted session is null" ); return false; } Session2IdentMap::iterator iter = m_Session2IdentMap.find(pSession); if(m_Session2IdentMap.end() != iter) { LOG_DEBUG( "accepted session all ready exists " ); return false; } LOG_DEBUG("******add new accepted session . addr :" << pSession); uint64_t iIdent = GetNewIdent(); m_Ident2SessionMap[iIdent] = pSession; m_Session2IdentMap[pSession] = iIdent; m_iCurAcceptedSessionNum--; LOG_DEBUG("GetCurAcceptedNum() : " << GetCurAcceptedNum()); return true; }
/* ARGSUSED */ void SetCommand(Widget w, ResCommand command, char *msg) { XClientMessageEvent client_event; Display *dpy = XtDisplay(w); if (msg == NULL) { /* "Click the mouse pointer on any toolkit client" */ msg = res_labels[6]; } SetMessage(global_screen_data.info_label, msg, "Click the mouse pointer on any toolkit client"); if (global_client.window == None) { if ( (global_client.window = GetClientWindow(w, NULL, NULL)) == None ) { return; } } /* printf("[SetCommand] global_client.window: %d 0x%x\n", */ /* global_client.window, */ /* global_client.window); */ global_client.ident = GetNewIdent(); global_client.command = command; global_client.atom = atom_comm; BuildHeader(&(global_client)); if (!XtOwnSelection(w, global_client.atom, CurrentTime, ConvertCommand, LoseSelection, SelectionDone)) { /* "Unable to own the Resource/Attribute Selection" */ SetMessage(global_screen_data.info_label, res_labels[7], "Unable to own the Resource/Attribute Selection"); } client_event.window = global_client.window; client_event.type = ClientMessage; client_event.message_type = atom_resource_editor; client_event.format = EDITRES_SEND_EVENT_FORMAT; client_event.data.l[0] = XtLastTimestampProcessed(dpy); client_event.data.l[1] = global_client.atom; client_event.data.l[2] = (long) global_client.ident; client_event.data.l[3] = global_effective_protocol_version; global_error_code = NO_ERROR; /* Reset Error code. */ global_old_error_handler = XSetErrorHandler(HandleXErrors); global_serial_num = NextRequest(dpy); XSendEvent(dpy, global_client.window, FALSE, (long)0, (XEvent*)&client_event); XSync(dpy, FALSE); XSetErrorHandler(global_old_error_handler); if (global_error_code == NO_WINDOW) { char error_buf[BUFSIZ]; global_error_code = NO_ERROR; /* Reset Error code. */ sprintf(error_buf, "The communication window with%s%s.", " application is no longer available\n", "Please select a new widget tree"); global_client.window = None; SetCommand(w, LocalSendWidgetTree, error_buf); return; } TellUserAboutMessage(global_screen_data.info_label, command); global_client.timeout = XtAppAddTimeOut(XtWidgetToApplicationContext(w), CLIENT_TIME_OUT, ClientTimedOut, (XtPointer)w); startWait(XtWidgetToApplicationContext(w), CLIENT_TIME_OUT / 1000); } /* SetCommand() */