Ejemplo n.º 1
0
bool CMediaSession::initSGSClient()
{
    LOGI("CMediaSession::initSGSClient(), begin");

    mContext = sgs_ctx_create_ex(mHost.c_str(), mPort, (void *)this, register_fd_cb, unregister_fd_cb);
    if (!mContext) {
        LOGE("CMediaSession::initSGSClient(), failed to sgs_ctx_create");
        return false;
    }

    sgs_ctx_set_channel_joined_cb(mContext, channel_joined_cb);
    sgs_ctx_set_channel_left_cb(mContext, channel_left_cb);
    sgs_ctx_set_channel_recv_msg_cb(mContext, channel_recv_msg_cb);
    sgs_ctx_set_disconnected_cb(mContext, disconnected_cb);
    sgs_ctx_set_logged_in_cb(mContext, logged_in_cb);
    sgs_ctx_set_login_failed_cb(mContext, login_failed_cb);
    sgs_ctx_set_reconnected_cb(mContext, reconnected_cb);
    sgs_ctx_set_recv_msg_cb(mContext, recv_msg_cb);

    mConnection = sgs_connection_create(mContext);
    if (!mConnection) {
        LOGE("CMediaSession::initSGSClient(), failed to sgs_connection_create");
        return false;
    }

    int ret = sgs_connection_login(mConnection, mName.c_str(), mPassword.c_str());
    if (ret != 0) {
        LOGE("CMediaSession::initSGSClient(), failed to sgs_connection_login");
        return false;
    }

    return true;
}
Ejemplo n.º 2
0
void loadContext(sgs_context *context)
{
    sgs_ctx_set_channel_joined_cb(context, channel_joined_cb);
    sgs_ctx_set_channel_left_cb(context, channel_left_cb);
    sgs_ctx_set_channel_recv_msg_cb(context, channel_recv_msg_cb);
    sgs_ctx_set_disconnected_cb(context, disconnected_cb);
    sgs_ctx_set_logged_in_cb(context, logged_in_cb);
    sgs_ctx_set_login_failed_cb(context, login_failed_cb);
    sgs_ctx_set_reconnected_cb(context, reconnected_cb);
    sgs_ctx_set_recv_msg_cb(context, recv_msg_cb);
}