--
You received this message because you are subscribed to the Google Groups "Blockly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blockly+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/blockly/f16b26ff-586c-4d47-b7b9-0f819e5c1063n%40googlegroups.com.
Hello,Thanks for your answer, indeed i was thinking that way. The sample you just link helped me too. I'm gonna try to work on that.Thank you.--Le vendredi 3 juin 2022 à 16:32:24 UTC+2, bwes...@google.com a écrit :Hello Sebastien!There's a real time collaboration demo, but I'm not sure if it's up-to-date. The basic way of doing real time collaboration is using events. Every time a non-ui event happens that is triggered by a user in one workspace, you serialize it, pipe it over to the other user in another workspace, deserialize it, and run it.I hope that helps! If you have any further questions please reply!
--BekaOn Thu, Jun 2, 2022 at 8:59 AM Sebastien K. <vittase...@gmail.com> wrote:Hello,
Currently working on a blockly/ace interface, I would like to implement a real-time collaborative code. Do you know if there are already projects that can help me to achieve this?
Thanks a lot.
Sebastien.
--
You received this message because you are subscribed to the Google Groups "Blockly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blockly+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/blockly/f16b26ff-586c-4d47-b7b9-0f819e5c1063n%40googlegroups.com.
You received this message because you are subscribed to the Google Groups "Blockly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blockly+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/blockly/3f1858e9-2090-4ee4-ab16-98e59c7ad370n%40googlegroups.com.
Hi, I had a simple test by using MQTT.
var myTimer;document.addEventListener('DOMContentLoaded', function() {//etc...var collaborationID = "SpBlocklyJS_"+Math.random().toString(16).substr(2, 8);
var mqttState = false;
var mqttLock = false;
function onBlocksChange(event) {
clearTimeout(myTimer);
if (event.type == "create"||event.type == "move"||event.type == "change"||event.type == "click"||event.type == "drag")
mqttState = true;
else if (event.type == "finished_loading") {
mqttState = false;
mqttLock = false;
}
myTimer = setTimeout(function(){
if (mqttState ==true&&mqttLock==false) {
mqttState = false;
var xml = Blockly.Xml.workspaceToDom(Blockly.getMainWorkspace());
var xmlText = Blockly.Xml.domToText(xml);mqtt_client.publish('blockly/mqtt', collaborationID+",,,"+xmlText);
}
mqttLock = false;
}, 1000);
}
workspace.addChangeListener(onBlocksChange);
const clientId = "mqtt_" + Math.random().toString(16).substr(2, 8);
const options = {
username: '',
password: '',
keepalive: 60,
clientId: clientId,
protocolId: "MQTT",
protocolVersion: 4,
clean: true,
reconnectPeriod: 1000,
connectTimeout: 30 * 1000
}
var mqtt_client = mqtt.connect('ws://mqttgo.io:8000/mqtt',options);
mqtt_client.on("connect", ()=>{
console.log("MQTT connected");
mqtt_client.subscribe('blockly/mqtt');
mqtt_client.on("message", async function (topic, payload) {
var enc = new TextDecoder("utf-8");
payload = enc.decode(payload).split(",,,");
//console.log(payload);
if (topic=='blockly/mqtt'&&payload[0]!=collaborationID) {
mqttLock = true;
var xmlDoc = Blockly.Xml.textToDom(payload[1]);
Blockly.getMainWorkspace().clear();
Blockly.Xml.domToWorkspace(xmlDoc, Blockly.getMainWorkspace());
}
})
})
});
--
You received this message because you are subscribed to the Google Groups "Blockly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blockly+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/blockly/44e07633-b494-4ddf-bdd2-6ef29ad140adn%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Blockly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blockly+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/blockly/3d3490c1-cbb7-4b00-8269-470e0928d3c6n%40googlegroups.com.