Exemplo n.º 1
0
void SessionManager::deliverPacket(InPacket &in)
{
	ICQ_STR to, from;
	uint8 online;
	uint16 cmd;

	in >> to >> from >> online >> cmd;

	PACKET p;
	p.to = to.text;
	p.from = from.text;
	p.cmd = cmd;
	p.online = online;
	p.data = in.cursor;
	p.dataLen = in.getBytesLeft();

	if (strchr(to.text, '@')) {
		s2s->deliver(&p);
		return;
	}

	Session *s = sessionHash.get(to.text);
	Client *client = NULL;

	if (s)
		client = s->client;
	else if (!online) {
		ICQ_LOG("%s is offline, bounce it\n", to.text);
		client = chooseClient();
	}

	if (client)
		client->deliver(&p);
}
Exemplo n.º 2
0
void ICQMain::onPacketReceived(const char *from, uint16 cmd, InPacket &in)
{
	ClientSession *s = sessionHash->get(from);
	if (!s)
		return;

	PACKET p;
	p.cmd = cmd;
	p.data = in.cursor;
	p.dataLen = in.getBytesLeft();
	p.from = NULL;
	p.to = NULL;

	postEvent(EV_S_OUT, s, &p);
}
Exemplo n.º 3
0
void ICQMain::addSession(ClientSession *s, InPacket &in)
{
	PACKET p;
	p.cmd = CMD_LOGIN;
	p.data = in.cursor;
	p.dataLen = in.getBytesLeft();
	p.from = NULL;
	p.to = NULL;

	// Select an event queue
	s->queue = selectQueue();
	// Increase reference count, so that we should not be delete after processed
	s->addRef();
	// Put it to the hash
	sessionHash->put(s);

	postEvent(EV_SESSION, s, &p);
}