I register a service in web app, when someone connects to the service, the service seems to be hanged if I try to assign callback to the onmessage of socket in onconnect function of BluetoothServiceSuccessCallback. The code is as following:
var uuid = "5BCE9431-6C75-32AB-AFE0-2EC108A30860";
adapter.registerRFCOMMServiceByUUID(uuid, "service", function(handler) {
handler.onconnect = function(socket) {
alert("1");
socket.onmessage = function() {
...
};
alert("2");
}
});
The first alert can be executed but the second can not. That is the "2" is never alerted. But if I commented the "socket.onmessage = function() {...}", the second alert executes. That's really strange. Can someone help me?