Esempio n. 1
0
        public override AChannel GetChannel(uint id)
        {
            TChannel channel = null;

            this.idChannels.TryGetValue(id, out channel);
            return(channel);
        }
Esempio n. 2
0
        public override async Task <AChannel> ConnectChannelAsync(IPEndPoint ipEndPoint)
        {
            TcpClient tcpClient = new TcpClient();
            TChannel  channel   = new TChannel(tcpClient, ipEndPoint, this);

            Log.Debug($"TService.ConnectChannelAsync.Start: channelId={channel.Id}, thread={System.Threading.Thread.CurrentThread.ManagedThreadId}");
            await channel.ConnectAsync(ipEndPoint);

            this.idChannels[channel.Id] = channel;
            Log.Debug($"TService.ConnectChannelAsync.Finish: channelId={channel.Id}, thread={System.Threading.Thread.CurrentThread.ManagedThreadId}");
            return(channel);
        }
Esempio n. 3
0
 public override void Dispose()
 {
     if (this.acceptor != null)
     {
         var ids = this.idChannels.Keys.ToArray();
         foreach (var id in ids)
         {
             TChannel channel = this.idChannels[id];
             channel.Dispose();
         }
         this.acceptor.Stop();
         this.acceptor = null;
     }
 }
Esempio n. 4
0
        public override async Task <AChannel> AcceptChannelAsync()
        {
            if (this.acceptor == null)
            {
                throw new Exception("service construct must use host and port param");
            }
            TcpClient tcpClient = await this.acceptor.AcceptTcpClientAsync();

            TChannel channel = new TChannel(tcpClient, (IPEndPoint)tcpClient.Client.RemoteEndPoint, this);

            channel.OnConnected();
            this.idChannels[channel.Id] = channel;
            Log.Debug($"TService.AcceptChannelAsync: channelId={channel.Id}, thread={System.Threading.Thread.CurrentThread.ManagedThreadId}");
            return(channel);
        }