当前位置: 首页>>代码示例>>C++>>正文


C++ SocketClient::is_connected方法代码示例

本文整理汇总了C++中SocketClient::is_connected方法的典型用法代码示例。如果您正苦于以下问题:C++ SocketClient::is_connected方法的具体用法?C++ SocketClient::is_connected怎么用?C++ SocketClient::is_connected使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SocketClient的用法示例。


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

示例1: addr

    int  open_connection        (const String &config, const String &display)
    {
        SocketAddress addr (scim_get_default_panel_socket_address (display));

        if (m_socket.is_connected ()) close_connection ();

        bool ret;
        int count = 0;

        // Try three times.
        while (1) {
            if ((ret = m_socket.connect (addr)) == false) {
                scim_usleep (100000);
                launch_panel (config, display);
                for (int i = 0; i < 200; ++i) {
                    if (m_socket.connect (addr)) {
                        ret = true;
                        break;
                    }
                    scim_usleep (100000);
                }
            }
 
            if (ret && scim_socket_open_connection (m_socket_magic_key, String ("FrontEnd"), String ("Panel"), m_socket, m_socket_timeout))
                break;

            m_socket.close ();

            if (count++ >= 3) break;

            scim_usleep (100000);
        }

        return m_socket.get_id ();
    }
开发者ID:dancor,项目名称:scim,代码行数:35,代码来源:scim_panel_client.cpp

示例2:

    bool prepare                (int icid)
    {
        if (!m_socket.is_connected ()) return false;

        int cmd;
        uint32 data;

        if (m_send_refcount <= 0) {
            m_current_icid = icid;
            m_send_trans.clear ();
            m_send_trans.put_command (SCIM_TRANS_CMD_REQUEST);
            m_send_trans.put_data (m_socket_magic_key);
            m_send_trans.put_data ((uint32) icid);

            m_send_trans.get_command (cmd);
            m_send_trans.get_data (data);
            m_send_trans.get_data (data);
            m_send_refcount = 0;
        }

        if (m_current_icid == icid) {
            m_send_refcount ++;
            return true;
        }
        return false;
    }
开发者ID:dancor,项目名称:scim,代码行数:26,代码来源:scim_panel_client.cpp

示例3: while

    bool filter_event           ()
    {
        Transaction recv;

        if (!m_socket.is_connected () || !recv.read_from_socket (m_socket, m_socket_timeout))
            return false;

        int cmd;
        uint32 context = (uint32)(-1);

        if (!recv.get_command (cmd) || cmd != SCIM_TRANS_CMD_REPLY)
            return true;

        // No context id available, so there will be some global command.
        if (recv.get_data_type () == SCIM_TRANS_DATA_COMMAND) {
            while (recv.get_command (cmd)) {
                switch (cmd) {
                    case SCIM_TRANS_CMD_RELOAD_CONFIG:
                        m_signal_reload_config ((int)context);
                        break;
                    case SCIM_TRANS_CMD_EXIT:
                        m_signal_exit ((int)context);
                        break;
                    default:
                        break;
                }
            }
            return true;
        }

        // Now for context related command.
        if (!recv.get_data (context))
            return true;

        while (recv.get_command (cmd)) {
            switch (cmd) {
                case SCIM_TRANS_CMD_UPDATE_LOOKUP_TABLE_PAGE_SIZE:
                    {
                        uint32 size;
                        if (recv.get_data (size))
                            m_signal_update_lookup_table_page_size ((int) context, (int) size);
                    }
                    break;
                case SCIM_TRANS_CMD_LOOKUP_TABLE_PAGE_UP:
                    {
                        m_signal_lookup_table_page_up ((int) context);
                    }
                    break;
                case SCIM_TRANS_CMD_LOOKUP_TABLE_PAGE_DOWN:
                    {
                        m_signal_lookup_table_page_down ((int) context);
                    }
                    break;
                case SCIM_TRANS_CMD_TRIGGER_PROPERTY:
                    {
                        String property;
                        if (recv.get_data (property))
                            m_signal_trigger_property ((int) context, property);
                    }
                    break;
                case SCIM_TRANS_CMD_PROCESS_HELPER_EVENT:
                    {
                        String target_uuid;
                        String helper_uuid;
                        Transaction trans;
                        if (recv.get_data (target_uuid) && recv.get_data (helper_uuid) && recv.get_data (trans))
                            m_signal_process_helper_event ((int) context, target_uuid, helper_uuid, trans);
                    }
                    break; 
                case SCIM_TRANS_CMD_MOVE_PREEDIT_CARET:
                    {
                        uint32 caret;
                        if (recv.get_data (caret))
                            m_signal_move_preedit_caret ((int) context, (int) caret);
                    }
                    break;
                case SCIM_TRANS_CMD_SELECT_CANDIDATE:
                    {
                        uint32 item;
                        if (recv.get_data (item))
                            m_signal_select_candidate ((int) context, (int) item);
                    }
                    break;
                case SCIM_TRANS_CMD_PROCESS_KEY_EVENT:
                    {
                        KeyEvent key;
                        if (recv.get_data (key))
                            m_signal_process_key_event ((int) context, key);
                    }
                    break;
                case SCIM_TRANS_CMD_COMMIT_STRING:
                    {
                        WideString wstr;
                        if (recv.get_data (wstr))
                            m_signal_commit_string ((int) context, wstr);
                    }
                    break;
                case SCIM_TRANS_CMD_FORWARD_KEY_EVENT:
                    {
                        KeyEvent key;
//.........这里部分代码省略.........
开发者ID:dancor,项目名称:scim,代码行数:101,代码来源:scim_panel_client.cpp


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