Exemplo n.º 1
0
        public static void sendBotAction(byte[] recipient, SpixiBotActionCode action, byte[] data, int channel = 0)
        {
            SpixiBotAction sba = new SpixiBotAction(action, data);

            // Prepare the message and send to the S2 nodes
            SpixiMessage spixi_message = new SpixiMessage(SpixiMessageCode.botAction, sba.getBytes(), channel);

            StreamMessage message = new StreamMessage();

            message.type           = StreamMessageCode.info;
            message.recipient      = recipient;
            message.sender         = IxianHandler.getWalletStorage().getPrimaryAddress();
            message.data           = spixi_message.getBytes();
            message.encryptionType = StreamMessageEncryptionCode.none;

            sendMessage(recipient, message);
        }
Exemplo n.º 2
0
        public SpixiBotAction(byte[] bytes)
        {
            try
            {
                using (MemoryStream m = new MemoryStream(bytes))
                {
                    using (BinaryReader reader = new BinaryReader(m))
                    {
                        int action = reader.ReadInt16();
                        this.action = (SpixiBotActionCode)action;

                        int data_length = reader.ReadInt32();
                        if (data_length > 0)
                        {
                            data = reader.ReadBytes(data_length);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Logging.error("Exception occured while trying to construct SpixiBotAction from bytes: " + e);
            }
        }
Exemplo n.º 3
0
 public SpixiBotAction(SpixiBotActionCode action, byte[] data)
 {
     this.action = action;
     this.data   = data;
 }