diff options
author | 2015-11-04 18:55:36 +0100 | |
---|---|---|
committer | 2015-11-04 18:55:36 +0100 | |
commit | b6707c3bb53c931e9ec3c5c6630149b7121bbcf5 (patch) | |
tree | 2d9c880bb21242c3fb4619977fe9a71658b3d06e /3rdparty/mongoose/examples/websocket_echo_server | |
parent | 2a067f08a4582cdff841dc27b661a9e48fac419a (diff) |
Removed mongoose due to restricted license and webserver wip till code is restructured (nw)
Diffstat (limited to '3rdparty/mongoose/examples/websocket_echo_server')
3 files changed, 0 insertions, 119 deletions
diff --git a/3rdparty/mongoose/examples/websocket_echo_server/Makefile b/3rdparty/mongoose/examples/websocket_echo_server/Makefile deleted file mode 100644 index f6b132dc9c6..00000000000 --- a/3rdparty/mongoose/examples/websocket_echo_server/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -# Copyright (c) 2014 Cesanta Software -# All rights reserved - -PROG = websocket_echo_server -CFLAGS = -W -Wall -I../.. -pthread -g -O0 $(CFLAGS_EXTRA) -SOURCES = $(PROG).c ../../mongoose.c - -$(PROG): $(SOURCES) - $(CC) -o $(PROG) $(SOURCES) $(CFLAGS) - -clean: - rm -rf $(PROG) *.exe *.dSYM *.obj *.exp .*o *.lib diff --git a/3rdparty/mongoose/examples/websocket_echo_server/index.html b/3rdparty/mongoose/examples/websocket_echo_server/index.html deleted file mode 100644 index 84e7078a7cb..00000000000 --- a/3rdparty/mongoose/examples/websocket_echo_server/index.html +++ /dev/null @@ -1,46 +0,0 @@ -<!DOCTYPE html> -<meta charset="utf-8" /> -<title>WebSocket Test</title> -<script language="javascript" type="text/javascript"> - - var out = function(message) { - var div = document.createElement('div'); - div.innerHTML = message; - document.getElementById('output').appendChild(div); - }; - - window.onload = function() { - var url = 'ws://' + location.host + '/ws'; - var num_messages = 0; - - websocket = new WebSocket(url); - websocket.onopen = function(ev) { - out('CONNECTED'); - var msg = 'Не всё подчиняется разуму. Но всё подчиняется упорству. '; - out('SENT: ' + msg); - websocket.send(msg); - }; - websocket.onclose = function(ev) { - out('DISCONNECTED'); - }; - websocket.onmessage = function(ev) { - if (!ev.data) { - out('<span style="color: blue;">PING... </span>'); - } else { - out('<span style="color: blue;">RESPONSE: ' + ev.data + ' </span>'); - num_messages++; - } - if (num_messages > 3) { - websocket.send('exit'); - } - }; - websocket.onerror = function(ev) { - out('<span style="color: red; ">ERROR: </span> ' + ev.data); - }; - }; -</script> -<style> div {font: small Verdana; } </style> -<h2>Mongoose WebSocket Test</h2> - -<div id="output"></div> -</html> diff --git a/3rdparty/mongoose/examples/websocket_echo_server/websocket_echo_server.c b/3rdparty/mongoose/examples/websocket_echo_server/websocket_echo_server.c deleted file mode 100644 index 9001a8a4c23..00000000000 --- a/3rdparty/mongoose/examples/websocket_echo_server/websocket_echo_server.c +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (c) 2013-2014 Cesanta Software Limited -// $Date: 2014-09-09 17:07:55 UTC $ - -#include <string.h> -#include <time.h> -#include "mongoose.h" - -static void push_message(struct mg_server *server, time_t current_time) { - struct mg_connection *c; - char buf[20]; - int len = sprintf(buf, "%lu", (unsigned long) current_time); - - // Iterate over all connections, and push current time message to websocket ones. - for (c = mg_next(server, NULL); c != NULL; c = mg_next(server, c)) { - if (c->is_websocket) { - mg_websocket_write(c, 1, buf, len); - } - } -} - -static int send_reply(struct mg_connection *conn) { - if (conn->is_websocket) { - // This handler is called for each incoming websocket frame, one or more - // times for connection lifetime. - // Echo websocket data back to the client. - mg_websocket_write(conn, 1, conn->content, conn->content_len); - return conn->content_len == 4 && !memcmp(conn->content, "exit", 4) ? - MG_FALSE : MG_TRUE; - } else { - mg_send_file(conn, "index.html", NULL); - return MG_MORE; - } -} - -static int ev_handler(struct mg_connection *conn, enum mg_event ev) { - switch (ev) { - case MG_AUTH: return MG_TRUE; - case MG_REQUEST: return send_reply(conn); - default: return MG_FALSE; - } -} - -int main(void) { - struct mg_server *server = mg_create_server(NULL, ev_handler); - time_t current_timer = 0, last_timer = time(NULL); - - mg_set_option(server, "listening_port", "8080"); - - printf("Started on port %s\n", mg_get_option(server, "listening_port")); - for (;;) { - mg_poll_server(server, 100); - current_timer = time(NULL); - if (current_timer - last_timer > 0) { - last_timer = current_timer; - push_message(server, current_timer); - } - } - - mg_destroy_server(&server); - return 0; -} |