コード例 #1
0
 public LobbyConnection(LocalConnection connection, MatchServer matchServer, LogOnService logOnService)
 {
     _connection = connection;
       _logOnService = logOnService;
       _registrationService = new RegistrationService();
       AuthenticationService = new AuthenticationService();
       MatchServer = matchServer;
 }
コード例 #2
0
ファイル: LogOnService.cs プロジェクト: spinesheath/TenView
 public bool TryLogOn(string accountId, LocalConnection connection)
 {
     lock(_accounts)
       {
     if(_accounts.ContainsKey(accountId))
       return false;
     _accounts.Add(accountId, connection);
     return true;
       }
 }
コード例 #3
0
ファイル: ClientFactory.cs プロジェクト: spinesheath/TenView
 /// <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;
       }
 }
コード例 #4
0
 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));
 }