https://bugzilla.wikimedia.org/show_bug.cgi?id=67955

--- Comment #1 from Merlijn van Deen <[email protected]> ---
Okay, this seems to be because of Socket.IO. Basically, it's not possible to
connect using plain websockets, as there's some opaque (and non-documented!!)
protocol above it.

How to connect using websockets:

1) Go to http://stream.wmflabs.org/socket.io/1/. Copy the first integer.
2) Use ws://stream.wmflabs.org/socket.io/1/websocket/<that integer> as
websockets URL
3) Don't forget to reply to pings!


The following code sort-of works using the library linked in #0:

#include "easywsclient.hpp"
#include <iostream>
#include <cstdlib>
#include <assert.h>
#include <stdio.h>
#include <string>

using easywsclient::WebSocket;
static WebSocket::pointer ws = NULL;

void handle_message(const std::string & message)
{
    printf(">>> %s\n", message.c_str());
    if (message == "world") { ws->close(); }
}

int main(int argc, char *argv[])
{
    if (argc != 2) {
        std::cout << "ERROR: must provide WS url; use the following:\n"
                  << argv[0] << "
ws://stream.wmflabs.org/socket.io/1/websocket/`curl
http://stream.wmflabs.org/socket.io/1/ | cut -d: -f1`\n";
        exit(1);
    }
    ws = WebSocket::from_url(argv[1]);
    assert(ws);
    ws->send("5::/rc:{\"name\": \"subscribe\", \"args\": [\"*\"]}");
    ws->send("hello");
    while (ws->getReadyState() != WebSocket::CLOSED) {
      ws->poll();
      ws->dispatch(handle_message);
    }
    delete ws;
    return 0;
}

-- 
You are receiving this mail because:
You are the assignee for the bug.
You are on the CC list for the bug.
_______________________________________________
Wikibugs-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l

Reply via email to