bool HandlePublishEvent <TEvent>(
            NetworkStream stream,
            TEvent @event,
            PapercutIPCommCommandType protocolCommandType) where TEvent : IEvent
        {
            string response = stream.ReadStringBuffered().Trim();

            if (response != "PAPERCUT")
            {
                return(false);
            }

            this._logger.Debug("Publishing {@Event} to Remote", @event);

            var eventJson = PapercutIPCommSerializer.ToJson(@event);

            stream.WriteLine(PapercutIPCommSerializer.ToJson(
                                 new PapercutIPCommRequest()
            {
                CommandType = protocolCommandType,
                Type        = @event.GetType(),
                ByteSize    = Encoding.UTF8.GetBytes(eventJson).Length
            }));

            response = stream.ReadStringBuffered().Trim();
            if (response == "ACK")
            {
                stream.WriteStr(eventJson);
            }

            return(true);
        }
Beispiel #2
0
        bool HandlePublishEvent <TEvent>(
            NetworkStream stream,
            TEvent @event,
            PapercutIPCommCommandType protocolCommandType) where TEvent : IEvent
        {
            string response = stream.ReadStringBuffered().Trim();

            if (response != AppConstants.ApplicationName.ToUpper())
            {
                return(false);
            }

            var eventJson = PapercutIPCommSerializer.ToJson(@event);

            stream.WriteLine(PapercutIPCommSerializer.ToJson(
                                 new PapercutIPCommRequest()
            {
                CommandType = protocolCommandType,
                Type        = @event.GetType(),
                ByteSize    = Encoding.UTF8.GetBytes(eventJson).Length
            }));

            response = stream.ReadStringBuffered().Trim();
            if (response == "ACK")
            {
                stream.WriteStr(eventJson);
            }

            return(true);
        }