public void OnSend(object sender, EventDataArg <string> e)
        {
            Logger.Info($"Send to {e.HostInfo.Host} via {e.HostInfo.Protocol} message {e.Data}");
            switch (e.HostInfo.Protocol)
            {
            case UdpSender.Name:
                UdpSender.SendAsync(e.HostInfo.Host, e.Data);
                break;

            case TcpSender.Name:
                TcpSender.SendAsync(e.HostInfo.Host, e.Data);
                break;

            default:
                Logger.Error($"Unknow protocol {e.HostInfo.Protocol} for {e.HostInfo}, message {e.Data}");
                break;
            }
        }
Пример #2
0
 public void EventDataHandler(object sender, EventDataArg <string> e)
 {
 }
        public void EventDataHandler(object sender, EventDataArg <string> e)
        {
            Logger.Info($"Invoked EventDataHandler for {e.HostInfo.Host} via {e.HostInfo.Protocol}, message {e.Data}");
            IMessage message = Deserializing.GetMessage(e.Data, out MessageType type);

            Logger.Debug($"File {message} deserialized to {type} for {e.HostInfo.Host} via {e.HostInfo.Protocol}, message {e.Data}");
            if (message == default(IMessage))
            {
                Logger.Error("Desirializing error");
                return;
            }
            switch (type)
            {
            case MessageType.Command:
            {
                CommandMessageReceived?.Invoke(e.HostInfo, new EventCommandMessageArgs(message as CommandMessage));
                break;
            }

            case MessageType.Connect:
            {
                ConnectMessageReceived?.Invoke(e.HostInfo, new EventMessageConnectArgs(message as ConnectMessage));
                break;
            }

            case MessageType.Request:
            {
                RequestReceived?.Invoke(e.HostInfo, new EventRequestArgs(message as Request));
                break;
            }

            case MessageType.Telemetry:
            {
                TelemetryReceived?.Invoke(e.HostInfo, new EventTelemetryArgs(message as Telemetry));
                break;
            }

            case MessageType.Call:
            {
                CallReceived?.Invoke(e.HostInfo, new EventCallArgs(message as Call));
                break;
            }

            case MessageType.Order:
            {
                OrderReceived?.Invoke(e.HostInfo, new EventOrderArgs(message as Order));
                break;
            }

            //TODO ВСЕХ НЕВЕРНЫХ СЖЕЧЬ!.. Всмысле, в error
            case MessageType.Err:
            {
                ErrorMessageReceived?.Invoke(e.HostInfo, new EventErrArgs(message as ErrorMessage));
                break;
            }

            default:
                Logger.Error("Desirializing error unknow MessageType");
                return;
            }
        }
Пример #4
0
 public void OnSend(object sender, EventDataArg <string> e)
 {
 }