Skip to content

Commit 4ddf260

Browse files
authored
Merge pull request defold#5181 from defold/issue-5180-dmsdk-webserver-handler
Issue 5180: Added dmWebServer to dmSDK
2 parents 07e0f50 + 8165cea commit 4ddf260

File tree

11 files changed

+280
-212
lines changed

11 files changed

+280
-212
lines changed

engine/dlib/src/dlib/web_server.h

Lines changed: 0 additions & 199 deletions
This file was deleted.

engine/dlib/src/dlib/web_server.cpp renamed to engine/dlib/src/dlib/webserver.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// Copyright 2020 The Defold Foundation
22
// Licensed under the Defold License version 1.0 (the "License"); you may not use
33
// this file except in compliance with the License.
4-
//
4+
//
55
// You may obtain a copy of the License, together with FAQs at
66
// https://www.defold.com/license
7-
//
7+
//
88
// Unless required by applicable law or agreed to in writing, software distributed
99
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
1010
// CONDITIONS OF ANY KIND, either express or implied. See the License for the
@@ -17,7 +17,7 @@
1717
#include "hashtable.h"
1818
#include "array.h"
1919
#include "dstrings.h"
20-
#include "web_server.h"
20+
#include "webserver.h"
2121
#include "http_server.h"
2222

2323
namespace dmWebServer

engine/dlib/src/dlib/webserver.h

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
// Copyright 2020 The Defold Foundation
2+
// Licensed under the Defold License version 1.0 (the "License"); you may not use
3+
// this file except in compliance with the License.
4+
//
5+
// You may obtain a copy of the License, together with FAQs at
6+
// https://www.defold.com/license
7+
//
8+
// Unless required by applicable law or agreed to in writing, software distributed
9+
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
10+
// CONDITIONS OF ANY KIND, either express or implied. See the License for the
11+
// specific language governing permissions and limitations under the License.
12+
13+
#ifndef DM_WEBSERVER_H
14+
#define DM_WEBSERVER_H
15+
16+
#include <dmsdk/dlib/socket.h>
17+
#include <dmsdk/dlib/webserver.h>
18+
19+
namespace dmWebServer
20+
{
21+
/**
22+
* Set NewParams default values
23+
* @param params Pointer to NewParams
24+
*/
25+
void SetDefaultParams(struct NewParams* params);
26+
27+
/**
28+
* Parameters passed into #New when creating a new web-server instance
29+
*/
30+
struct NewParams
31+
{
32+
/// Web-server port
33+
uint16_t m_Port;
34+
35+
/// Max persistent client connections
36+
uint16_t m_MaxConnections;
37+
38+
/// Connection timeout in seconds
39+
uint16_t m_ConnectionTimeout;
40+
41+
NewParams()
42+
{
43+
SetDefaultParams(this);
44+
}
45+
};
46+
47+
/**
48+
* Crete a new web server
49+
* @param params Parameters
50+
* @param server Web server instance
51+
* @return RESULT_OK on success
52+
*/
53+
Result New(const NewParams* params, HServer* server);
54+
55+
/**
56+
* Delete web server
57+
* @param server Web server instance
58+
*/
59+
void Delete(HServer server);
60+
/**
61+
* Update server
62+
* @param server Server handle
63+
* @return RESULT_OK on success
64+
*/
65+
Result Update(HServer server);
66+
67+
/**
68+
* Get name for socket, ie address and port
69+
* @param server Web server
70+
* @param address Address (result)
71+
* @param port Port (result)
72+
*/
73+
void GetName(HServer server, dmSocket::Address* address, uint16_t* port);
74+
}
75+
76+
#endif // DM_WEBSERVER_H

0 commit comments

Comments
 (0)