public ChatPeerListener(ChatClient chatClient, PlayerInfo playerInfo, string serverAddress, string applicationName) { Player = playerInfo; ChatClient = chatClient; _connected = false; _operations = new Dictionary<byte, IBaseOp>(); foreach (var item in typeof(IBaseOp).Assembly.GetTypes().Where(_ => !_.IsAbstract && typeof(IBaseOp).IsAssignableFrom(_))) { var obj = (IBaseOp)Activator.CreateInstance(item); _operations[obj.OpCode] = obj; } _peer = new PhotonPeer(this, ConnectionProtocol.Udp); _peer.Connect(serverAddress, applicationName); while (!_connected) { _peer.Service(); } var t = new Timer { Enabled = true, Interval = 10 }; t.Elapsed += (sender, args) => _peer.Service(); t.Start(); }
public static void AddPlayer(string userId, PlayerInfo playerInfo) { if (Repository.ContainsKey(userId)) { throw new ArgumentException(); } Repository.Add(userId, playerInfo); }
public ChatClient() { _userId = Guid.NewGuid().ToString("N"); Trace.TraceInformation($"User:: {_userId}"); _playerInfo = new PlayerInfo { UserId = _userId, LobbyName = "London" }; }