public IEnumerable <UserWords> GetChat(string room_name) { string canonical_room_name = RoomNameGuard.CheckName(room_name); //return ChatManager.Get(room); return(ChatPond.Get(canonical_room_name)); }
public void UpdatePosition2(string user_id, double x, double y, string room_name) { string canonical_room_name = RoomNameGuard.CheckName(room_name); UserCenter.UpdatePosition(canonical_room_name, user_id, x, y); HotRoomCenter.Update(canonical_room_name, user_id); }
public static bool CreateRoom(string name, int size, int attr) { TableResult result = Warehouse.RoomsTable.Execute(TableOperation.Retrieve("Rooms", Config.SPECIAL_KEY)); DynamicTableEntity entity = (DynamicTableEntity)result.Result; if (entity == null) { entity = new DynamicTableEntity("Rooms", Config.SPECIAL_KEY); entity["nextid"] = new EntityProperty(0); //entity["borderx"] = new EntityProperty(100); entity["bordery"] = new EntityProperty(100); Warehouse.RoomsTable.Execute(TableOperation.Insert(entity)); } if (!entity.Properties.ContainsKey("borderny")) { entity["borderny"] = new EntityProperty(-100); } int next_id = (int)entity["nextid"].Int32Value; createRoomNameEntry(next_id, name); // let it throw exception if the name already exists. entity["nextid"].Int32Value = next_id + 1; bool is_private = (attr & (int)RoomAttributes.IS_PRIVATE) != 0; int entrance_x, entrance_y; if (is_private) { entrance_x = Warehouse.Random.Next(1000, 10000); entrance_y = Warehouse.Random.Next(-10000, -1000); } else { bool ny = (attr & (int)RoomAttributes.CAN_PICTURE) != 0; int border_y = (int)entity[ny ? "borderny" : "bordery"].Int32Value; int delta_y = ((int)((size - 1) / 2) + 1) * (ny ? -1 : 1); entrance_x = ny ? -100 : 100; entrance_y = border_y + delta_y; entity[ny ? "borderny" : "bordery"].Int32Value = border_y + 2 * delta_y; } Warehouse.RoomsTable.Execute(TableOperation.Replace(entity)); // Throws StorageException ((412) Precondition Failed) if the entity is modified in between. // RoomInfoEntity ri_entity = new RoomInfoEntity(next_id, name, entrance_x, entrance_y, size, attr); Warehouse.RoomsTable.Execute(TableOperation.Insert(ri_entity)); // StorageException: 遠端伺服器傳回一個錯誤: (409) 衝突。 if the key already exists. // if (!is_private) { RoomList.OnNewRoom(name); } RoomNameGuard.OnNewRoom(name); return(true); }
public object GetFigurePage(string room_name, int page_id) { string canonical_room_name = RoomNameGuard.CheckName(room_name); IEnumerable <FigureInfo> list = FigureCenter.GetFigurePage(canonical_room_name, ref page_id); return(new { page_id = page_id, list = list }); }
public int /*0=suc, 1=fail, 2=full, 3=suc almost full, 4=too fast*/ DrawPaths(PathModel[] models, string room_name) { string canonical_room_name = RoomNameGuard.CheckName(room_name); if (Limiter.IsOverRate(Context.ConnectionId)) { return(4); } // Order inversion may happen when current paths are still under processing and next paths rush in in a new thread. // This causes later path gets smaller gsid. int ret = 0; //Trace.TraceInformation("DrawPaths. models.Length={0}.", models.Length); string batch_uri = null; int batch_gsid = 0; for (int i = 0; i < models.Length; i++) { PathModel model = models[i]; if (model.Type == (int)PathType.PT_BATCH) { if (model.DxDyCombined == batch_uri) { model.Gsid = batch_gsid; } else { model.Gsid = GsidManager.Get(canonical_room_name); // Negative and 0 GSIDs are also valid. batch_gsid = model.Gsid; batch_uri = model.DxDyCombined; // make all flag paths have same gsid. Otherwise path orders are affected by flag path's GSID. Batch path's order should depend on subid only. } } else { model.Gsid = GsidManager.Get(canonical_room_name); // Negative and 0 GSIDs are also valid. } int r = DrawAPath5(model, canonical_room_name); if (r != 0) { ret = r; } } return(ret); }
public void UpdateStatus2(string user_id, string name, string status, string room_name) { string canonical_room_name = RoomNameGuard.CheckName(room_name); if (name != null && status != null) { if (name.Length <= 20 && status.Length <= 100) { //ChatManager.Add(name, status); ChatPond.AddChat(canonical_room_name, name, status); UserCenter.UpdateStatus(canonical_room_name, user_id, name, status); } } }
public bool CreateFigure(string room_name, string figure_name, string uri, string user_id) { if (figure_name.Length > 100 || figure_name.Length < 1) { return(false); } if (!Util.WithinCharSetUserName(figure_name)) { return(false); } string canonical_room_name = RoomNameGuard.CheckName(room_name); bool ret = FigureStore.CreateFigure(canonical_room_name, figure_name, uri, user_id); if (ret) { Clients.Group(canonical_room_name).onNewFigure(); } return(ret); }
public IDictionary <string, UserStatus> GetAllStatus(string room_name) { string canonical_room_name = RoomNameGuard.CheckName(room_name); return(UserCenter.GetAllStatus(canonical_room_name)); }
public void AddEarlyPath(PathModel model, string room_name) { string canonical_room_name = RoomNameGuard.CheckName(room_name); PathCenter.AddEarlyPath(model, canonical_room_name); }