Exemplo n.º 1
0
 public Communicate(Schema schema, IShouldReceive shouldReceive, IReceive receive, ISend send)
 {
     _schema        = schema;
     _shouldReceive = shouldReceive;
     _receive       = receive;
     _send          = send;
 }
Exemplo n.º 2
0
        private static void ArquiteturaBaseadaEmObjetos()
        {
            string     message = "Entrei na conversa";
            int        id;
            TcpChannel tcpChannel = new TcpChannel();

            ChannelServices.RegisterChannel(tcpChannel, false);

            Type requiredType = typeof(ISend);

            remoteObject = (ISend)Activator.GetObject(requiredType,
                                                      "tcp://localhost:9998/MailServer");

            id = remoteObject.Register();

            new Thread(refreshMessages).Start();

            while (true)
            {
                lock (lockObj)
                {
                    mensagens = remoteObject.SendMessage(id, message);
                    Console.WriteLine(mensagens);
                }

                message = System.Console.ReadLine();
                Console.Clear();
            }
        }
		public MissingPlayerDataChecker(ISend sender)
		{
			Sender = sender;
			MyRunStorer = new DbfRunStorer();
			Stopwatch = new Stopwatch();
			Stopwatch.Start();
		}
Exemplo n.º 4
0
 public MyDemo(IService service,
               ITotal total,
               ISend send)
 {
     this._service = service;
     this._total   = total;
     this._send    = send;
 }
Exemplo n.º 5
0
 public BufferWriteStream(MemoryPool <byte> _memoryPool, ISend send, IAsyncSend asyncSend)
 {
     //this.MemoryPool = memoryPool;
     Send        = send;
     AsyncSend   = asyncSend;
     DataSegment = new List <ArraySegment <byte> >();
     // MemoryOwners = new List<IMemoryOwner<byte>>();
 }
Exemplo n.º 6
0
        public TransformerApplySender(ISend sender, string propertyNameSender, string key)
        {
            Sender             = sender;
            PropertyNameSender = propertyNameSender;
            Key = key;
            string type = (sender == null) ? "" : sender.GetType().Name;

            this.Name = $"apply {key} => {type}.{propertyNameSender}";
        }
Exemplo n.º 7
0
 void Resend(IReceive <int> numbers, ISend <string> results, string name)
 {
     foreach (var n in numbers.Range())
     {
         Task.Delay(5).Wait();
         results.Send($"{name} : {n}");
     }
     results.Close();
     Console.WriteLine($" [+] {name} done");
 }
Exemplo n.º 8
0
 public ZYSocketAsyncEventArgs(IFiberReadStream r_stream, IFiberWriteStream w_stream, ISend send, IAsyncSend asyncsend, MemoryPool <byte> memoryPool, Encoding encoding, ISerialization objFormat = null, bool isLittleEndian = false)
 {
     this.MemoryPool      = memoryPool;
     this.RStream         = r_stream;
     this.WStream         = w_stream;
     this.Encoding        = encoding;
     this.ObjFormat       = objFormat;
     base.Completed      += ZYSocketAsyncEventArgs_Completed;
     IsLittleEndian       = isLittleEndian;
     SendImplemented      = send;
     AsyncSendImplemented = asyncsend;
 }
Exemplo n.º 9
0
        public WhatsAppForm(ICustomerRepository repo, ISend send)
        {
            InitializeComponent();
            FormDesign.SetColor(this);
            _form_resize = new AutoSize(this);

            _repo = repo;
            _send = send;
            _dt   = _repo.GetCustomers();

            this.Load       += FormLoad;
            this.send.Click += SendClick;
        }
Exemplo n.º 10
0
        public DefaultSendEvaluator(ISend send)
        {
            _send = send ?? throw new ArgumentNullException(nameof(send));

            EventExpressionEvaluator   = send.EventExpression?.As <IStringEvaluator>();
            TypeExpressionEvaluator    = send.TypeExpression?.As <IStringEvaluator>();
            TargetExpressionEvaluator  = send.TargetExpression?.As <IStringEvaluator>();
            DelayExpressionEvaluator   = send.DelayExpression?.As <IIntegerEvaluator>();
            ContentExpressionEvaluator = send.Content?.Expression?.As <IObjectEvaluator>();
            ContentBodyEvaluator       = send.Content?.Body?.As <IValueEvaluator>();
            IdLocationEvaluator        = send.IdLocation?.As <ILocationEvaluator>();
            NameEvaluatorList          = send.NameList.AsArrayOf <ILocationExpression, ILocationEvaluator>();
            ParameterList = send.Parameters.AsArrayOf <IParam, DefaultParam>();
        }
Exemplo n.º 11
0
        /// <summary>
        /// Sends a message without metadata.
        /// </summary>
        public static async ValueTask <MessageId> Send <TMessage>(this ISend <TMessage> sender, TMessage message, CancellationToken cancellationToken = default)
        {
            var metadata = _messageMetadataPool.Get();

            try
            {
                return(await sender.Send(metadata, message, cancellationToken).ConfigureAwait(false));
            }
            finally
            {
                metadata.Metadata.Properties.Clear();
                _messageMetadataPool.Return(metadata);
            }
        }
Exemplo n.º 12
0
 protected override void OnProcess()
 {
     while (true)
     {
         foreach (var ch in Device429.SendComponents)
         {
             ISend sendItem = ch as ISend;
             if (sendItem != null)
             {
                 sendItem.Send();
             }
         }
         Thread.Sleep(500);
     }
 }
Exemplo n.º 13
0
        private void ConfigureSdp(SocketCfg cfg)
        {
            switch (cfg.SocketType)
            {
            case SocketType.Datagram:
                receiveModule = new SdpDatagramReceiveModule(this);
                sendModule    = new SdpDatagramSendModule(this);
                break;

            case SocketType.Stream:
                throw new Exception("Este protocolo não permite envio/recebimento do tipo stream");

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Exemplo n.º 14
0
        private void ConfigureTcp(SocketCfg cfg)
        {
            switch (cfg.SocketType)
            {
            case SocketType.Datagram:
                receiveModule = new TcpDatagramReceiveModule(this);
                sendModule    = new TcpDatagramSendModule(this);
                break;

            case SocketType.Stream:
                receiveModule = new TcpStreamReceiveModule(this);
                sendModule    = new TcpStreamSendModule(this);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Exemplo n.º 15
0
        IRowReceiveHierarchicalParent[]  FromSimpleTree(SimpleTree st, IRowReceiveHierarchicalParent parent)
        {
            var li = new List <IRowReceiveHierarchicalParent>();

            foreach (var node in st)
            {
                var item   = node.Key;
                var newRow = new RowReadHierarchical();
                newRow.Values.Add("Name", item.Name ?? item.GetType().Name);
                newRow.Values.Add("Type", item.GetType().Name);
                newRow.Parent = parent;
                li.Add(newRow);
                var childs = node.Childs;
                li.AddRange(FromSimpleTree(childs, newRow));

                ISend send = item as ISend;
                if (send != null)
                {
                    newRow.Values.Add("RowType", "Sender");
                    continue;
                }
                ITransform tr = item as ITransform;
                if (tr != null)
                {
                    newRow.Values.Add("RowType", "Transformer");
                    continue;
                }
                IFilter fi = item as IFilter;
                if (fi != null)
                {
                    newRow.Values.Add("RowType", "Filter");
                    continue;
                }
                IReceive r = item as IReceive;
                if (r != null)
                {
                    newRow.Values.Add("RowType", "Receiver");
                    continue;
                }
            }
            return(li.ToArray());
        }
Exemplo n.º 16
0
        public SmsForm(ICustomerRepository repo, ISend send)
        {
            InitializeComponent();
            FormDesign.SetColor(this);
            _form_resize = new AutoSize(this);

            _repo = repo;
            _send = send;

            _apiKey.Validating += Valid.TextValidating;
            _sender.Validating += Valid.TextValidating;

            _dt     = _repo.GetCustomers();
            _config = new ProviderConfig
            {
                ApiKey = _apiKey.Text,
                Sender = _sender.Text
            };
            this.Load     += FormLoad;
            sendSMS.Click += senderClick;
        }
Exemplo n.º 17
0
 public UserNotification(ISend send) : base(send)
 {
 }
Exemplo n.º 18
0
 public Notification(ISend send)
 {
     _send = send;
 }
Exemplo n.º 19
0
 public SimpleJob AddSender(ISend s)
 {
     this.Senders.Add(Senders.Count, s);
     return(this);
 }
Exemplo n.º 20
0
        public override async Task Execute()
        {
            IReceive arv = null;

            if (Receivers?.Count == 1)
            {
                arv = Receivers[0];
            }
            if (arv == null)
            {
                if (AllReceiversAsync)
                {
                    arv = new AsyncReceiverMultiple(Receivers.Select(it => it.Value).ToArray());
                }
                else
                {
                    arv = new SyncReceiverMultiple(Receivers.Select(it => it.Value).ToArray());
                }
            }
            await arv.LoadData();

            bool existsVar = (RuntimeParameters?.Length ?? 0) > 0;

            string[] nameObjectsWithVariables = null;
            if (existsVar)
            {
                nameObjectsWithVariables = RuntimeParameters
                                           .SelectMany(it => it.NameObjectsToApplyTo)
                                           .Select(it => it.NameObjectToApplyTo.ToLowerInvariant())
                                           .Distinct()
                                           .ToArray();
            }
            IRow[] data = arv.valuesRead;
            foreach (var filterKV in FiltersAndTransformers)
            {
                var var = filterKV.Value as TransformIntoVariable;
                if (var != null)
                {
                    if (!existsVar)
                    {
                        //TODO:log
                        continue;
                    }
                    var param = RuntimeParameters.FirstOrDefault(it => it.VariableName == var.VariableName);
                    if (param == null)
                    {
                        throw new ArgumentException($"in runtime parameters I cannot find variable {var.VariableName}");
                    }
                    await var.Run();

                    variables[param] = var.Result;
                    continue;
                }
                bool hasVar = (nameObjectsWithVariables?.Length > 0) && (nameObjectsWithVariables.Contains(filterKV.Value.Name.ToLowerInvariant()));
                if (hasVar)
                {
                    TransformPropertyFromVar(filterKV.Value);
                }
                //TODO: see also IFilterTransformer
                var transform = filterKV.Value as ITransform;
                if (transform != null)
                {
                    transform.valuesRead = data;
                    await transform.Run();

                    data = transform.valuesTransformed;
                    continue;
                }
                var filter = filterKV.Value as IFilter;
                if (filter != null)
                {
                    filter.valuesRead = data;
                    await filter.Run();

                    data = filter.valuesTransformed;
                    continue;
                }
                Debug.Assert(false, "base object is not found");
                //@class.Log(LogLevel.Error,0,$"base object is not found",null,null);
                Debug.Assert(false, "filter is not found");
            }
            //await SenderData(data);
            if (Senders.Count == 0)
            {
                return;
            }

            ISend send = null;

            if (Senders.Count == 1)
            {
                send = Senders[0];
            }
            if (send == null)
            {
                if (AllSendersAsync)
                {
                    send = new ASyncSenderMultiple(Senders.Select(it => it.Value).ToArray());
                }
                else
                {
                    send = new SyncSenderMultiple(Senders.Select(it => it.Value).ToArray());
                }
            }
            send.valuesToBeSent = data;
            await send.Send();
        }
Exemplo n.º 21
0
 public SendSale(ISend se)
 {
     s = se;
 }
Exemplo n.º 22
0
 public Greeter(ISend sender, DateTimeWrapper dateTimeWrapper)
 {
     _sender          = sender;
     _dateTimeWrapper = dateTimeWrapper;
 }
Exemplo n.º 23
0
 public DeliveryActor(ISend sender)
 {
     _sender = sender;
 }
Exemplo n.º 24
0
 public SendGuild(ISend se)
 {
     s = se;
 }
Exemplo n.º 25
0
 public SendPlayer(ISend se)
 {
     s = se;
 }
Exemplo n.º 26
0
 public virtual bool Send(ISend player, byte[] data)
 {
     return(player.Send(data));
 }
Exemplo n.º 27
0
 public SendDecorator(ISend sendor)
 {
     Sendor = sendor;
 }
Exemplo n.º 28
0
 public SocketClient(int bufferLength)
 {
     _sock    = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
     _SendObj = new AsyncSend(_sock, bufferLength);
     //_SendObj = new BeginSend(_sock, bufferLength);
 }
Exemplo n.º 29
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, ISend send, IReceive receive)
        {
            var  receiveSocket  = true;
            var  sendStartState = true;
            Task receiveTask    = null;
            Task sendTask       = null;
            bool connected      = false;

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            var webSocketOptions = new WebSocketOptions()
            {
                KeepAliveInterval = TimeSpan.FromSeconds(300),
                ReceiveBufferSize = 6 * 1024,
            };

            app.UseWebSockets(webSocketOptions);

            #region AcceptWebSocket
            app.Use(async(context, next) =>
            {
                bool firstTime = true;

                if (!connected)
                {
                    _webSocket = await context.WebSockets.AcceptWebSocketAsync();
                    connected  = true;
                }

                do
                {
                    if (sendStartState) // Send the start state once when there's a connection
                    {
                        sendStartState = await send.SendStartState(context, _webSocket);
                    }

                    if (sendTask == null || sendTask.IsCompleted) //Note: Performancewise this is faster then no await
                    {
                        sendTask = Task.Run(async() => await send.SendState(context, _webSocket));
                    }

                    if (receiveTask == null || receiveTask.IsCompleted)
                    {
                        receiveTask = Task.Run(async() => receiveSocket = await receive.ReceiveSocket(context, _webSocket, _buffer));
                        if (firstTime)
                        {
                            Thread.Sleep(50);
                            firstTime = false;
                        }
                    }

                    if (_webSocket.State == WebSocketState.Closed) // Handle websocket closing
                    {
                        await _webSocket.CloseAsync(new WebSocketCloseStatus(), "Client disconnected.", new CancellationToken());
                        sendStartState = true;
                        connected      = false;
                        break;
                    }
                } while (receiveSocket);

                // Cleanup tasks
                sendTask.Dispose();
                receiveTask.Dispose();
                sendStartState = true;
                connected      = false;
            });
            #endregion
        }
Exemplo n.º 30
0
 public ServerObserver()
 {
     this.commander = IoCRegister.Container.GetInstance <ICommander>();
     this.sender    = IoCRegister.Container.GetInstance <ISend>();
 }
Exemplo n.º 31
0
 public SendSession(ISend se)
 {
     s = se;
 }
Exemplo n.º 32
0
 void Ping(ISend <string> pings, string msg)
 {
     pings.Send(msg);
 }
Exemplo n.º 33
0
 public ValuesController(ISend send)
 {
     _send = send;
 }
Exemplo n.º 34
0
 void Pong(IReceive <string> pings, ISend <string> pongs)
 {
     var(msg, _) = pings.Receive();
     pongs.Send(msg);
 }