コード例 #1
0
        private void ReadCallback(IAsyncResult ar)
        {
            // Retrieve the state object and the handler socket
            // from the asynchronous state object.
            var state   = (StateObject)ar.AsyncState;
            var handler = state.workSocket;

            // Read data from the client socket.
            int bytesRead = handler.EndReceive(ar);

            if (bytesRead > 0)
            {
                RaiseAction?.Invoke(state.buffer);

                handler.BeginSend(state.buffer, 0, state.buffer.Length, 0,
                                  new AsyncCallback(SendCallback), handler);
            }
        }
コード例 #2
0
        private static RaiseAction ReadRaiseAction(FSMXmlReader reader)
        {
            RaiseAction raise = new RaiseAction();

            raise.Event = reader.ReadAttributeValue <string>("event");

            foreach (var child in reader.FilterChildNodeType(FSMNamespace))
            {
                reader.ReadStartNode(child);
                switch (child.LocalName)
                {
                case "data":
                    raise.DataExpr = reader.ReadFirstChildExpression(null);
                    break;
                }
                reader.ReadEndNode();
            }

            return(raise);
        }
コード例 #3
0
        public void Start(int port, string savePath)
        {
            var ipHostInfo = Dns.GetHostEntry(Dns.GetHostName());
            var ipAddress  = ipHostInfo.AddressList[0];

            var listener = new TcpListener(IPAddress.Any, port);

            listener.Start();

            RaiseNotification?.Invoke($"File Socket Server listening on Port:{port}");

            while (true)
            {
                using (var client = listener.AcceptTcpClient())
                    using (var stream = client.GetStream())
                    {
                        RaiseAction?.Invoke(ReadAllBytes(stream));
                    }
            }
        }
コード例 #4
0
 public static void SetRaiseEvent(RaiseAction raiseAction, string eventName) =>
 raiseAction.EventName = eventName;