Hi all,
I'm never here.
I'm trying to use the WebSocket with Firebase 1.8-CE-RC.2 but I have a problem with the GameTransportPacket message received from the server using JavaScript. Reading the protocol specification the GameTransportPacket has classId=100 with tableId, pid and
gamedata that should be an array of byte.
My problem is that I don't know how to use the packet.gamedata received in JS function because my JS function receive a type of string for the packet.gamedata when I expect to receive an array of byte from the server.
This is my JS function that handle the packet:
...
packetCallback: function(packet) {
message("PACKET CLASSID:"+packet.classId);
//ClassId:100
switch(packet.classId){
case 100:
var localgamedata=packet.gamedata
alert("Gamedata "+ localgamedata);//this display the string reported above
alert(typeof localgamedata);//this diplay 'string'
break;
}
}
...
This is what my server log for the forwarding packet:
...
Forwarding packets: [GameTransportPacket : tableid[1] pid[2] gamedata[{123, 34, 99, 108, 97, 115, 115, 73, 100, 34, 58, 34, 78, 111, 116, 105, 102, 121, 80, 117... (221)}] attributes[]]]
...
and this is what my JS receive in the gamedata var:
eyJjbGFzc0lkIjoiTm90aWZ5UHVibGljQ2FyZHMiLCJkYXRhIjoie1wiZ2FtZVJlZmVyZW5jZVwiOlwiMzMtMVwiLFwicHVibGljQ2FyZHNcIjpbe1wic2VlZFwiOlwiREVOQVJJXCIsXCJ2YWx1ZVwiOjh9LHtcInNlZWRcIjpcIlNQQURFXCIsXCJ2YWx1ZVwiOjZ9LHtcInNlZWRcIjpcIkNPUFBFXCIsXCJ2YWx1ZVwiOjEwfSx7XCJzZWVkXCI6XCJTUEFERVwiLFwidmFsdWVcIjozfV19In0=
The typeof gamedata is string and not array or object.
In Firebase source code there is a js bytearray.js is it helpful? If yes how I can use it to read the convert the string in byte array?
I hope all is clear
Thanks
Pass