Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Service #36

Closed
zlozl233 opened this issue Dec 10, 2020 · 3 comments
Closed

Service #36

zlozl233 opened this issue Dec 10, 2020 · 3 comments

Comments

@zlozl233
Copy link

请问Service模块的作用是什么?

@188080501
Copy link
Owner

188080501 commented Dec 10, 2020

只是使用http的话,用不到service模块
service模块是其他基础模块的封装,给程序内服务调度用的,简单的说就是自动分发请求到对应的槽函数

@188080501
Copy link
Owner

但是目前service模块完成度不是很高,所以配套代码暂时没补上,大致用法如下

@188080501
Copy link
Owner

    auto service = HCHttpService::createService( {
        { JQHttpServer::ServiceHttpListenPort, 13890 },
        { JQHttpServer::ServiceProcessor, QVariant::fromValue< QPointer< QObject > >( &processor ) },
    } );
    if ( !service )
    {
        qDebug() << "Http initialize fail";
        QThread::sleep( 3 );
        return -1;
    }
class ServiceProcessor: public QObject
{
    Q_OBJECT

public slots:
    void getMyName(const QPointer< JQHttpServer::Session > &session);

    void postMyName(const QPointer< JQHttpServer::Session > &session);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants