示例#1
0
void ChatMessageLib::sendChatRoomMessage(Channel* channel, BString galaxy, BString sender, BString message) const
{
    ChatAvatarIdList::iterator iter = channel->getUserList()->begin();

#ifdef DISP_REAL_FIRST_NAME
#else
    sender.toLower();
#endif

    // Check ignore list.
    BString loweredName = sender;
    loweredName.toLower();
    uint32 loweredNameCrc = loweredName.getCrc();

    while (iter != channel->getUserList()->end())
    {
        // If sender present at recievers ignore list, don't send.
        if ((*iter)->getPlayer()->checkIgnore(loweredNameCrc))
        {
            // Ignore player
        }
        else
        {

            DispatchClient* client = (*iter)->getPlayer()->getClient();

            if (client == NULL)
            {
                LOG(warning) << "sendChatRoomMessage: Client not found for channel " <<  channel->getId();
            }
            else
            {
                gMessageFactory->StartMessage();
                gMessageFactory->addUint32(opChatRoomMessage);

                gMessageFactory->addString(SWG);
                gMessageFactory->addString(galaxy);
                gMessageFactory->addString(sender);

                gMessageFactory->addUint32(channel->getId());
                gMessageFactory->addString(message);
                gMessageFactory->addUint32(0);
                Message* response = gMessageFactory->EndMessage();
                client->SendChannelA(response, client->getAccountId(), CR_Client, 5);

            }
        }
        ++iter;
    }
}
示例#2
0
void ZoneServer::_connectToConnectionServer(void)
{
	ProcessAddress processAddress;
	memset(&processAddress, 0, sizeof(ProcessAddress));

	// Query the DB to find out who this is.
	// setup our databinding parameters.
	DataBinding* binding = mDatabase->CreateDataBinding(5);
	binding->addField(DFT_uint32, offsetof(ProcessAddress, mType), 4);
	binding->addField(DFT_string, offsetof(ProcessAddress, mAddress), 16);
	binding->addField(DFT_uint16, offsetof(ProcessAddress, mPort), 2);
	binding->addField(DFT_uint32, offsetof(ProcessAddress, mStatus), 4);
	binding->addField(DFT_uint32, offsetof(ProcessAddress, mActive), 4);

	// Execute our statement
	DatabaseResult* result = mDatabase->ExecuteSynchSql("SELECT id, address, port, status, active FROM config_process_list WHERE name='connection';");
	uint32 count = static_cast<uint32>(result->getRowCount());

	// If we found them
	if (count == 1)
	{
		// Retrieve our routes and add them to the map.
		result->GetNextRow(binding, &processAddress);
	}

	// Delete our DB objects.
	mDatabase->DestroyDataBinding(binding);
	mDatabase->DestroyResult(result);

	// Now connect to the ConnectionServer
	DispatchClient* client = new DispatchClient();
	mRouterService->Connect(client, processAddress.mAddress, processAddress.mPort);

	// Send our registration message
	gMessageFactory->StartMessage();
	gMessageFactory->addUint32(opClusterRegisterServer);
	gMessageFactory->addString(mZoneName);

	Message* message = gMessageFactory->EndMessage();
	client->SendChannelA(message, 0, CR_Connection, 1);
}