Boost logo

Boost Users :

Subject: Re: [Boost-users] BEGINNER - separate array for each client
From: U.Mutlu (for-gmane_at_[hidden])
Date: 2011-11-27 16:01:54


wempwer_at_[hidden] wrote, On 2011-11-25 20:37:
> I'm learning boost. I'd like to write a simple application that allows user
> to store data on server. User can insert new data using PUT command followed
> by ID number and data value, and retrieve data using GET command followed by ID.
> User requests are processed in analyze_user_request function and are subsequently
> written to or read from array. The thing is that I want every client to refer
> to his own array. That means that if one client saves something under particular ID
> this data is visible only to him. I wonder, how can I associate array with different
> clients, and create a new array when a new client connects? I tried encapsulating
> private data in class, but it doesn't seem to work

That's relatively easy. Just store the user data somewhere
(array, container, database, file, ...) with a unique key per user,
and with each request the client must send his unique key.
Then with that key you try to find his data,
if not found then, depending on your own "protocol" or API,
add a new user to your storage area or return an error etc...

In your case I would recommend to use a set<YourStructType>
since a set accepts only unique keys. A map would work too,
but I swear on set :-)


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net