示例#1
0
int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);


    QCommandLineParser parser;
    parser.setApplicationDescription("agar.io private server");
    parser.addHelpOption();

    QCommandLineOption dbgOption(QStringList() << "d" << "debug",
            QCoreApplication::translate("main", "Debug output [default: off]."));
    parser.addOption(dbgOption);
    QCommandLineOption portOption(QStringList() << "p" << "port",
            QCoreApplication::translate("main", "Port for server [default: 9000]."),
            QCoreApplication::translate("main", "port"), QLatin1Literal("9000"));
    parser.addOption(portOption);
    parser.process(a);
    bool debug = parser.isSet(dbgOption);
    int port = parser.value(portOption).toInt();

    GameServer *server = new GameServer(port, debug);
    QObject::connect(server, &GameServer::closed, &a, &QCoreApplication::quit);

    return a.exec();
}
示例#2
0
int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
    // TODO: separate to module based on Server Configurator App
    // with options to turn on/off components/etc
    QCommandLineParser parser;
    parser.setApplicationDescription("SemIoT gateway");
    parser.addHelpOption();
    // TODO: miltiple devices
    QCommandLineOption dbgOption(QStringList() << "d" << "debug", QCoreApplication::translate("main", "Debug output [default: off]."));
    parser.addOption(dbgOption);
    // TODO: get rid of magic default port:
    QCommandLineOption portOption(QStringList() << "p" << "port", QCoreApplication::translate("main", "Port for gateway server [default: 57864]."), QCoreApplication::translate("main", "port"), QLatin1Literal("57864"));
    parser.addOption(portOption);
    parser.process(a);
    bool debug = parser.isSet(dbgOption);
    Q_UNUSED(debug); //TODO
    int port = parser.value(portOption).toInt();
    // Internal part
    //DataServer dataServer;
    //DevicesConfigsLoader devicesConfigsLoader;
    FrontModuleManager fMM(&a);
    // External Part
    WebSocketServer wsServer(port,&a);
    HttpServer httpServer(&a);
    fMM.connectFrontModule((FrontModule*)&wsServer);
    fMM.connectFrontModule((FrontModule*)&httpServer);
    //wsServer.setDataServer(&dataServer);
    //httpServer.setDataServer(&dataServer);
    // FIXME: for all the protocols
    /*
    QObject::connect(&devicesConfigsLoader,SIGNAL(newDataReady(QString,QString)),&wsServer,SLOT(processNewData(QString,QString)));
    QObject::connect(&httpServer,SIGNAL(newRequestReceived(QVariant)),&devicesConfigsLoader,SIGNAL(newRequestReceived(QVariant)));
    QObject::connect(&httpServer,SIGNAL(addDeviceDriverFromUrl(QUrl)),&devicesConfigsLoader,SLOT(addConfig(QUrl)));
    */
    // TODO: linux kernel driver
    // TODO: dbus
    // TODO: systemd?
    /*
    monarch::data::json::JsonLd jsonld();

    monarch::rt::DynamicObject input;
    QFile file("infile");
    file.open(QIODevice::ReadOnly);
    QByteArray ba(file.readAll());

    monarch::rt::DynamicObject options;
    monarch::rt::DynamicObject output;
    jsonld().fromRdf(input,options,output);
    */
    return a.exec();
}
示例#3
0
文件: main.cpp 项目: rozetti/RZQLua
int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    QCommandLineParser parser;
    parser.setApplicationDescription("QtWebSockets example: echoclient");
    parser.addHelpOption();

    QCommandLineOption dbgOption(QStringList() << "d" << "debug",
            QCoreApplication::translate("main", "Debug output [default: off]."));
    parser.addOption(dbgOption);
    parser.process(a);
    bool debug = parser.isSet(dbgOption);
    debug=true;

    EchoClient client(QUrl(QStringLiteral("ws://localhost:1234")), debug);
    QObject::connect(&client, &EchoClient::closed, &a, &QCoreApplication::quit);

    return a.exec();
}