El 10/02/11 04:53 a.m., Schmidt escribió:
> "Eduardo"<mm@mm.com> schrieb im Newsbeitrag
> news:iiv6ek$h67$1@speranza.aioe.org...
>
>> Larry, they are all common but just for that
>> instance of the object.
>> They are not common for all the instances of the object.
Hello Olaf
> Now I'm confused... ;-)
>
> You mean, that each client creates a separate
> Instance of this "global Class" for its own use?
No, in that case it wouldn't have some properties customizables, but
everything would be customized for the only client.
Neither the object would have to know what client is using something
(properties/methods) because it would be only one client for each instance.
> If that is the case, how many "differently behaving"
> clients are there (which are "consumers" of your
> global data-instance)?
>
> In either case - some small Code-Snippets would
> be great, which demonstrate the principle you
> currently have running (just one small Server-Class
> and two different Client-Consumers + 2 or 3 Properties
> which can demonstrate the problem you're currently
> fighting with).
It works this way:
There is another object that I call "server" in my program, so the other
object I've been talking, sometimes called also server (here in the
messages of the newsgroup), we will call it just "object".
When a client starts, it sends to the server an object request. The
server keeps a collection of object instances that are already loaded
and prepared (if a client asked for them before). If it's the first
request, it created a new instance of the "object".
Back to the client, it send the request for an object, and supply a
parameter that defines whith what, let's say... document will the object
instance be prepared.
So, all the objects instances differ that are prepared with different
documents.
Lets say ClientA sends a request for an Object providing data according
to Document1, the server looks if there is already an Object with
Document1 in its objects collection, if there is already one, it returns
a reference of that object instance to the client, and from now and
ahead the client will work directly with the Object.
The only other function of the server is to keep a maximun of 10 Object
instances in its collection, if this limit is exceeded, it looks for the
older object in the collection, and deletes it from the collection.
Back to ClientA, it asked for an Object/Document1, and it's already with
the object reference that the server provided.
If the Object instance was just created, it prepared all the basic data
with Document1 at the time it created.
But there are also other "customizable" data that would be too much to
prepare for every possibility that a client could ask for, so it works
this way: it expect for the client to say how it will need the data to
be customized. They are actually 4 long parameters that the client sends
to the object. The possibilities are not 4 * 2^32, but much less, but
still many.
But there is another thing to consider, still when theorically any
client can ask for any combination, in practice in the most of cases the
clients will ask for the same customization.
So, back to ClientA, it says it will work with &H1&-&H5&-&H3&-&H8&.
With this customization supplied, the Object must prepare the
customizable data according to this.
Then there is another client, ClientB, that also asks for an Document1
object to the server. The server already has in its collection a
reference to the instance that is already using ClientA, and returns to
ClientB a reference of the same instance of the Object that is already
using ClientA.
When ClientB receive the reference for Object/Document1, it specify the
customization to the Object, it is the same as Client1:
&H1&-&H5&-&H3&-&H8&, so the object has everythig prepared, ready to use
inmediately.
ClientC ask also for an Object/Document1 to the server, the server
returns the reference, ClientC specifies the custimization to the
Object, and it says &H2&-&H6&-&H3&-&H8&. There is a difference, so the
Object/Document1 instance now will have to prepare the customization
&H2&-&H6&-&H3&-&H8& that ClientC needs. The Object keeps this customized
data in a collection inside it.
At this time there is only one instance of the Object.
But ClintD asks for an Object/Document2 to the server, so the server
creates another instance of the Object, now with data of Document2, so
Object/Document2 prepares itself with the basic data...
And so on.
So... the Object needs to identify the clients in order to provide the
customized data.
Then when a client sends the customization information (4 longs), the
Object returns a ClientID to the client (a long), so in the future when
the client asks for some customized data, it must provide the ClientID
to the Object in order for the Object to know what to return.
The Object keeps a track of the clients and their customization (in a
client collection).
I didn't explain it better before because I thought it was quite complex
to explain all these details.
But the point is: why the client has to send the ClientID every time?
In the Client code:
YParameter = 111
Variable1 = Object.GiveMeDataCusmizableX(YParameter, _
ZParameter, ClientID)
YParameter = 112
Variable2 = Object.GiveMeDataCusmizableX(YParameter, _
ZParameter, ClientID)
Variable25 = Object.GiveMeDataCusmizableT(JParameter, _
ClientID)
It always has to supply the ClientID, that's what I don't like.
Does the object should not see what client is asking for something
without the client having to say "I'm client 4" every time it asks for
something? (Hence the title "Hey Class, this is me again, don't you see?")
That was the point. I'm pretty sure that that's not possible in VB6, but
I still wanted to discuss it.
Thanks.