void mwSession_stop(struct mwSession *s, guint32 reason) { GList *list, *l = NULL; struct mwMsgChannelDestroy *msg; g_return_if_fail(s != NULL); if(mwSession_isStopped(s) || mwSession_isStopping(s)) { g_debug("attempted to stop session that is already stopped/stopping"); return; } state(s, mwSession_STOPPING, GUINT_TO_POINTER(reason)); for(list = l = mwSession_getServices(s); l; l = l->next) mwService_stop(MW_SERVICE(l->data)); g_list_free(list); msg = (struct mwMsgChannelDestroy *) mwMessage_new(mwMessage_CHANNEL_DESTROY); msg->head.channel = MW_MASTER_CHANNEL_ID; msg->reason = reason; /* don't care if this fails, we're closing the connection anyway */ mwSession_send(s, MW_MESSAGE(msg)); mwMessage_free(MW_MESSAGE(msg)); session_buf_free(s); /* close the connection */ io_close(s); state(s, mwSession_STOPPED, GUINT_TO_POINTER(reason)); }
int CSametimeProto::LogOut() { debugLog(_T("LogOut() start")); continue_connect = false; EnterCriticalSection(&session_cs); if (session && server_connection && m_iStatus != ID_STATUS_OFFLINE && !mwSession_isStopped(session) && !mwSession_isStopping(session)) { debugLog(_T("LogOut() mwSession_stop")); mwSession_stop(session, 0); } LeaveCriticalSection(&session_cs); return 0; }