■ My first test with SpiderBasic is to log in and get a nickname
Code: Select all
Global username.s
!require(["https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.0.3/socket.io.js"],
! function(value) {
;Connect to server
Debug "Connection in progress ..."
! var socket = io.connect('http://109.13.115.206:6832', {'forceNew':true });
;Server emit a custom event 'setnewguest'
! socket.on('setnewguest', function(username) {
! v_username = username
Debug "Welcome. Your nickname is " + username
! })
! }
!);
■ The same code encoded with javascript worksConsole wrote:Uncaught ReferenceError: io is not defined
Code: Select all
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Test Socket.io</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.0.3/socket.io.js"></script>
</head>
<body>
<h5>Welcome</h5>
<div id="username"></div>
<script>
// Connect to server
var socket = io.connect('http://109.13.115.206:6832', {'forceNew':true });
//Server emit a custom event 'setnewguest'
socket.on('setnewguest', function (data) {
document.getElementById("username").innerHTML = "Your nickname is " + data;
})
</script>
</body>
</html>
These two codes attempt to connect to a test server. (Not on the operating server)
I hope you will help me to solve this problem. Thank you.