• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ chat_session_ptr类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中chat_session_ptr的典型用法代码示例。如果您正苦于以下问题:C++ chat_session_ptr类的具体用法?C++ chat_session_ptr怎么用?C++ chat_session_ptr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了chat_session_ptr类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: GetIpCommandHandler

bool GetIpCommandHandler(chat_session_ptr _client, char const* args)
{
    std::string s = "Tu IP es: " + _client->socket().remote_endpoint().address().to_string();
    _client->SendMessageClient(s);

    return true;
}
开发者ID:BackupGGCode,项目名称:telnetcom,代码行数:7,代码来源:cliManager.cpp


示例2: RunCommand

void CommandsMgr::RunCommand(chat_session_ptr _client, std::string command, bool console)
{
    const char* command_str = _strdup(command.c_str());
    char* tok = strtok((char*) command_str, " ");
    tok = strtok(NULL, " ");
    std::ostringstream args;
    while (tok != NULL)
    {
        args << " " << tok;
        tok = strtok(NULL, " ");
    }
    char* arg_f = (char*)args.str().c_str();

    memcpy ( arg_f, args.str().c_str(), strlen(args.str().c_str()) +1);
    if (strcmp(arg_f, "") == 0)
        arg_f = NULL;


    for (int32 i = 0; i < MAX_COMMANDS; ++i)
    {
        if (boost::iequals(command_str, MyComands_[i].Name))
        {
            if (!MyComands_[i].AllowConsole && console)
            {
                std::cout << "Este comando no se puede usar por consola." << std::endl;
                break;
            }

            if (!console && _client->GetSecurity() < MyComands_[i].sec)
            {
                CommandsMgr::SendMessageBoth(_client, "No tienes permisos para ejecutar este comando!");
                CommandsMgr::PSendMessageBoth(_client, "Este comando requiere permisos de: %s.", GetSecurityString(MyComands_[i].sec).c_str());
                break;
            }

            if (!MyComands_[i].handler(_client, arg_f))
            {
                CommandsMgr::SendMessageBoth(_client, "Error de sintaxis.");
                CommandsMgr::PSendMessageBoth(_client, "%s", MyComands_[i].Help.c_str());
            }

            break;
        }
    }

    // Esto manda al cliente el salto de linea e incluye TC>
    if (_client)
        _client->SendMessageClient("");

    std::cout << std::endl << "TC> ";
    command.clear();
    args.clear();
    free(tok);
}
开发者ID:BackupGGCode,项目名称:telnetcom,代码行数:54,代码来源:cliManager.cpp


示例3: handle_accept

	void handle_accept(chat_session_ptr session,const boost::system::error_code& error)
	{
		if (!error)
		{
			session->start();
		}

		start_accept();
	}
开发者ID:javawork,项目名称:tictactoe,代码行数:9,代码来源:Server.cpp


示例4: handle_accept

 void handle_accept(chat_session_ptr session,
                    const asio::error_code& error)
 {
     if (!error)
     {
         session->start();
         chat_session_ptr new_session(new chat_session(io_service_, room_));
         acceptor_.async_accept(new_session->socket(),
                                boost::bind(&chat_server::handle_accept, this, new_session,
                                            asio::placeholders::error));
     }
 }
开发者ID:barrbrain,项目名称:asio,代码行数:12,代码来源:chat_server.cpp


示例5: SendMessageBoth

bool CommandsMgr::SendMessageBoth(chat_session_ptr _client, char const* msg)
{
    if (!_client)
    {
        std::cout << msg << std::endl;
        return true;
    }

    std::string msg_ = msg;

    if (!_client->SendMessageClient(msg_))
        return false;

    return true;
}
开发者ID:BackupGGCode,项目名称:telnetcom,代码行数:15,代码来源:cliManager.cpp


示例6: SendAllHandler

bool SendAllHandler(chat_session_ptr _client, char const* args)
{
    if (!args)
        return false;

    std::string from = std::string();
    if (!_client)
        from = "Console: ";
    else
        from = _client->socket().remote_endpoint().address().to_string() + ": ";

    from += args;

    sServerGlobals->AssynSendMessageAllClients(from);

    return true;
}
开发者ID:BackupGGCode,项目名称:telnetcom,代码行数:17,代码来源:cliManager.cpp


示例7: SendHandler

bool SendHandler(chat_session_ptr _client, char const* args)
{
    if (!args)
        return false;

    char* to_ = strtok((char*)args, " ");

    char* msg_ = strtok(NULL, "");
    if (!to_ || !msg_)
        return false;

    std::string from = std::string();
    if (!_client)
        from = "Console: ";
    else
        from = _client->socket().remote_endpoint().address().to_string() + ": ";

    from += msg_;

    if (strcmp(to_, "Console") == 0)
    {
        std::cout << from;
        return true;
    }

    std::list<chat_session_ptr>::const_iterator itr = sServerGlobals->GetClientList().begin();
    bool send_ = false;
    for (; itr != sServerGlobals->GetClientList().end(); ++itr)
    {
        if ((*itr) && (*itr)->socket().is_open())
        {
            if ((*itr)->socket().remote_endpoint().address().to_string() == to_)
            {
                (*itr)->SendMessageClient(from);
                send_ = true;
            }
        }
    }

    if (!send_)
        CommandsMgr::SendMessageBoth(_client, "No se a encontrado un cliente con esa IP.");

    return true;
}
开发者ID:BackupGGCode,项目名称:telnetcom,代码行数:44,代码来源:cliManager.cpp


示例8: ComandsListHandler

bool ComandsListHandler(chat_session_ptr _client, char const* args)
{
    ListCommands* commands_ = sCommandsMgr->GetCommandsList();

    CommandsMgr::SendMessageBoth(_client, "Lista de comandos disponibles: ");

    for (int32 i = 0; commands_[i].Name != "NONE"; ++i)
    {
        if (!_client && !commands_[i].AllowConsole)
            continue;

        if (_client && _client->GetSecurity() < commands_[i].sec)
            continue;

        CommandsMgr::PSendMessageBoth(_client, "%s", commands_[i].Name.c_str());
    }

    return true;
}
开发者ID:BackupGGCode,项目名称:telnetcom,代码行数:19,代码来源:cliManager.cpp


示例9: LoginClientHandler

bool LoginClientHandler(chat_session_ptr _client, char const* args)
{
    // El !_client no deberia pasar JAMAS.
    if (!args || !_client)
        return false;

    char* pass_ = strtok((char*)args, " ");

    if (!pass_)
        return false;

    if (pass_ == sServerGlobals->AdminPass)
        _client->sec_level = SEC_ADMIN;
    else if (pass_ == sServerGlobals->ModPass)
        _client->sec_level = SEC_MODERATOR;
    else
    {
        CommandsMgr::SendMessageBoth(_client, "Contraseña incorrecta.");
        return true;
    }

    CommandsMgr::PSendMessageBoth(_client, "Se ha logeado con permisos de %s.", GetSecurityString(_client->GetSecurity()).c_str());
    return true;
}
开发者ID:BackupGGCode,项目名称:telnetcom,代码行数:24,代码来源:cliManager.cpp



注:本文中的chat_session_ptr类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ chd_file类代码示例发布时间:2022-05-31
下一篇:
C++ channel_ptr类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap