/// <summary> /// Returns true if player has joined the room /// </summary> public bool JoinPlayer(IAccount account, out RoomInfo roomInfo, out Token connectToken) { connectToken = Token.Create(); roomInfo = new RoomInfo(id, name); if (!playerDatabase.TryGetValue(account.ID, playerFactory, out TPlayer player)) { } player = playerFactory.Create(account.ID, clock.MS, account.Name, connectToken, null); return(players.TryAdd(player.ID, player)); }
/// <summary> /// Returns true if player has added to the room /// </summary> public bool AddPlayer(IAccount account, out Token connectToken) { connectToken = Token.Create(); if (!playerDatabase.TryGetValue(account.ID, playerFactory, out TPlayer player)) { player = playerFactory.Create(account.ID, 0, account.Name, connectToken, null); } player.LastPingMS = clock.MS; return(players.TryAdd(player.ID, player)); }