1

I'm currently testing a theory. I have VS2013 and have installed Apache Cordova and Node.js project libraries. I have created NodeJS+Socket.IO websites before using the native command line methods, mostly using guides so my understanding of "how things work" is on the basic side. Below is a picture of the VS Project I've created:

Solution Structure

Basically I want to be able to use socket.io to communicate data between the two projects. I've done a fair bit of research on Google and on here and can't find anything specific, how could this be achieved?

I have seen this question which tells me this could potentially be achieved, but that is natively Android and not Cordova.

It also may be that using NodeJS isn't the best option. Ultimately I'm wanting to be able to communicate with an existing (very large) .Net application so I would be interested to know if there's a better way of doing this (skipping the NodeJS layer entirely?).

Thanks for your time

UPDATE

Something I'm trying, but getting connection error:

Server Side

var http = require('http');
var server = http.createServer();
var io = require('socket.io')(server);

server.listen(5022, function () {
    console.log('listening on *:5022');
});

io.sockets.on('connection', function (socket) {
    console.log('socket connected');
    
    socket.on('disconnect', function () {
        console.log('socket disconnected');
    });
    
    socket.emit('text', 'wow. such event. very real time.');
});

App

document.addEventListener('deviceready',    
    function() {
        onDeviceReady.bind(this);
        console.log('Device is Ready')
        var socket = io.connect('http://MyDomain:5022');
        socket.on('connect', function () {
            socket.on('text', function (text) {
                console.log(text);
            });
        });
    },
false);

I get the Device is Ready message, but I get this message:

Failed to load resource: net::ERR_CONNECTION_REFUSED

File: xhr_proxy, Line: 0, Column: 0

Community
  • 1
  • 1
Jamie Barker
  • 8,145
  • 3
  • 29
  • 64

1 Answers1

1

I created a new question on here. The code I created was fine, it was just the debug method I was using (Ripple) which was preventing CORS in the browser.

Community
  • 1
  • 1
Jamie Barker
  • 8,145
  • 3
  • 29
  • 64