-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from Papierkorb/master
C++ Example
- Loading branch information
Showing
3 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* This is an example on how to create a fully functional HTTP server for use | ||
* with the sipgate.io API based on the NuriaProject Framework. | ||
* See: https://github.com/NuriaProject/Framework | ||
*/ | ||
|
||
#include <QCoreApplication> | ||
#include <nuria/httpclient.hpp> | ||
#include <nuria/httpserver.hpp> | ||
#include <nuria/httpnode.hpp> | ||
#include <nuria/debug.hpp> | ||
|
||
void mySlot (Nuria::HttpClient *client) { | ||
Nuria::HttpPostBodyReader *reader = client->postBodyReader (); | ||
if (!reader) { | ||
client->killConnection (400); | ||
return; | ||
} | ||
|
||
nLog() << "Incoming call" << reader->fieldValue ("from") << "->" << reader->fieldValue ("to"); | ||
} | ||
|
||
int main (int argc, char *argv[]) { | ||
QCoreApplication a (argc, argv); | ||
Nuria::HttpServer server; | ||
|
||
server.root ()->connectSlot ("index", mySlot); | ||
|
||
if (!server.listen (QHostAddress::Any, 3000)) { | ||
nError() << "Failed to listen on port 3000."; | ||
return 1; | ||
} | ||
|
||
nLog() << "Listening on all interfaces on port 3000."; | ||
return a.exec (); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Example project file for a sipgate.io HTTP server | ||
TEMPLATE = app | ||
TARGET = example | ||
INCLUDEPATH += . | ||
|
||
# Dependency to the NuriaProject Framework | ||
# See https://github.com/NuriaProject/Framework | ||
CONFIG += nuria | ||
NURIA += core network | ||
|
||
# | ||
SOURCES += example.cpp |