1 line
3.3 KiB
Plaintext
Executable File
1 line
3.3 KiB
Plaintext
Executable File
{"version":3,"file":"Connectors/TestConnector.js","sources":["Connectors/TestConnector.coffee"],"names":[],"mappings":"CACA,WAAA,GAAA,EAAA,GAAI,QAAQ,cAEZ,OAAO,QAAU,SAAC,GAKhB,GAAA,SAAM,GAAA,WAQS,QAAA,GAAE,EAAS,EAAK,GAC3B,GAAA,GAAA,CADY,MAAC,OAAA,EAAQ,KAAC,GAAA,EAAI,KAAC,mBAAA,EAC3B,EAAQ,SAAA,SAAA,UAAC,SACP,GAAC,KAAK,KADA,MAER,KAAC,mBAAmB,KAAK,GAEzB,KAAC,sBACD,EAA4B,SAAA,SAAA,UAAC,SAC3B,GAAC,mBAAmB,KAAK,KADC,MAE5B,KAAC,mBAAmB,KAAK,GACI,KAA1B,MAAA,EAAK,EAAW,OAAA,SACjB,KAAC,OAAO,SAAS,EAAU,GAAG,mBAAmB,WAEnD,KAAC,oBAZH,GAAA,UAkBA,uBAAwB,iBACtB,MAAC,oBAnBH,EAAA,UAyBA,KAAM,SAAC,GACL,GAAA,GAAA,EAAA,EAAA,CAAA,IAAI,EAAE,IAAI,UAAW,KAAC,GAAG,aAA8C,gBAA5B,GAAS,IAAI,UAAxD,KACE,KAAA,EAAA,EAAA,EAAA,EAAA,OAAA,EAAA,EAAA,kBACK,EAAK,cAAiB,KAAC,GAAG,YAC3B,EAAK,eAAe,QAAQ,sBA7BpC,EAAA,UAmCA,QAAS,SAAC,GACR,GAAA,GAAA,+DACA,KAAC,WAAW,EAAE,IAAI,SAAS,KAAK,IArClC,EAAA,UA0CA,SAAU,SAAC,GACT,GAAA,EAAA,QAAA,OAAA,EAAA,KAAA,WAAA,IAAA,EAAsB,OAAA,QAAS,EAC7B,KAAC,OAAO,QAAQ,KAAC,WAAW,GAAM,SADpC,QA3CF,EAAA,UAiDA,eAAgB,iBACd,MAAC,SAAU,EAAE,OAAO,EAAI,EAAU,OAAO,KAlD3C,EAAA,UAuDA,SAAU,WACR,GAAA,GAAA,EAAA,CAAA,GAAA,KAAA,UAAA,KAAA,IAAA,UACE,KAAC,OAAO,SAAS,SACnB,MAAC","sourcesContent":["\n_ = require \"underscore\"\n\nmodule.exports = (user_list)->\n\n #\n # A trivial Connector that simulates network delay.\n #\n class TestConnector\n\n #\n # @param {Engine} engine The transformation engine\n # @param {HistoryBuffer} HB\n # @param {Array<Function>} execution_listener You must ensure that whenever an operation is executed, every function in this Array is called.\n # @param {Yatta} yatta The Yatta framework.\n #\n constructor: (@engine, @HB, @execution_listener)->\n send_ = (o)=>\n @send o\n @execution_listener.push send_\n\n @applied_operations = []\n appliedOperationsListener = (o)=>\n @applied_operations.push o\n @execution_listener.push appliedOperationsListener\n if not (user_list?.length is 0)\n @engine.applyOps user_list[0].getHistoryBuffer()._encode()\n\n @unexecuted = {}\n\n #\n # This engine applied operations in a specific order.\n # Get the ops in the right order.\n #\n getOpsInExecutionOrder: ()->\n @applied_operations\n\n #\n # This function is called whenever an operation was executed.\n # @param {Operation} o The operation that was executed.\n #\n send: (o)->\n if (o.uid.creator is @HB.getUserId()) and (typeof o.uid.op_number isnt \"string\")\n for user in user_list\n if user.getUserId() isnt @HB.getUserId()\n user.getConnector().receive(o)\n\n #\n # This function is called whenever an operation was received from another peer.\n # @param {Operation} o The operation that was received.\n #\n receive: (o)->\n @unexecuted[o.uid.creator] ?= []\n @unexecuted[o.uid.creator].push o\n\n #\n # Flush one operation from the line of a specific user.\n #\n flushOne: (user)->\n if @unexecuted[user]?.length > 0\n @engine.applyOp @unexecuted[user].shift()\n\n #\n # Flush one operation on a random line.\n #\n flushOneRandom: ()->\n @flushOne (_.random 0, (user_list.length-1))\n\n #\n # Flush all operations on every line.\n #\n flushAll: ()->\n for n,ops of @unexecuted\n @engine.applyOps ops\n @unexecuted = {}\n\n"],"sourceRoot":"/source/"} |