Example #1
0
bool CIRCSock::OnJoinMessage(CJoinMessage& Message) {
    const CNick& Nick = Message.GetNick();
    CString sChan = Message.GetParam(0);
    CChan* pChan = nullptr;

    if (Nick.NickEquals(GetNick())) {
        m_pNetwork->AddChan(sChan, false);
        pChan = m_pNetwork->FindChan(sChan);
        if (pChan) {
            pChan->Enable();
            pChan->SetIsOn(true);
            PutIRC("MODE " + sChan);
        }
    } else {
        pChan = m_pNetwork->FindChan(sChan);
    }

    if (pChan) {
        pChan->AddNick(Nick.GetNickMask());
        Message.SetChan(pChan);
        IRCSOCKMODULECALL(OnJoinMessage(Message), NOTHING);

        if (pChan->IsDetached()) {
            return true;
        }
    }

    return false;
}
Example #2
0
bool CClient::OnJoinMessage(CJoinMessage& Message) {
    CString sChans = Message.GetTarget();
    CString sKeys = Message.GetKey();

    VCString vsChans;
    sChans.Split(",", vsChans, false);
    sChans.clear();

    VCString vsKeys;
    sKeys.Split(",", vsKeys, true);
    sKeys.clear();

    for (unsigned int a = 0; a < vsChans.size(); a++) {
        Message.SetTarget(vsChans[a]);
        Message.SetKey((a < vsKeys.size()) ? vsKeys[a] : "");
        if (m_pNetwork) {
            // May be nullptr.
            Message.SetChan(m_pNetwork->FindChan(vsChans[a]));
        }
        bool bContinue = false;
        NETWORKMODULECALL(OnUserJoinMessage(Message), m_pUser, m_pNetwork, this,
                          &bContinue);
        if (bContinue) continue;

        CString sChannel = Message.GetTarget();
        CString sKey = Message.GetKey();

        if (m_pNetwork) {
            CChan* pChan = m_pNetwork->FindChan(sChannel);
            if (pChan) {
                if (pChan->IsDetached())
                    pChan->AttachUser(this);
                else
                    pChan->JoinUser(sKey);
                continue;
            } else if (!sChannel.empty()) {
                pChan = new CChan(sChannel, m_pNetwork, false);
                if (m_pNetwork->AddChan(pChan)) {
                    pChan->SetKey(sKey);
                }
            }
        }

        if (!sChannel.empty()) {
            sChans += (sChans.empty()) ? sChannel : CString("," + sChannel);

            if (!vsKeys.empty()) {
                sKeys += (sKeys.empty()) ? sKey : CString("," + sKey);
            }
        }
    }

    Message.SetTarget(sChans);
    Message.SetKey(sKeys);

    return sChans.empty();
}
Example #3
0
CConnectionEventBase* CIRCEventFactory::createJoinMessageEvent(
        const CIRCResponseData& message) const
{
    // Eventの作成
    CStreamEvent<CJoinMessage>* event = new CStreamEvent<CJoinMessage>(myEVT_THREAD_STREAM_CH_JOIN);
    CJoinMessage* log = new CJoinMessage();
    log->setServiceId(m_connectionId);
    log->setChannelName(message.m_body);
    log->setUserName(message.m_username);
    event->setServiceLog(log);

    return event;
}
Example #4
0
TEST(MessageTest, Join) {
	CJoinMessage msg;
	msg.Parse(":nick JOIN #chan");
	EXPECT_EQ("nick", msg.GetNick().GetNick());
	EXPECT_EQ("JOIN", msg.GetCommand());
	EXPECT_EQ("#chan", msg.GetTarget());
	EXPECT_EQ(CMessage::Type::Join, msg.GetType());

	EXPECT_EQ(":nick JOIN #chan", msg.ToString());
}
Example #5
0
// チャンネル参加ストリーム受信時
void CMainWindow::onJoinStream(CStreamEvent<CJoinMessage>& event)
{
    CChatServiceBase* service = m_serviceHolder->getService(
            event.getConnectionId());

    // 処理待ちに追加
    CJoinMessage* log = event.getServiceLog();
    service->onGetJoinStream(log->getChannelName(), log->getUserName());

    m_logHolder->pushLog(event.getServiceLog());
    service->addLog(event.getServiceLog());

    // 表示の更新
    m_view->displayLogs(m_logHolder->getLogs(), m_serviceHolder); // ログペイン
    if (log->getChannelName() == service->getCurrentChannel()
            && m_serviceHolder->getCurrentServiceId()
                    == event.getConnectionId()){

        m_view->addMessage(event.getServiceLog());
        updateMemberView(event.getConnectionId(), log->getChannelName());
    }
}
Example #6
0
 void OnJoinMessage(CJoinMessage& Message) override {
     const CNick& Nick = Message.GetNick();
     CChan& Channel = *Message.GetChan();
     AddBuffer(Channel, Nick.GetNickMask() + " joined", &Message.GetTime(),
               Message.GetTags());
 }
Example #7
0
	void OnJoinMessage(CJoinMessage& msg) override { vsHooks.push_back("OnJoinMessage"); vsMessages.push_back(msg.ToString()); vNetworks.push_back(msg.GetNetwork()); vChannels.push_back(msg.GetChan()); }