Пример #1
0
void mwSession_start(struct mwSession *s) {
  struct mwMsgHandshake *msg;
  int ret;

  g_return_if_fail(s != NULL);
  g_return_if_fail(mwSession_isStopped(s));

  if(mwSession_isStarted(s) || mwSession_isStarting(s)) {
    g_debug("attempted to start session that is already started/starting");
    return;
  }
  
  state(s, mwSession_STARTING, 0);

  msg = (struct mwMsgHandshake *) mwMessage_new(mwMessage_HANDSHAKE);
  msg->major = GUINT(property_get(s, mwSession_CLIENT_VER_MAJOR));
  msg->minor = GUINT(property_get(s, mwSession_CLIENT_VER_MINOR));
  msg->login_type = GUINT(property_get(s, mwSession_CLIENT_TYPE_ID));

  msg->loclcalc_addr = GUINT(property_get(s, mwSession_CLIENT_IP));

  if(msg->major >= 0x001e && msg->minor >= 0x001d) {
    msg->unknown_a = 0x0100;
    msg->local_host = property_get(s, mwSession_CLIENT_HOST);
  }

  ret = mwSession_send(s, MW_MESSAGE(msg));
  mwMessage_free(MW_MESSAGE(msg));

  if(ret) {
    mwSession_stop(s, CONNECTION_BROKEN);
  } else {
    state(s, mwSession_HANDSHAKE, 0);
  }
}
void MeanwhileSession::disconnect()
{
    HERE;
    if (state == mwSession_STOPPED || state == mwSession_STOPPING)
        return;

    mwSession_stop(session, ERR_SUCCESS);
}
void MeanwhileSession::slotSocketAboutToClose()
{
    HERE;

    /* TODO -error handling
    if (reason & KExtendedSocket::involuntary)
        emit serverNotification(
                QString("Lost connection with Meanwhile server"));
    */

    mwSession_stop(session, 0x00);
}
Пример #4
0
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;
}