public LobbyConnection(LocalConnection connection, MatchServer matchServer, LogOnService logOnService) { _connection = connection; _logOnService = logOnService; _registrationService = new RegistrationService(); AuthenticationService = new AuthenticationService(); MatchServer = matchServer; }
public bool TryLogOn(string accountId, LocalConnection connection) { lock(_accounts) { if(_accounts.ContainsKey(accountId)) return false; _accounts.Add(accountId, connection); return true; } }
/// <summary> /// Creates a local match. /// </summary> public static IEnumerable<ITenhouReceiver> CreateLocalMatch() { var server = new LocalLobbyServer(new SeedGenerator()); for (var i = 0; i < 4; ++i) { var connection = new LocalConnection(server); var sender = new TenhouSender(connection, new LogOnInformation("AccountId" + i, "M", 0)); var client = new AutoJoinLobbyClient(sender); var ai = new TsumokiriAI(sender); var receiver = new TenhouReceiver(connection, sender, client, ai); connection.Connect(); yield return receiver; } }
public void Process(LocalConnection connection, XElement message) { StateMachine stateMachine; lock (_stateMachines) { if (!_stateMachines.ContainsKey(connection)) { var lobbyConnection = new LobbyConnection(connection, _matchServer, _logOnService); stateMachine = new StateMachine(new ConnectionEstablishedState(lobbyConnection)); stateMachine.Finished += OnConnectionEnded; _stateMachines.Add(connection, stateMachine); } else { stateMachine = _stateMachines[connection]; } } stateMachine.Process(new Message(InvariantConvert.ToString(connection.GetHashCode()), message)); }