Getting data from the server to the client?

I have a server that does lots of stuff.  I have a client that can create remote objects on the server.  I need to get data from the server to the client but I am having problems.  I think there is an obvious solution but I am just not seeing it. 

Here is the scenario:  The sever starts up and makes a configuration list instance.  The server holds this list in its memory and often updates the data within this list.  The client eventually makes a remote object on the server.  Now I need that remote object to get information from the server’s instance.  But, I can’t figure out how to get the configuration list instance information from the server to the remote object the client created.

I can have the client’s remote object make a new list but it is not the same as the one the server as been updating.  I can have the client make calls to static functions on the server but these functions cannot access the server’s members.  I can’t seem to find a way to get the data from the server to the client.

 

Any help would be greatly appreciated!


Answer this question

Getting data from the server to the client?

  • Mike Woods

    Thank you for the reply,

    I think I should be a little more specific:  The server makes an instance of a local object and it updates and maintains this object.  The client then creates a remote object (on the server) that would like to get data from the server's local object.  These objects are in the same namespace but they do not have any relation between themselves.  eg. One object doesn't know that the other exists!

    I can call each other's static methods because they are in the same namespace but I can't use each other's member objects (which contain the data!!)

    In regards to the singleton, I looked into this a bit and it seems to be used to share data across clients and I only have 1 client..  I am planning on more research into this shortly.  I will let you all know what I come up with.

    I would love some input on this matter.  A link to an example or explanation would be great.

    Thank you

  • Gombly

    Hi .

    I think you can solve the problem without any server architecture changes simple by using the AppDomains SetData when you createing the object Foo and getData when accesing the object foo via the client activated object Bar

    Distef

     

     

     


  • Laurentiu Cristofor

    Hey,
    If you go back to remoting basics, there are multiple modes of remoting - Singlecall, Singleton.

    I assume you are using Singleclass objects. In this case, the members are not shared. But you might consider using singleton remoting which will allow you to share the members.

    Maybe it solves the problem. I am not too sure if it will because I did remoting long time back.

    Anyways, this is the line that you need to think on.

  • Roland Weiss

    Okay,

    I get your problem. Your server creates an object Foo that it uses to store some data.

    Your client requests an object Bar that needs to get access to the data in Foo.

    If the server only makes one Foo, you should use the Singleton Pattern for Foo that is (in VB.net)

    <serializable()>
    public class foo
      implements IFoo

    private shared m_Instance as foo=new foo()
    public shared readonly property instance as foo

    get

    return m_Instance

    end get

    end property
    private sub new()
    'do any initialization here
    end sub
    ' you can add any public methods or whatever here.

    end class

    The singleton pattern ensures that only one instance of the foo class will ever exist. That instance can be accessed with a Shared (static) property. Any class can get the one instance of the foo that needs it.

    Now your bar can say

    public shared method getFoo() as IFOO

    return Foo.getInstance()

    end method



  • Jomo Fisher MSFT

    These forums have been down for a day or two so I have posted this question on experts-exchange.com in the programming section under the title ".Net Remoting c# Getting data from server to client"

    This link might work http://www.experts-exchange.com/Programming/Q_21663804.html

    I would greatly appreciate any comments on this matter.

    Thanks

  • goelectric

    I am marking this as the answer but ivolved and distef01 have very interesting comments that I will look into. Thanks!

    I have a deadline approaching so I implemented a not-so-elegant solution.  Basically I am chaining events between the client and the server and sending the data as an arguement to the events.  This allows communication but I can't use ref params or return values,  but I guess it is "loosely coupled" which is good.  The lack of return values is a bummer because I have to send a message, one way, which I handle and then trigger another one way message to be sent back.

    This is how I did it:  Server creates object A which is implemented in library.  Client creates object A which is implemented in library.  Client creates object B which inherits from a different object (C) implemented in library.  Client ties event from object A to delegate in object C.  The event from A is handled by a function in C which calls another function in C which is abstract, BUT implemented on the client in object B.

    Soooo, Server fires event in A which is caught by C which then gets data to B.  It is a little tricky to code but it works fine.  Now, you have to code the whole thing in reverse to send data back.

  • Getting data from the server to the client?