コード例 #1
0
ファイル: UdpSocket.cs プロジェクト: hersveit/tunnelier-udp
        public void Listen(DOnReceiveClient onReceiveClient)
        {
            ParameterizedThreadStart listenThreadStart = new ParameterizedThreadStart(
                (obj) => ListenThread(obj as DOnReceiveClient)
                );

            thread = new Thread(listenThreadStart);
            thread.Start(onReceiveClient);
        }
コード例 #2
0
ファイル: UdpSocket.cs プロジェクト: hersveit/tunnelier-udp
        private void ListenThread(DOnReceiveClient onReceiveClient)
        {
            while (true)
            {
                IPEndPoint endPoint   = new IPEndPoint(0, 0);
                byte[]     result     = socket.Receive(ref endPoint);
                string     endPointIp = endPoint.Address.ToString();

                if (Array.Exists(blackList, ip => endPointIp == ip))
                {
                    var logger = TunnelierCore.Core.DI.Get <Logger>();
                    logger.Info($"Client was blocked by black list: {endPointIp.ToString()}");
                    continue;
                }

                onReceiveClient(new ClientMessage(endPoint, result));
            }
        }