Ejemplo n.º 1
0
        public override void readAsBinary(BinaryDataInput input)
        {
            version = input.readCompressedInt();
            if (version > Message.CURRENT_PROTOCOL_VERSION || version < Message.REQUIRED_PROTOCOL_VERSION)
            {
                throw new Exception("Protocol mismatch.  Driver Protocol Version: " + version + ".  Service expects: " + Message.REQUIRED_PROTOCOL_VERSION + " up to "
                                    + Message.CURRENT_PROTOCOL_VERSION + ".");
            }
            dataSource        = input.readString();
            userID            = input.readString();
            password          = input.readString();
            dataStoreUserID   = input.readString();
            dataStorePassword = input.readString();
            clientID          = input.readString();
            timezone          = input.readString();
            timezoneOffset    = input.readString();
            flags             = input.readCompressedInt();

            if ((flags & EXTENDED_PROPERTIES) != 0)
            {
                extendedProperties = input.readString();
            }

            // Vendor ID branding
            if (version >= 8)
            {
                vendorID = input.readString();
            }
        }
Ejemplo n.º 2
0
        public BinaryDataInput submitPostRequest(string path, bool allowRetry)
        {
            post.GetAsync(path);
            try
            {
                messageWriter.close();
            }
            catch (Exception ioException)
            {
                throw;//.ioException(ioException, false);
            }
            //setSessionToken(post);
            //setConnectorID(post);

            int retryCount = 0;

            while (true)
            {
                try
                {
                    byte[] requestbuffer = streamBuffer.getBuffer();
                    int    requestlength = streamBuffer.getSize();

                    //if (logger.isloggable(level.fine))
                    //{
                    //    string sessiontoken = implconnection.sessiontoken == null ? "" : implconnection.sessiontoken;
                    //    //logger.logp(level.fine, logger.getname(), implconnection.sessiontoken, "post - content length:  " + integer.tostring(requestlength) + " sessiontoken: " + sessiontoken
                    //    +" path: " + path);
                    //}

                    //if (logger.isloggable(level.finest))
                    //{
                    //    logbytes(requestbuffer, requestlength, true);
                    //}
                    string        res    = Encoding.UTF8.GetString(requestbuffer);
                    StringContent entity = new StringContent(res);
                    //post.(entity);

                    //HttpResponse response = implConnection.getHttpClient().execute(implConnection.target, post);
                    Task <HttpResponseMessage> response = implConnection.getHttpClient().PostAsync(DDCloudImplConnection.Url, entity);

                    BinaryDataInput bufferResponse = BufferResponse(response);

                    return(bufferResponse);
                }
                catch (IOException ioException)
                {
                    if (allowRetry && retryCount < implConnection.wsRetryCount)
                    {
                        // implConnection.logger.config("Detected timeout. Retrying operation.  Retry count: " + retryCount);
                    }
                    else
                    {
                        throw;// implConnection.ioException(ioException, false);
                    }
                    ++retryCount;
                }
            }
        }
Ejemplo n.º 3
0
        private void AssertReadWrite <T>(
            T key,
            Writer <T> write,
            Reader <T> read)
            where T : IntSeqKey
        {
            byte[] bytes;

            using (var memoryStream = new MemoryStream()) {
                using (var dataOutput = new BinaryDataOutput(memoryStream)) {
                    write.Invoke(dataOutput, key);
                    memoryStream.Flush();
                    memoryStream.Close();
                    bytes = memoryStream.ToArray();
                }
            }

            using (var memoryStream = new MemoryStream(bytes)) {
                using (var dataInput = new BinaryDataInput(memoryStream)) {
                    IntSeqKey deserialized = read.Invoke(dataInput);
                    Assert.AreEqual(key, deserialized);
                }
            }
        }
Ejemplo n.º 4
0
 public abstract void readAsBinary(BinaryDataInput input);
Ejemplo n.º 5
0
        public object Decode(Remoting.Channel ch, Packet packet)
        {
            BinaryDataInput input = new BinaryDataInput(packet.Content);
            int             type  = packet.Header.Type;

            if (type == Packet.FLAG_HANDSNAKE)
            {
                HandSnakeResp resp = new HandSnakeResp();
                resp.DeserializeTo(input);
                return(resp);
            }
            else if (type == Packet.FLAG_HEARTBEAT)
            {
                HeartBeatResp req = new HeartBeatResp();
                req.DeserializeTo(input);
                return(req);
            }
            else if (type == Packet.FLAG_KICK)
            {
                KickClient kick = new KickClient();
                kick.DeserializeTo(input);
                return(kick);
            }
            else if (type == Packet.FLAG_MESSAGE)
            {
                int  mid   = input.ReadInt();
                byte mType = input.ReadByte();
                if (mType == AbstractMessage.TYPE_RESPONSE)
                {
                    Response response = new Response(mid);
                    response.Sequence  = input.ReadInt();
                    response.ErrorCode = input.ReadInt();
                    response.ErrorDes  = input.ReadUTF();
                    if (response.ErrorCode == Response.OK)
                    {
                        ResponseArg respArg = ResponseMappingInfo.Instance.CreateResponseMapping(mid) as ResponseArg;
                        if (respArg == null)
                        {
                            log.Error("Failed to handle response message,Cause : Cloud not found response mapper id :" + mid);
                        }
                        respArg.DeserializeTo(input);
                        response.Content = respArg;
                    }
                    return(response);
                }
                else if (mType == AbstractMessage.TYPE_PUSH)
                {
                    Push push = new Push(mid);
                    push.Identity = input.ReadInt();
                    ResponseArg respArg = ResponseMappingInfo.Instance.CreateResponseMapping(mid) as ResponseArg;
                    if (respArg == null)
                    {
                        log.Error("Failed to handle push message,Cause : Cloud not found response mapper id :" + mid);
                    }
                    respArg.DeserializeTo(input);
                    push.Content = respArg;
                    return(push);
                }
                else if (mType == AbstractMessage.TYPE_BROADCAST)
                {
                    BroadCast broadcast = new BroadCast(mid);
                    broadcast.Identity = input.ReadInt();
                    ResponseArg respArg = ResponseMappingInfo.Instance.CreateResponseMapping(mid) as ResponseArg;
                    if (respArg == null)
                    {
                        log.Error("Failed to handle broadcast message,Cause : Cloud not found response mapper id :" + mid);
                    }
                    respArg.DeserializeTo(input);
                    broadcast.Content = respArg;
                    return(broadcast);
                }
            }
            return(null);
        }