- Client API to v1.7.2
- Smartfoxserver 2X to v2.13
I have trouble. When I have tried to connect to server, I get this in console
Code: Select all
[ SFS2X | INFO ] SmartFox instance ready
[ SFS2X | INFO ] SFS2X JavaScript API v1.7.2
[ SFS2X | INFO ] Attempting connection to server
[ SFS2X | INFO ] Sending request 'HandshakeRequest' to server
sfs2x-api-1.7.2.js:10 Uncaught RangeError: Wrong length!
at validateArrayBufferArguments (_typed-buffer.js:157)
at new ArrayBuffer (_typed-buffer.js:247)
at SFSDataSerializer.object2binary (sfs2x-api-1.7.2.js:9)
at SFSObject.toBinary (sfs2x-api-1.7.2.js:11)
at SFSProtocolCodec.onPacketWrite (sfs2x-api-1.7.2.js:10)
at SocketEngine.send (sfs2x-api-1.7.2.js:10)
at SmartFox.send (sfs2x-api-1.7.2.js:8)
at SmartFox._onSocketConnect (sfs2x-api-1.7.2.js:8)
at SocketEngine.dispatchEvent (sfs2x-api-1.7.2.js:10)
at WebSocket._onSocketConnect (sfs2x-api-1.7.2.js:10)
This is my code
Code: Select all
var sfs = null;
class Map extends React.Component {
constructor(props) {
super(props);
var config = {};
config.host = "127.0.0.1";
config.port = 8080;
config.zone = "BasicExamples";
config.debug = true;
sfs = new SFS2X.SmartFox(config);
var platform = navigator.appName;
var version = navigator.appVersion;
sfs.setClientDetails(platform, version);
sfs.addEventListener(SFS2X.SFSEvent.CONNECTION, this.onConnection, this);
sfs.connect();
}
function onConnection(event) {
if (event.success) {
console.log("Connected to SmartFoxServer 2X!");
} else {
alert("Failed!");
}
}
}
thank for help!