tgext.socketio and socket.io 1.3.7

43 views
Skip to first unread message

tguser

unread,
Oct 3, 2015, 12:51:24 PM10/3/15
to TurboGears
Hi all 

I manged to run the example in https://github.com/amol-/tgext.socketio
but if upgrade the socket.io  library to 1.3.7 it does not work anymore.
.
I tried using and other combinations:
var socket = io(window.location.protocol + '//localhost/pingpong', { 'multiplex': false, 'path': '/socketio'});

But no success with error like this:

XMLHttpRequest cannot load http://localhost/socketio/?EIO=3&transport=polling&t=1443890999903-2. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:9999' is therefore not allowed access. The response had HTTP status code 404.

Any ideas ?

G


<body>
<div>
<a class="ping" href="#" data-attack="ping">Ping</a>
<a class="ping" href="#" data-attack="fireball">Fireball</a>
<a class="ping" href="#" data-attack="auto">Auto</a>
<a class="ping" href="#" data-attack="error">Error</a>
</div>
<div id="result"></div>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/socket.io/0.9.16/socket.io.min.js"></script>
<script>
$(function(){
var socket = io.connect('/pingpong', {'resource':'socketio'});
socket.on('pong',function(data){
$('#result').append(data.sound + '<br/>');
});
socket.on('error',function(error, info) {
if (error == 'method_access_denied') { alert(info); }
else { console.log(info); alert(error); }
});
$('.ping').click(function(event){
event.preventDefault();
socket.emit('ping',{'type':$(this).data('attack')});
});
});
</script>
</body>
</html>
Reply all
Reply to author
Forward
0 new messages