Exemple #1
0
        public AChannel GetChannel(ObjectId id)
        {
            TChannel channel = null;

            this.idChannels.TryGetValue(id, out channel);
            return(channel);
        }
Exemple #2
0
        public void Remove(AChannel channel)
        {
            TChannel tChannel = channel as TChannel;

            if (tChannel == null)
            {
                return;
            }
            this.idChannels.Remove(channel.Id);
            this.channels.Remove(channel.RemoteAddress);
            this.timerManager.Remove(tChannel.SendTimer);
        }
Exemple #3
0
        public async Task <AChannel> GetChannel()
        {
            if (this.acceptor == null)
            {
                throw new Exception("service construct must use host and port param");
            }
            TSocket socket = new TSocket(this.poller);

            await this.acceptor.AcceptAsync(socket);

            TChannel channel = new TChannel(socket, this);

            this.channels[channel.RemoteAddress] = channel;
            this.idChannels[channel.Id]          = channel;
            return(channel);
        }
Exemple #4
0
        public AChannel GetChannel(string host, int port)
        {
            TChannel channel = null;

            if (this.channels.TryGetValue(host + ":" + port, out channel))
            {
                return(channel);
            }

            TSocket newSocket = new TSocket(this.poller);

            channel = new TChannel(newSocket, host, port, this);
            this.channels[channel.RemoteAddress] = channel;
            this.idChannels[channel.Id]          = channel;
            this.SocketConnectAsync(channel);
            return(channel);
        }
Exemple #5
0
        private void Dispose(bool disposing)
        {
            if (this.acceptor == null)
            {
                return;
            }

            if (disposing)
            {
                foreach (ObjectId id in this.idChannels.Keys.ToArray())
                {
                    TChannel channel = this.idChannels[id];
                    channel.Dispose();
                }
                this.acceptor.Dispose();
            }

            this.acceptor = null;
        }
Exemple #6
0
		public async Task<AChannel> GetChannel()
		{
			if (this.acceptor == null)
			{
				throw new Exception("service construct must use host and port param");
			}
			TSocket socket = new TSocket(this.poller);
			await this.acceptor.AcceptAsync(socket);
			TChannel channel = new TChannel(socket, this);
			this.channels[channel.RemoteAddress] = channel;
			this.idChannels[channel.Id] = channel;
			return channel;
		}
Exemple #7
0
		public AChannel GetChannel(string host, int port)
		{
			TChannel channel = null;
			if (this.channels.TryGetValue(host + ":" + port, out channel))
			{
				return channel;
			}

			TSocket newSocket = new TSocket(this.poller);
			channel = new TChannel(newSocket, host, port, this);
			this.channels[channel.RemoteAddress] = channel;
			this.idChannels[channel.Id] = channel;
			this.SocketConnectAsync(channel);
			return channel;
		}