mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-27 06:19:34 -06:00
reference: WebSocket
git-svn-id: svn://ultimatepp.org/upp/trunk@6708 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
f65a99f7ed
commit
5ba2e29db2
7 changed files with 79 additions and 1 deletions
27
reference/WebSocket/WebSocket.cpp
Normal file
27
reference/WebSocket/WebSocket.cpp
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
#include "Core/Core.h"
|
||||
|
||||
using namespace Upp;
|
||||
|
||||
// Open demo.html in browser, run this app, push the button...
|
||||
|
||||
CONSOLE_APP_MAIN
|
||||
{
|
||||
StdLogSetup(LOG_COUT|LOG_FILE);
|
||||
|
||||
TcpSocket server;
|
||||
if(!server.Listen(8888)) {
|
||||
LOG("Failed to start listening on 8888..");
|
||||
return;
|
||||
}
|
||||
|
||||
for(;;) {
|
||||
WebSocket ws;
|
||||
if(ws.WebAccept(server)) {
|
||||
LOG("Accepted connection");
|
||||
LOG(ws.Recieve());
|
||||
ws.SendText("Hello browser!");
|
||||
}
|
||||
if(ws.IsError())
|
||||
LOG("ERROR: " << ws.GetErrorDesc());
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue