Пример #1
0
        private void SendAuthMessage <T>(string secret, string token, protobuf.ws.WsRequestMetaData.WsRequestMsgType requestType, T message)
        {
            protobuf.ws.WsRequestMetaData meta;

            byte[] msg;

            using (MemoryStream msgStream = new MemoryStream())
            {
                ProtoBuf.Serializer.Serialize(msgStream, message);
                msg = msgStream.ToArray();
            }

            byte[] sign = ComputeHash(secret, msg);

            meta = new protobuf.ws.WsRequestMetaData
            {
                RequestType = requestType,
                Token       = token,
                Sign        = sign
            };

            protobuf.ws.WsRequest request = new protobuf.ws.WsRequest
            {
                Meta = meta,
                Msg  = msg
            };

            SendRequest(request);
        }
Пример #2
0
        private void WsClient_Subscribe <T>(string token, protobuf.ws.WsRequestMetaData.WsRequestMsgType requestType, T message)
        {
            protobuf.ws.WsRequestMetaData meta;

            byte[] msg;

            using (MemoryStream msgStream = new MemoryStream())
            {
                ProtoBuf.Serializer.Serialize(msgStream, message);
                msg = msgStream.ToArray();
            }

            meta = new protobuf.ws.WsRequestMetaData
            {
                RequestType = requestType,
                Token       = token
            };

            protobuf.ws.WsRequest request = new protobuf.ws.WsRequest
            {
                Meta = meta,
                Msg  = msg
            };

            SendRequest(request);
        }
Пример #3
0
        private void WsClient_Login(String key, String secret, int ttl)
        {
            byte[] msg;

            protobuf.ws.LoginRequest message = new protobuf.ws.LoginRequest
            {
                ExpireControl = new protobuf.ws.RequestExpired
                {
                    Now = (long)(DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalMilliseconds,
                    Ttl = ttl
                },
                ApiKey = key
            };

            using (MemoryStream msgStream = new MemoryStream())
            {
                ProtoBuf.Serializer.Serialize(msgStream, message);
                msg = msgStream.ToArray();
            }
            byte[] sign = ComputeHash(secret, msg);
            var    meta = new protobuf.ws.WsRequestMetaData
            {
                RequestType = protobuf.ws.WsRequestMetaData.WsRequestMsgType.Login,
                Token       = "Login request",
                Sign        = sign
            };

            protobuf.ws.WsRequest request = new protobuf.ws.WsRequest
            {
                Meta = meta,
                Msg  = msg
            };

            SendRequest(request);
        }