get socket-io plugin 2 work with on node

0 favourites
  • 4 posts
From the Asset Store
Node Downloader is a plugin for download file for Construct 3 and construct 2 game engine
  • I have a tiny test app running on node.js with installed:

    var io = require("").listen(8080);

    io.sockets.on('connection', function (socket) {


        socket.emit('balls', { ball:42 });

        socket.on('daub', function (data) {




    As you can see, it sends one message, and logs when it receives one.

    I know its all working as when I try this test js outside of C2, it works:





    <script src="socket-io/"></script>


    var socket = io.connect('http://localhost:8080');

    socket.on('balls', function (data) {


        socket.emit('daub', { my: 'data' });





    Using the official C2 web sockets plugin, nothing happens.

    Using Zacks plugin:

    Nothing happens.

    My capx simply says:

    system->On load complete=WebSocket connect to "ws://localhost:8080" (required protocol "").

    It never connects to the server. no errors no nothing.

    WebSocket->On message is never fired.

    WebSocket->On connection error is never fired.

    WebSocket->On connection opened is never fired.

    The same using the Socket object provided by Zacks plugin, it does nothing. i.e.

    system->On load complete=Socket Connect to "ws://localhost" (port 8080 specified in the dialogue) never connects. It also never calls any events, such as On Connect or on error.

    They are both just "dead". But I know the server side is working fine.

    any ideas?

  • ws://localhost ?

    try: localhost

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Ok, got it to connect now, but no joy on transferring messages in either direction. Neither side sees the messages from the other. I am guessing its because node.js uses two parameters, and the web socket implentation only uses one. I.e. the "balls" and "daub" in my example. Unfortunately, the official web socket manual page has no examples or info on what it expects on the server side, and i cant find a server side web socket implementation which is compatible with it.

    I think my only option here is to develop my own plugin, as my client and server javascript works fine, its just the 3 or 4 existing web socket and plugins for C2 dont work with node.js and

    I chose node.js and for speed of prototyping and compatibility, but will probably switch to smartfoxserver 2x, kaazing or jwebsocket for production.

  • OK, being new to web sockets, and (but have been programming unix sockets for 30 years), i realise where i was going wrong. is not compatible with web sockets.

    I installed the ws package on node.js, and changed the server side test program to this:

    var WebSocketServer = require('ws').Server

    , wss = new WebSocketServer({port: 8080});

    wss.on('connection', function(ws) {

        ws.on('message', function(message) {

            console.log('received: %s', message);




    And it works with the C2 web sockets.

    However, web sockets suck compared with the features of and jwebsockets, so I will be developing plugins for one of those. (could not get Zacks to work).

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)