コード例 #1
0
ファイル: RdmNetDeviceSocket.cs プロジェクト: AvolitesLtd/ACN
        private void DoNewConnection(IAsyncResult state)
        {
            if (!IsDisposed)
            {
                TcpListener listener = (TcpListener)state.AsyncState;
                if (listener.Server.IsBound)
                {
                    try
                    {
                        Socket clientSocket = listener.EndAcceptSocket(state);

                        if (IsTcpConnectionAlive())
                        {
                            clientSocket.Close();
                        }
                        else
                        {
                            HealthCheckedTcpSocket socket = new HealthCheckedTcpSocket(clientSocket, RdmSourceId, SenderId, SourceName);
                            socket.UnhandledException += socket_UnhandledException;
                            socket.Open(new IPEndPoint(IPAddress.Any, 0));
                            AliveTcpSocket = socket;
                        }
                    }
                    finally
                    {
                        listener.BeginAcceptSocket(new AsyncCallback(DoNewConnection), listener);
                    }
                }
            }
        }
コード例 #2
0
 public void AddKnownDevice(RdmEndPoint endpoint)
 {
     if (!devices.ContainsKey(endpoint))
     {
         HealthCheckedTcpSocket device = HealthCheckedTcpSocket.Connect(endpoint, SenderId);
         device.UnhandledException += device_UnhandledException;
         device.NewRdmPacket       += device_NewRdmPacket;
         devices.Add(endpoint, device);
     }
 }
コード例 #3
0
        public static HealthCheckedTcpSocket Connect(RdmEndPoint endpoint, Guid senderId)
        {
            Socket newConnection = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

            newConnection.Connect(endpoint);

            HealthCheckedTcpSocket socket = new HealthCheckedTcpSocket(newConnection, endpoint.Id, senderId, string.Empty);

            socket.Open(endpoint);
            return(socket);
        }
コード例 #4
0
 public HeartbeatProtocolFilter(HealthCheckedTcpSocket parent)
 {
     this.parent = parent;
 }