Websocket does not work in Ionic -


everyone! please, help.. should in order use websocket in ionic app? couldn't find info in docs this.

i'm writing in code:

.controller('controller', function($scope) {   $scope.planets = [{'name': 'Меркурий', 'order': '1'},                     {'name': 'Венера', 'order': '2'},                     {'name': 'Земля', 'order': '3'},                     {'name': 'Марс', 'order': '4'},                     {'name': 'Юпитер', 'order': '5'},                     {'name': 'Сатурн', 'order': '6'},                     {'name': 'Уран', 'order': '7'},                     {'name': 'Нептун', 'order': '8'},                     {'name': 'Плутон', 'order': '9'},                    ];    $scope.senddata = function(selected) {       var planets = $scope.planets;       var num;       (var i=0; < planets.length; i++) {           if (planets[i].name === selected) {               num = planets[i].order;           }        }        var socket = new websocket("ws://somesource.com");       socket.send(num);       socket.onmessage = function(data) {           alert(data);       };    };  }) 

and nothing...

by design somesource.com must return me data responding on "num"

thanks!

it's have found if had searched websockets on cordova instead of ionic (cordova underlying component of ionic).

websockets not officially supported because android has no native websocket support , newest ios devices have native websocket support:

   websockets or alternative phonegap?

   https://www.quora.com/does-phonegap-support-websocket

as alternative, recommend following tutorial learn how use socket.io ionic:

   https://www.sitepoint.com/using-socket-io-and-cordova-to-create-a-real-time-chat-app/


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -