public void AddPath(PathModel model) { this.queue.Enqueue(model); }
public void AddEarlyPath(PathModel model, string room_name) { string canonical_room_name = RoomNameGuard.CheckName(room_name); PathCenter.AddEarlyPath(model, canonical_room_name); }
private int /*0=suc, 1=fail, 2=full, 3=suc almost full, 4=too fast*/ DrawAPath5(PathModel model, string room_name) { // If client is old and layer ("l") is not included in upload, model.Layer will be 0. // path_model.UpdatedBy = Context.ConnectionId; // Clients.AllExcept(path_model.UpdatedBy).drawAPath(path_model); //if (_broadcaster.IsOverRate(Context.ConnectionId)) int ret = Warehouse.BlockPathsPond.AddPath(model); if (ret == 0 || ret == 3) { _broadcaster.AddPath(model, room_name); } //Trace.TraceInformation("DrawAPath5. Gsid={0}, type={1}.", model.Gsid, model.Type); return(ret); }
private static int /*0=suc, 1=fail, 2=full, 3=suc almost full*/ addPath(PathModel model) { string partition_key = Config.DRAWING_PAR_KEY_PREFIX + model.BlockIndexX.ToString() + ',' + model.BlockIndexY.ToString(); try { TableOperation op = TableOperation.Retrieve <DrawingInfoEntity>(partition_key, Config.SPECIAL_KEY); TableResult result = Warehouse.DrawingsTable.Execute(op); DrawingInfoEntity info_entity = (DrawingInfoEntity)result.Result; if (info_entity != null) { if (info_entity.NextId >= Config.BLOCK_FULL_THRESHOLD) { return(2); } info_entity.NextId++; Warehouse.DrawingsTable.Execute(TableOperation.Replace(info_entity)); } else { info_entity = new DrawingInfoEntity(partition_key); info_entity.NextId++; Warehouse.DrawingsTable.Execute(TableOperation.Insert(info_entity)); } string row_key = Config.DRAWING_ROW_KEY_PREFIX + (info_entity.NextId - 1).ToString("D" + Config.DRAWING_ROW_KEY_DIGITS); DynamicTableEntity entity = new DynamicTableEntity(partition_key, row_key); entity["t"] = new EntityProperty(model.Type); entity["u"] = new EntityProperty(model.UserId); entity["l"] = new EntityProperty(model.Layer); entity["z"] = new EntityProperty(model.Zoom); entity["tm"] = new EntityProperty(model.TransformMatrix); entity["o"] = new EntityProperty(model.Color); entity["s"] = new EntityProperty(model.TipSize); entity["b"] = new EntityProperty(model.BrushId); entity["r"] = new EntityProperty(model.Blur); if (model.Idiosyncrasy.Length != 0) { entity["i"] = new EntityProperty(model.Idiosyncrasy); } entity["hx"] = new EntityProperty(model.HeadX); // typed changed from int to string. entity["hy"] = new EntityProperty(model.HeadY); // typed changed from int to string. entity["bx"] = new EntityProperty(model.BlockIndexX); entity["by"] = new EntityProperty(model.BlockIndexY); entity["c"] = new EntityProperty(model.DxDyCombined); entity["g"] = new EntityProperty(model.Gsid); Warehouse.DrawingsTable.Execute(TableOperation.Insert(entity)); // //HomeManager.onNewPath(model.BlockIndexX, model.BlockIndexY, info_entity.NextId); return(info_entity.NextId >= Config.BLOCK_ALMOST_FULL ? 3 : 0); } catch (StorageException ex) { // "遠端伺服器傳回一個錯誤: (409) 衝突。" when inserting duplicated entities. // "遠端伺服器傳回一個錯誤: (412) Precondition Failed。" when entity is modified in between. return(1); } }