locked
MSRS and SIlverlight RRS feed

  • Question

  • I have run the Silverlight viewer sample for the Xbox controller, but I am having a problem understanding how the Silverlight app is geting the data.

    1) Is the statment in the help file "A viewer for an Xbox Controller is also available that was written as an example of using Silverlight, but it does not currently have a documentation page." still correct? Is there any documention you can point me to?

    2) The specific piece of code that I would most like to understand is Page.xaml.cs. More specifically lines 30-56:

    ==========================================================================================

     

    public Page()

    {

    InitializeComponent();

     

    try

    {

    webServiceUri =

    HtmlPage.Document.DocumentUri;

    Server_Uri.Text =

    "Connecting ...";

    Dispatcher.BeginInvoke(RefreshControllerState);

    }

     

    catch (Exception e)

    {

    Server_Uri.Text =

    "Inner ERROR! :" + e.GetType().Name + " " + e.Message;

    }

    }

     

    void RefreshControllerState()

    {

    Server_Uri.Text =

    "Connected";

     

    if (webServiceUri != null)

    {

     

    // make the uri unique so that it's not grabbed from IE cache

     

    Uri uniqueUri = new Uri(webServiceUri.AbsoluteUri + @"/" + DateTime.Now.Ticks.ToString());

     

    HttpWebRequest _request = (HttpWebRequest)WebRequest.Create(uniqueUri);

    _request.Method =

    "get";

    _request.BeginGetResponse(

    new AsyncCallback(ControllerResponseCallback), _request);

    }

    }

    ==========================================================================================

    How are webServiceUri & uniqueUri built and used?

    Thursday, April 16, 2009 3:37 AM

Answers

  • Hi John,

    As you can see on top of the code you pasted in webServiceUri is set to:

    webServiceUri = HtmlPage.Document.DocumentUri;

    The uniqueUri is also in that code:

    Uri
    uniqueUri = new Uri(webServiceUri.AbsoluteUri + @"/" + DateTime
    .Now.Ticks.ToString()); 

    Which is used to get the state of the service and display it.

    I'm not sure if this answers you quesion, play around with the code and feel free to ask for some more details or specifics.

    Pavel
    Wednesday, May 6, 2009 8:59 PM