If you run the application you will be present with a log in screen (below), where you just enter a unique name - the name is not validated here - but that is something that can be easy implemented - all we are after is a unique name that can be later used to indicate who pushed a an update from the client on the GUI.
...
...
Code Explanation
Client (Silverlight) Code
namespace Client
{
[ScriptableType]
public partial class ClientPage : Page
{
private ObservableCollection<ThermoTemps> thermoCollection;
public ClientPage()
{
InitializeComponent();
ThermoCollection = new ObservableCollection<ThermoTemps>();
this.gridThermo.ItemsSource = ThermoCollection;
HtmlPage.RegisterScriptableObject("myObject", this);
}
private void button1_Click(object sender, RoutedEventArgs e)
{
HtmlPage.Window.Invoke("sendMessage", this.txtFan.Text);
}
[ScriptableMember]
public void UpdateText(string result)
{
try
{
string jsonString = result.Substring(result.IndexOf('{'));
ThermoTemps myDeserializedObj = new ThermoTemps();
DataContractJsonSerializer dataContractJsonSerializer = new DataContractJsonSerializer(typeof(ThermoTemps));
MemoryStream memoryStream = new MemoryStream(Encoding.Unicode.GetBytes(jsonString));
myDeserializedObj = (ThermoTemps)dataContractJsonSerializer.ReadObject(memoryStream);
ThermoCollection.Add(myDeserializedObj);
Read more: Codeproject
QR: