"serverBlob" content RRS feed

  • Question

  • Hello again.One more question about ctp 4. (I working with "ListService"  example and "iphone" example from CTP 4 samples.)

    Iphone and server synchronize one table. Rows in this table have different size. I know approximate   size of each row in that table .

    But before synchronization iphone and server i need to get on iphone approximate size of server updates packet and show this size for iphone user.

    And user can start synxhronizing or cancel it.

    How i can calculate aproximate size of server update data for current synchronization of iphone in "iphone sample"?

    i can create stored procedure based on sp_selectchanges where i can calculate aproximate size of  each row and return that on iphone

    but i don't know how i can get values of parameters  sp_selectchanges(or base values for calculate these parameters) on iphone before sync .


    I noticed that iphone and listService send each other some messages like that

    "d":{"__sync":{"moreChangesAvailable":false,"serverBlob":"AAEAAAD\/...  "},"results":[...

     i think  that inside "serverBlob" strore information about last sync session parameters and i can use that for exec my sp for calculation server updates packet size. Am I right? Or may be there is another way for gettin on iphone server update size before synchronization?

    Wednesday, April 13, 2011 9:48 AM

All replies

  • The serverBlob does not store statistics from last sync session, so that approach would not work for you. There is a property called SyncStatistics but that's available on Microsoft platforms on the client side, not on the iPhone, and that property is populated after the sync is completed, not before. It is hard for Sync technology to predict how many changes are beind sent since another client could be simultaneously changing items on the server.

    There can be a work around, which I haven't tried and would also require some work: Since on the server side is a WCF service, you could add another method on the service and call this method to determine amount of data to be downloaded from the server. Ofcourse, this method needs to be called after you initiate the download. On the server side, there are business logic extensibility points, called interceptors, which you can use to count the size or the number of rows in a download batch. Here's the link for this: http://msdn.microsoft.com/en-us/library/gg299068(v=sql.110).aspx


    Hope this helps.





    • Proposed as answer by Sameer[MSFT] Tuesday, April 19, 2011 6:15 PM
    • Unproposed as answer by Sameer[MSFT] Tuesday, April 19, 2011 6:15 PM
    Wednesday, April 13, 2011 5:33 PM
  • Thanks a lot, Sameer! It's was very helpfull.

    How i realized calculation of server update packet size(may be it will be helpfull for someone else):

    i sync table with big blob field between iphone and server.

    On iphone i set special header if i want to get size of server update packet.

    On server i catch [SyncResponseInterceptor("DefaultScope", SyncOperations.Download)]
            public void Download_Response(SyncOperationContext context)

    and see context.RequestHeaders. If i find my special header i get (context as SyncDownloadResponseOperationContext).OutgoingChanges[0] and modify server responce rows collection. I replace big blob fields on their byte lenght values. And on iphone  i can read blobs lenght and calculate aproximate size of  next server update packet.

    if i can't find my special header i don't modify server responce and iphone gets normal server update packet.





    • Proposed as answer by Sameer[MSFT] Tuesday, April 19, 2011 6:13 PM
    • Unproposed as answer by Sameer[MSFT] Tuesday, April 19, 2011 6:13 PM
    Thursday, April 14, 2011 11:11 AM
  • Yes, this the approach I was referring to and glad it works for you.

    I would just caution that you test that you are syncing all the changes in both directions after you have intercepted and sent back the size information.



    • Proposed as answer by Sameer[MSFT] Tuesday, April 19, 2011 6:15 PM
    Tuesday, April 19, 2011 6:15 PM