Exemplo n.º 1
0
        bool HandlePublishEvent <TEvent>(
            NetworkStream stream,
            TEvent @event,
            ProtocolCommandType protocolCommandType) where TEvent : IEvent
        {
            string response = stream.ReadString().Trim();

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

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

            var eventJson = @event.ToJson();

            stream.WriteLine(
                new PapercutProtocolRequest
            {
                CommandType = protocolCommandType,
                Type        = @event.GetType(),
                ByteSize    = eventJson.Length
            }.ToJson());

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

            return(true);
        }
Exemplo n.º 2
0
 // COMMANDS
 private void IssueCommand(ProtocolCommandType command)
 {
     _ble.WriteCharacteristic(ProtocolServices._characteristicCommand, command.Serialize());
 }