Beispiel #1
0
        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;
        }
Beispiel #2
0
 public IClient this[ITetriNETClientCallback callback]
 {
     get
     {
         IClient client;
         _clients.TryGetValue(callback, out client);
         return client;
     }
 }
Beispiel #3
0
        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);
        }
Beispiel #4
0
 public IProxy CreateProxy(ITetriNETClientCallback callback, string address)
 {
     return new WCFProxy(callback, address);
 }
Beispiel #5
0
 public bool Contains(string name, ITetriNETClientCallback callback)
 {
     bool found = _clients.Any(x => x.Value.Name == name || x.Key == callback);
     return found;
 }
Beispiel #6
0
 protected override IClient CreateClient(string name, ITetriNETClientCallback callback)
 {
     return new Client(name, IPAddress.Any, callback);
 }
Beispiel #7
0
 protected abstract IClient CreateClient(string name, ITetriNETClientCallback callback);
Beispiel #8
0
 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);