public Client(string name, IPAddress address, ITetriNETClientCallback callback, string team = null) { if (name == null) throw new ArgumentNullException("name"); if (address == null) throw new ArgumentNullException("address"); if (callback == null) throw new ArgumentNullException("callback"); Id = Guid.NewGuid(); Name = name; Address = address; Callback = callback; ConnectTime = DateTime.Now; State = ClientStates.Connected; Roles = ClientRoles.NoRole; Team = team; PieceIndex = 0; LastActionToClient = DateTime.Now; LastActionFromClient = DateTime.Now; TimeoutCount = 0; _disconnected = false; }
public IClient this[ITetriNETClientCallback callback] { get { IClient client; _clients.TryGetValue(callback, out client); return client; } }
public WCFProxy(ITetriNETClientCallback callback, string address) { if (callback == null) throw new ArgumentNullException("callback"); if (address == null) throw new ArgumentNullException("address"); LastActionToServer = DateTime.Now; // Get WCF endpoint EndpointAddress endpointAddress = new EndpointAddress(address); // Create WCF proxy from endpoint Log.Default.WriteLine(LogLevels.Debug, "Connecting to server:{0}", endpointAddress.Uri); Binding binding = new NetTcpBinding(SecurityMode.None); InstanceContext instanceContext = new InstanceContext(callback); _factory = new DuplexChannelFactory<ITetriNETClient>(instanceContext, binding, endpointAddress); _proxy = _factory.CreateChannel(instanceContext); }
public IProxy CreateProxy(ITetriNETClientCallback callback, string address) { return new WCFProxy(callback, address); }
public bool Contains(string name, ITetriNETClientCallback callback) { bool found = _clients.Any(x => x.Value.Name == name || x.Key == callback); return found; }
protected override IClient CreateClient(string name, ITetriNETClientCallback callback) { return new Client(name, IPAddress.Any, callback); }
protected abstract IClient CreateClient(string name, ITetriNETClientCallback callback);
public IClient CreateClient(string name, string team, IPAddress address, ITetriNETClientCallback callback) { return new Client(name, address, callback, team); }
protected override IClient CreateClient(string name, IPAddress address, ITetriNETClientCallback callback, string team = null) { return new Client(name, address, callback, team); }
protected abstract IClient CreateClient(string name, IPAddress address, ITetriNETClientCallback callback, string team = null);