I am developping a collaborative whiteboard using fabricjs. When a user creates a new fabric object , I serialize it and send it to all other users.
var rec
You can use fabric.util.enlivenObjects
to deserialize json objects. After all objects are deserialized you have to add them:
objects.forEach(function(o) {
canvas.add(o);
});
Here is the complete example - replace obj1, obj2 with your objects. Example is also available on jsfiddle.
fabric.util.enlivenObjects([obj1, obj2], function(objects) {
var origRenderOnAddRemove = canvas.renderOnAddRemove;
canvas.renderOnAddRemove = false;
objects.forEach(function(o) {
canvas.add(o);
});
canvas.renderOnAddRemove = origRenderOnAddRemove;
canvas.renderAll();
});