[DEV] continue removing stl
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
|
||||
|
||||
namespace appl {
|
||||
void onReceiveData(std::vector<uint8_t>& _data) {
|
||||
void onReceiveData(etk::Vector<uint8_t>& _data) {
|
||||
TEST_INFO("Receive Datas : " << _data.size() << " bytes");
|
||||
TEST_INFO("data:" << (char*)&_data[0] << "");
|
||||
}
|
||||
@@ -25,7 +25,7 @@ int main(int _argc, const char *_argv[]) {
|
||||
etk::init(_argc, _argv);
|
||||
enet::init(_argc, _argv);
|
||||
for (int32_t iii=0; iii<_argc ; ++iii) {
|
||||
std::string data = _argv[iii];
|
||||
etk::String data = _argv[iii];
|
||||
if ( data == "-h"
|
||||
|| data == "--help") {
|
||||
TEST_PRINT(etk::getApplicationName() << " - help : ");
|
||||
@@ -38,11 +38,11 @@ int main(int _argc, const char *_argv[]) {
|
||||
TEST_INFO("== Test HTTP client ==");
|
||||
TEST_INFO("==================================");
|
||||
// connect on TCP server:
|
||||
enet::Tcp tcpConnection = std::move(enet::connectTcpClient("127.0.0.1", 12345));
|
||||
enet::Tcp tcpConnection = etk::move(enet::connectTcpClient("127.0.0.1", 12345));
|
||||
// TODO : Check if connection is valid ...
|
||||
|
||||
// Create a HTTP connection in Client mode
|
||||
enet::HttpClient connection(std::move(tcpConnection));
|
||||
enet::HttpClient connection(etk::move(tcpConnection));
|
||||
// Set callbacks:
|
||||
connection.connect(appl::onReceiveData);
|
||||
|
||||
|
@@ -16,7 +16,7 @@
|
||||
|
||||
|
||||
namespace appl {
|
||||
void onReceiveData(std::vector<uint8_t>& _data, bool _isString) {
|
||||
void onReceiveData(etk::Vector<uint8_t>& _data, bool _isString) {
|
||||
TEST_INFO("Receive Datas : " << _data.size() << " bytes");
|
||||
if (_isString == true) {
|
||||
_data.resize(_data.size()+1);
|
||||
@@ -32,7 +32,7 @@ int main(int _argc, const char *_argv[]) {
|
||||
etk::init(_argc, _argv);
|
||||
enet::init(_argc, _argv);
|
||||
for (int32_t iii=0; iii<_argc ; ++iii) {
|
||||
std::string data = _argv[iii];
|
||||
etk::String data = _argv[iii];
|
||||
if ( data == "-h"
|
||||
|| data == "--help") {
|
||||
TEST_PRINT(etk::getApplicationName() << " - help : ");
|
||||
@@ -45,19 +45,19 @@ int main(int _argc, const char *_argv[]) {
|
||||
TEST_INFO("== Test WebSocket client ==");
|
||||
TEST_INFO("==================================");
|
||||
// connect on TCP server:
|
||||
enet::Tcp tcpConnection = std::move(enet::connectTcpClient("127.0.0.1", 12345));
|
||||
enet::Tcp tcpConnection = etk::move(enet::connectTcpClient("127.0.0.1", 12345));
|
||||
// TODO : Check if connection is valid ...
|
||||
|
||||
// Create a HTTP connection in Client mode
|
||||
enet::WebSocket connection(std::move(tcpConnection), false);
|
||||
enet::WebSocket connection(etk::move(tcpConnection), false);
|
||||
// Set callbacks:
|
||||
connection.connect(appl::onReceiveData);
|
||||
|
||||
// start http connection (the actual state is just TCP start ...)
|
||||
std::vector<std::string> protocols;
|
||||
protocols.push_back("test1526/1.0");
|
||||
protocols.push_back("test1526/1.5");
|
||||
protocols.push_back("Hello");
|
||||
etk::Vector<etk::String> protocols;
|
||||
protocols.pushBack("test1526/1.0");
|
||||
protocols.pushBack("test1526/1.5");
|
||||
protocols.pushBack("Hello");
|
||||
connection.start("/plop.txt", protocols);
|
||||
|
||||
// send some data to play ...
|
||||
|
@@ -17,7 +17,7 @@ int main(int _argc, const char *_argv[]) {
|
||||
etk::init(_argc, _argv);
|
||||
enet::init(_argc, _argv);
|
||||
for (int32_t iii=0; iii<_argc ; ++iii) {
|
||||
std::string data = _argv[iii];
|
||||
etk::String data = _argv[iii];
|
||||
if ( data == "-h"
|
||||
|| data == "--help") {
|
||||
TEST_PRINT(etk::getApplicationName() << " - help : ");
|
||||
@@ -31,7 +31,7 @@ int main(int _argc, const char *_argv[]) {
|
||||
TEST_INFO("==================================");
|
||||
// client mode ...
|
||||
// connect on TCP server:
|
||||
enet::Tcp connection = std::move(enet::connectTcpClient("127.0.0.1", 12345));
|
||||
enet::Tcp connection = etk::move(enet::connectTcpClient("127.0.0.1", 12345));
|
||||
TEST_INFO("CLIENT connect ...");
|
||||
if (connection.getConnectionStatus() != enet::Tcp::status::link) {
|
||||
TEST_ERROR("can not link to the socket...");
|
||||
|
@@ -14,7 +14,7 @@
|
||||
|
||||
#include <etk/stdTools.hpp>
|
||||
namespace appl {
|
||||
void onReceiveData(enet::HttpServer* _interface, std::vector<uint8_t>& _data) {
|
||||
void onReceiveData(enet::HttpServer* _interface, etk::Vector<uint8_t>& _data) {
|
||||
TEST_INFO("Receive Datas : " << _data.size() << " bytes");
|
||||
}
|
||||
void onReceiveHeader(enet::HttpServer* _interface, const enet::HttpRequest& _data) {
|
||||
@@ -23,8 +23,8 @@ namespace appl {
|
||||
if (_data.getType() == enet::HTTPReqType::HTTP_GET) {
|
||||
if (_data.getUri() == "plop.txt") {
|
||||
enet::HttpAnswer answer(enet::HTTPAnswerCode::c200_ok);
|
||||
std::string data = "<html><head></head></body>coucou</body></html>";
|
||||
answer.setKey("Content-Length", etk::to_string(data.size()));
|
||||
etk::String data = "<html><head></head></body>coucou</body></html>";
|
||||
answer.setKey("Content-Length", etk::toString(data.size()));
|
||||
_interface->setHeader(answer);
|
||||
_interface->write(data);
|
||||
_interface->stop(true);
|
||||
@@ -42,7 +42,7 @@ int main(int _argc, const char *_argv[]) {
|
||||
etk::init(_argc, _argv);
|
||||
enet::init(_argc, _argv);
|
||||
for (int32_t iii=0; iii<_argc ; ++iii) {
|
||||
std::string data = _argv[iii];
|
||||
etk::String data = _argv[iii];
|
||||
if ( data == "-h"
|
||||
|| data == "--help") {
|
||||
TEST_PRINT(etk::getApplicationName() << " - help : ");
|
||||
@@ -62,16 +62,16 @@ int main(int _argc, const char *_argv[]) {
|
||||
// Start listening ...
|
||||
interface.link();
|
||||
// Wait a new connection ..
|
||||
enet::Tcp tcpConnection = std::move(interface.waitNext());
|
||||
enet::Tcp tcpConnection = etk::move(interface.waitNext());
|
||||
// Free Connected port
|
||||
interface.unlink();
|
||||
// TODO : Check if connection is valid ...
|
||||
|
||||
// Create a HTTP connection in Server mode
|
||||
enet::HttpServer connection(std::move(tcpConnection));
|
||||
enet::HttpServer connection(etk::move(tcpConnection));
|
||||
enet::HttpServer* tmp = &connection;
|
||||
// Set callbacks:
|
||||
connection.connect([=](std::vector<uint8_t>& _value){
|
||||
connection.connect([=](etk::Vector<uint8_t>& _value){
|
||||
appl::onReceiveData(tmp, _value);
|
||||
});
|
||||
connection.connectHeader([=](const enet::HttpRequest& _value){
|
||||
@@ -97,8 +97,8 @@ int main(int _argc, const char *_argv[]) {
|
||||
|
||||
TEST_INFO("----------------------------");
|
||||
TEST_INFO("POST data : ");
|
||||
std::map<std::string, std::string> values;
|
||||
values.insert(std::make_pair<std::string, std::string>("plop", "valuePlop"));
|
||||
etk::Map<etk::String, etk::String> values;
|
||||
values.insert(etk::makePair<etk::String, etk::String>("plop", "valuePlop"));
|
||||
if (connection.post("", values) == false) {
|
||||
TEST_ERROR("can not POST data...");
|
||||
return -1;
|
||||
@@ -107,7 +107,7 @@ int main(int _argc, const char *_argv[]) {
|
||||
|
||||
TEST_INFO("----------------------------");
|
||||
TEST_INFO("POST xml : ");
|
||||
if (connection.post("", "text/xml; charset=utf-8", "<plop><string>value1</string></plop>") == false) {
|
||||
if (connection.post("", "text/xml; charset=utf-8", "<plop><etk/String.hpp>value1</string></plop>") == false) {
|
||||
TEST_ERROR("can not POST XML data...");
|
||||
return -1;
|
||||
}
|
||||
|
@@ -15,7 +15,7 @@
|
||||
|
||||
#include <etk/stdTools.hpp>
|
||||
namespace appl {
|
||||
void onReceiveData(enet::WebSocket* _interface, std::vector<uint8_t>& _data, bool _isString) {
|
||||
void onReceiveData(enet::WebSocket* _interface, etk::Vector<uint8_t>& _data, bool _isString) {
|
||||
TEST_INFO("Receive Datas : " << _data.size() << " bytes");
|
||||
if (_isString == true) {
|
||||
_data.resize(_data.size()+1);
|
||||
@@ -26,7 +26,7 @@ namespace appl {
|
||||
TEST_INFO("binary data: ... ");
|
||||
}
|
||||
}
|
||||
bool onReceiveUri(enet::WebSocket* _interface, const std::string& _uri, const std::vector<std::string>& _protocols) {
|
||||
bool onReceiveUri(enet::WebSocket* _interface, const etk::String& _uri, const etk::Vector<etk::String>& _protocols) {
|
||||
TEST_INFO("Receive Header uri: " << _uri);
|
||||
for (auto &it : _protocols) {
|
||||
if (it == "test1526/1.5") {
|
||||
@@ -45,7 +45,7 @@ int main(int _argc, const char *_argv[]) {
|
||||
etk::init(_argc, _argv);
|
||||
enet::init(_argc, _argv);
|
||||
for (int32_t iii=0; iii<_argc ; ++iii) {
|
||||
std::string data = _argv[iii];
|
||||
etk::String data = _argv[iii];
|
||||
if ( data == "-h"
|
||||
|| data == "--help") {
|
||||
TEST_PRINT(etk::getApplicationName() << " - help : ");
|
||||
@@ -65,19 +65,19 @@ int main(int _argc, const char *_argv[]) {
|
||||
// Start listening ...
|
||||
interface.link();
|
||||
// Wait a new connection ..
|
||||
enet::Tcp tcpConnection = std::move(interface.waitNext());
|
||||
enet::Tcp tcpConnection = etk::move(interface.waitNext());
|
||||
// Free Connected port
|
||||
interface.unlink();
|
||||
// TODO : Check if connection is valid ...
|
||||
|
||||
// Create a HTTP connection in Server mode
|
||||
enet::WebSocket connection(std::move(tcpConnection), true);
|
||||
enet::WebSocket connection(etk::move(tcpConnection), true);
|
||||
enet::WebSocket* tmp = &connection;
|
||||
// Set callbacks:
|
||||
connection.connect([=](std::vector<uint8_t>& _value, bool _isString){
|
||||
connection.connect([=](etk::Vector<uint8_t>& _value, bool _isString){
|
||||
appl::onReceiveData(tmp, _value, _isString);
|
||||
});
|
||||
connection.connectUri([=](const std::string& _value, const std::vector<std::string>& _protocols){
|
||||
connection.connectUri([=](const etk::String& _value, const etk::Vector<etk::String>& _protocols){
|
||||
return appl::onReceiveUri(tmp, _value, _protocols);
|
||||
});
|
||||
|
||||
|
@@ -17,7 +17,7 @@ int main(int _argc, const char *_argv[]) {
|
||||
etk::init(_argc, _argv);
|
||||
enet::init(_argc, _argv);
|
||||
for (int32_t iii=0; iii<_argc ; ++iii) {
|
||||
std::string data = _argv[iii];
|
||||
etk::String data = _argv[iii];
|
||||
if ( data == "-h"
|
||||
|| data == "--help") {
|
||||
TEST_PRINT(etk::getApplicationName() << " - help : ");
|
||||
@@ -37,13 +37,13 @@ int main(int _argc, const char *_argv[]) {
|
||||
// Start listening ...
|
||||
interface.link();
|
||||
// Wait a new connection ..
|
||||
enet::Tcp tcpConnection = std::move(interface.waitNext());
|
||||
enet::Tcp tcpConnection = etk::move(interface.waitNext());
|
||||
// Free Connected port
|
||||
interface.unlink();
|
||||
|
||||
int32_t iii = 0;
|
||||
while (tcpConnection.getConnectionStatus() == enet::Tcp::status::link) {
|
||||
int32_t len = tcpConnection.write("plop" + etk::to_string(iii));
|
||||
int32_t len = tcpConnection.write("plop" + etk::toString(iii));
|
||||
TEST_INFO("write len=" << len);
|
||||
char data[1024];
|
||||
len = tcpConnection.read(data, 1024);
|
||||
|
Reference in New Issue
Block a user