Esempio n. 1
0
void ChatChannel::insertUser(QString channelId, shared_ptr<ChatUser> user)
{
  if (channelId == _id)
  {
    _users.insert(user->id(), user);
    emit userConnected(user);
    emit usersUpdated();
  }
}
Esempio n. 2
0
void ChatCore::connection_established() {
    worker = std::unique_ptr<Worker>(
                new Worker(this, &this->msg_queue, &this->mutex));

//    connect(worker.get(), SIGNAL(authorization_failed()),
//            SLOT(authorization_failed()));
    connect(worker.get(), SIGNAL(online_users(QString)),
            SIGNAL(onlineUsers(QString)));
    connect(worker.get(), SIGNAL(msg_from_user(QString, QString)),
            SIGNAL(newMess(QString, QString)));
    connect(worker.get(), SIGNAL(user_connected(QString)),
            SIGNAL(userConnected(QString)));
    connect(worker.get(), SIGNAL(user_disconnected(QString)),
            SIGNAL(userDisconnected(QString)));


    worker->start();
    emit connected("Connected successfully");
}
Esempio n. 3
0
void SessionState::joinUser(Client *user, bool host)
{
	user->setSession(this);
	_clients.append(user);

	// Make sure the ID is reserved (hosting user gets to choose their own)
	_userids.reserve(user->id());

	connect(user, SIGNAL(barrierLocked()), this, SLOT(userBarrierLocked()));
	connect(user, SIGNAL(disconnected(Client*)), this, SLOT(removeUser(Client*)));
	connect(this, SIGNAL(newCommandsAvailable()), user, SLOT(sendAvailableCommands()));

	MessagePtr joinmsg(new protocol::UserJoin(user->id(), user->username()));

	if(host) {
		Q_ASSERT(!_mainstream.hasSnapshot());
		// Send login message directly, since the distributable login
		// notification will be part of the initial snapshot.
		user->sendDirectMessage(joinmsg);

		// Request initial session content. This creates a snapshot point for the session
		// and upgrades the client to full session state
		user->requestSnapshot(false);
	} else {
		connect(this, SIGNAL(snapshotCreated()), user, SLOT(snapshotNowAvailable()));
		addToCommandStream(joinmsg);
	}

	// Give op to this user if it is the only one here
	if(userCount() == 1)
		user->grantOp();
	else if(_lockdefault)
		user->lockUser();
	else
		user->sendUpdatedAttrs(); // make sure up to date attrs are always sent

	_lastEventTime = QDateTime::currentDateTime();

	logger::info() << user << "Joined session";
	emit userConnected(this, user);
}