Example #1
0
        private static void OperateAsync(Socket socket, SaeaAwaiter awaiter, Func <Socket, SaeaAwaiter, bool> operation, Action <SaeaAwaiter, SocketError> callback)
        {
            if (socket == null)
            {
                return;
            }

            try
            {
                awaiter.Reset();
                awaiter.OnCompleted(callback);
                operation.Invoke(socket, awaiter);
            }
            catch
            {
            }
        }
Example #2
0
        private static void OperateAsync(Socket socket, SaeaAwaiter awaiter, Func <Socket, SaeaAwaiter, bool> operation, Action <SaeaAwaiter, SocketError> callback)
        {
            if (socket == null)
            {
                return;
            }

            try
            {
                awaiter.Reset();
                awaiter.OnCompleted(callback);
                operation.Invoke(socket, awaiter);
            }
            catch (Exception e)
            {
                Console.WriteLine("simaysocket operate exception:" + e.Message);
            }
        }
        private static void OperateAsync(Socket socket, SaeaAwaiter awaiter, Func <Socket, SaeaAwaiter, bool> operation, Action <SaeaAwaiter, SocketError> callback)
        {
            if (socket == null)
            {
                return;
            }

            try
            {
                awaiter.Reset();
                awaiter.OnCompleted(callback);
                bool willSyncCompleted = operation.Invoke(socket, awaiter);
                if (!willSyncCompleted)
                {
                    awaiter.CompletedHandler();
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog("OperateAsync:" + ex.Message);
            }
        }
Example #4
0
 public static void SendAsync(Socket socket, SaeaAwaiter awaiter, Action <SaeaAwaiter, SocketError> callback)
 => OperateAsync(socket, awaiter, SEND, callback);
Example #5
0
 public static void ReceiveAsync(Socket socket, SaeaAwaiter awaiter, Action <SaeaAwaiter, SocketError> callback)
 => OperateAsync(socket, awaiter, RECEIVE, callback);
Example #6
0
 public static void DisonnectAsync(Socket socket, SaeaAwaiter awaiter, Action <SaeaAwaiter, SocketError> callback)
 => OperateAsync(socket, awaiter, DISCONNECT, callback);
Example #7
0
 public static void AcceptAsync(Socket socket, SaeaAwaiter awaiter, Action <SaeaAwaiter, SocketError> callback)
 => OperateAsync(socket, awaiter, ACCEPT, callback);