Beispiel #1
0
        public void send(AbstractMessageSendExecutor sendExecutor)
        {
            if (sendExecutor == null)
            {
                return;
            }

            try
            {
                if (this.currentChannel == null)
                {
                    sendExecutor.failure("server channel is empty.");
                    return;
                }

                Task task = this.currentChannel.WriteAndFlushAsync(sendExecutor.getMessageContext());
                task.Wait();

                if (task.IsCompleted)
                {
                    sendExecutor.success();
                }
                else
                {
                    sendExecutor.failure("server channel error.");
                }
            }
            catch (Exception ex)
            {
                sendExecutor.failure(ex.Message);
            }
        }
        public void send(AbstractMessageSendExecutor sendExecutor, IClientMessageListenExecutor listenExecutor)
        {
            if (sendExecutor == null)
            {
                return;
            }

            if (listenExecutor != null)
            {
                this.registerListenExecutor(sendExecutor.getMessageType(), listenExecutor);
            }

            try
            {
                Task task = this.currentChannel.WriteAndFlushAsync(sendExecutor.getMessageContext());
                task.Wait();

                if (task.IsCompleted)
                {
                    sendExecutor.success();
                }
                else
                {
                    sendExecutor.failure("server channel error.");
                }
            }
            catch (Exception ex)
            {
                sendExecutor.failure(ex.Message);
            }
        }