//Send request, user request id
        internal void send(string route, uint id, JsonObject msg)
        {
            if (this.state != ProtocolState.working)
            {
                return;
            }

            byte[] body = messageProtocol.encode(route, id, msg);

            send(PackageType.PKG_DATA, body);
        }
Exemplo n.º 2
0
        //Send request, user request id
        internal void send(string route, uint id, JsonObject msg)
        {
            if (this.state != ProtocolState.working)
            {
                return;
            }

            if (IsCrypto)
            {
                string jsonString = SimpleJson.SimpleJson.SerializeObject(msg);
                byte[] jsonBytes  = Encoding.UTF8.GetBytes(jsonString);


                //The hash to sign.
                byte[] hash;

                hash = _Sha256.ComputeHash(jsonBytes);

                //Set the hash algorithm to SHA256.
                _RSAFormatter.SetHashAlgorithm("SHA256");

                //Create a signature for HashValue and return it.
                byte[] SignedHash = _RSAFormatter.CreateSignature(hash);

                string signString = BitConverter.ToString(SignedHash).Replace("-", string.Empty);
                msg.Add("__crypto__", signString);
            }

            byte[] body = messageProtocol.encode(route, id, msg);

            send(PackageType.PKG_DATA, body);
        }