本文整理汇总了C++中CChatChannel::MemberTalk方法的典型用法代码示例。如果您正苦于以下问题:C++ CChatChannel::MemberTalk方法的具体用法?C++ CChatChannel::MemberTalk怎么用?C++ CChatChannel::MemberTalk使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CChatChannel
的用法示例。
在下文中一共展示了CChatChannel::MemberTalk方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: EventMsg
void CChat::EventMsg( CClient * pClient, const NCHAR * pszText, int len, CLanguageID lang ) // Text from a client
{
ADDTOCALLSTACK("CChat::EventMsg");
// ARGS:
// len = length of the pszText string in NCHAR's.
//
CChatChanMember * pMe = pClient;
ASSERT(pMe);
// newer clients do not send the 'chat button' packet, leading to all kinds of problems
// with the client not being initialised properly for chat (e.g. blank name and exceptions
// when leaving a chat room) - if chat is not active then we must simulate the chat button
// event before processing the chat message
if (pMe->IsChatActive() == false)
{
// simulate the chat button being clicked
pClient->Event_ChatButton(NULL);
// if chat isn't active now then cancel processing the event
if (pMe->IsChatActive() == false)
return;
}
CChatChannel * pChannel = pMe->GetChannel();
TCHAR szText[MAX_TALK_BUFFER * 2];
CvtNUNICODEToSystem( szText, sizeof(szText), pszText, len );
// The 1st character is a command byte, join channel, private message someone, etc etc
TCHAR * szMsg = szText+1;
switch ( szText[0] )
{
case 'a': // a = client typed a plain message in the text entry area
{
// Check for a chat command here
if (szMsg[0] == '/')
{
DoCommand(pMe, szMsg + 1);
break;
}
if (!pChannel)
{
not_in_a_channel:
pMe->SendChatMsg(CHATMSG_MustBeInAConference);
return;
}
// Not a chat command, must be speech
pChannel->MemberTalk(pMe, szMsg, lang);
break;
};
case 'A': // A = change the channel password
{
if (!pChannel)
goto not_in_a_channel;
pChannel->ChangePassword(pMe, szMsg);
break;
};
case 'b': // b = client joining an existing channel
{
// Look for second double quote to separate channel from password
size_t i = 1;
for (; szMsg[i] != '\0'; i++)
if (szMsg[i] == '"')
break;
szMsg[i] = '\0';
TCHAR * pszPassword = szMsg + i + 1;
if (pszPassword[0] == ' ') // skip leading space if any
pszPassword++;
JoinChannel( pMe, szMsg + 1, pszPassword);
break;
};
case 'c': // c = client creating (and joining) new channel
{
TCHAR * pszPassword = NULL;
size_t iMsgLength = strlen(szMsg);
for (size_t i = 0; i < iMsgLength; i++)
{
if (szMsg[i] == '{') // OK, there's a password here
{
szMsg[i] = 0;
pszPassword = szMsg + i + 1;
size_t iPasswordLength = strlen(pszPassword);
for (i = 0; i < iPasswordLength; i++)
{
if (pszPassword[i] == '}')
{
pszPassword[i] = '\0';
break;
}
}
break;
}
}
CreateJoinChannel(pMe, szMsg, pszPassword);
break;
};
case 'd': // d = (/rename x) rename conference
{
if (!pChannel)
//.........这里部分代码省略.........
示例2: Action
void CChat::Action(CClient *pClient, const NCHAR *pszText, int len, CLanguageID lang)
{
ADDTOCALLSTACK("CChat::Action");
// ARGS:
// len = length of the pszText string in NCHAR's.
if ( !(g_Cfg.m_iFeatureT2A & FEATURE_T2A_CHAT) )
return;
CChatMember *pMe = static_cast<CChatMember *>(pClient);
CChatChannel *pChannel = pMe->GetChannel();
TCHAR szFullText[MAX_TALK_BUFFER];
CvtNUNICODEToSystem(szFullText, sizeof(szFullText), pszText, len);
TCHAR *pszMsg = szFullText + 1;
switch ( szFullText[0] ) // the 1st character is a command byte (join channel, leave channel, etc)
{
case CHATACT_ChangeChannelPassword: // client shortcut: /pw
{
if ( !pChannel )
goto NoConference;
pChannel->ChangePassword(pMe, pszMsg);
break;
}
case CHATACT_LeaveChannel:
{
if ( !pChannel )
goto NoConference;
pChannel->RemoveMember(pMe);
break;
}
case CHATACT_LeaveChat:
{
if ( pChannel )
pChannel->RemoveMember(pMe);
break;
}
case CHATACT_ChannelMessage:
{
if ( pChannel )
{
pChannel->MemberTalk(pMe, pClient->m_UseNewChatSystem ? szFullText : pszMsg, lang);
break;
}
NoConference:
pMe->SendChatMsg(CHATMSG_MustBeInAConference);
return;
}
case CHATACT_JoinChannel: // client shortcut: /conf
{
// Look for second double quote to separate channel from password
size_t i = 1;
for ( ; pszMsg[i] != '\0'; i++ )
{
if ( pszMsg[i] == '"' )
break;
}
pszMsg[i] = '\0';
TCHAR *pszPassword = pszMsg + i + 1;
if ( pszPassword[0] == ' ' ) // skip whitespaces
pszPassword++;
JoinChannel(pszMsg + 1, pszPassword, pMe);
break;
}
case CHATACT_CreateChannel: // client shortcut: /newconf
{
TCHAR *pszPassword = NULL;
size_t iMsgLength = strlen(pszMsg);
for ( size_t i = 0; i < iMsgLength; i++ )
{
if ( pszMsg[i] == '{' ) // there's a password here
{
pszMsg[i] = 0;
pszPassword = pszMsg + i + 1;
size_t iPasswordLength = strlen(pszPassword);
for ( i = 0; i < iPasswordLength; i++ )
{
if ( pszPassword[i] == '}' )
{
pszPassword[i] = '\0';
break;
}
}
break;
}
}
if ( CreateChannel(pszMsg, pszPassword, pMe) )
JoinChannel(pszMsg, pszPassword, pMe);
break;
}
case CHATACT_RenameChannel: // client shortcut: /rename
{
if ( !pChannel )
goto NoConference;
pMe->RenameChannel(pszMsg);
break;
//.........这里部分代码省略.........