how to run server

I installed: Node, npm and npm websockets on ubuntu. Javascrip code is below. And its running on but unity wont get any data :( Do you have any idea what could be wrong ? Code is fine, i tested it on my computer.

#!/usr/bin/env nodejs
var io = require('')({
   transports: ['websocket'],

var userdataN = [ ];
var redovi = 6;

for(var i = 0; i < redovi; ++i) {
    userdataN[i] = [ ];
console.log("Online players: " + userdataN[0].length);
io.on('connection', function(socket){

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

      if(userdataN[0].indexOf( == -1){


         var poz = userdataN[0].indexOf(;
            userdataN[1][poz] = data.username;
               userdataN[2][poz] = data.x;
               userdataN[3][poz] = data.y;
               userdataN[4][poz] = data.z;
               userdataN[5][poz] = data.rotY;

               socket.emit('update', {

                  username : userdataN[1],
                  x : userdataN[2],
                  y : userdataN[3],
                  z : userdataN[4],
                  rotY : userdataN[5]
      socket.on('chatmsg', function(poruka){
         var poz = userdataN[0].indexOf(;
         socket.emit('update', {

                  username : userdataN[1][poz],
                  msg : poruka


   socket.on('disconnect', function() {

      var poz = userdataN[0].indexOf(;

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hope… this url ( will help you out

Lol, no edit button.

Just to add that im trying to connect with my unity game. ws://