internal void HandleMessage(NavicoJson.IncomingDeviceList deviceList)
 {
     foreach (NavicoJson.IncomingDeviceList.Device device in deviceList.DeviceList)
     {
         m_DeviceList [device.NDP2kName] = device;
     }
 }
 private void OnSocketMessage(object sender, MessageEventArgs e)
 {
     lock (this)
     {
         JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
         if (e.Type == Opcode.Text)
         {
             String json = e.Data.ToString();
             if (json.StartsWith("{\"DataInfo\":"))
             {
                 NavicoJson.IncomingDataInfo info = javaScriptSerializer.Deserialize <NavicoJson.IncomingDataInfo>(json);
                 if (info.IsValid())
                 {
                     HandleMessage(info);
                 }
             }
             else if (json.StartsWith("{\"DeviceList\":"))
             {
                 NavicoJson.IncomingDeviceList deviceList = javaScriptSerializer.Deserialize <NavicoJson.IncomingDeviceList> (json);
                 if (deviceList.IsValid())
                 {
                     HandleMessage(deviceList);
                 }
             }
             else
             {
                 NavicoJson.IncomingData data = javaScriptSerializer.Deserialize <NavicoJson.IncomingData> (json);
                 if (data.IsValid())
                 {
                     HandleMessage(data);
                 }
                 else
                 {
                     NavicoJson.DList dl = javaScriptSerializer.Deserialize <NavicoJson.DList> (json);
                     if (dl.IsValid())
                     {
                         HandleMessage(dl);
                     }
                 }
             }
         }
     }
 }