/// <summary> /// Handles the Connected event of the m_socketServer control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="VmcController.MceState.SocketEventArgs"/> instance containing the event data.</param> void SocketConnected(object sender, SocketEventArgs e) { StringBuilder sb = new StringBuilder(); Trace.TraceInformation("socketServer_Connected() Start"); Trace.Indent(); try { sb.AppendFormat( "204 Connected (Build: {0} Clients: {1})\r\n", VersionInfo, m_socketServer.Count); // Provide current state information to the client if (!string.IsNullOrEmpty(MediaState.Volume)) { sb.AppendFormat("Volume={0}\r\n", MediaState.Volume); } if (!string.IsNullOrEmpty(MediaState.Mute)) { sb.AppendFormat("Mute={0}\r\n", MediaState.Mute); } if (MediaState.Page != MEDIASTATUSPROPERTYTAG.Unknown) { sb.AppendFormat("{0}=True\r\n", MediaState.Page); } if (MediaState.MediaMode != MEDIASTATUSPROPERTYTAG.Unknown) { sb.AppendFormat("{0}=True\r\n", MediaState.MediaMode); } if (MediaState.PlayRate != MEDIASTATUSPROPERTYTAG.Unknown) { sb.AppendFormat("{0}=True\r\n", MediaState.PlayRate); } foreach (KeyValuePair <string, object> item in MediaState.MetaData) { sb.AppendFormat("{0}={1}\r\n", item.Key, item.Value); } // Send the data to the connected client Trace.TraceInformation(sb.ToString()); m_socketServer.SendMessage(sb.ToString(), e.TcpClient); } catch (Exception ex) { Trace.TraceError(ex.ToString()); } finally { Trace.Unindent(); Trace.TraceInformation("socketServer_Connected() End"); } }
private void SocketConnected(object sender, SocketEventArgs e) { var sb = new StringBuilder(); try { sb.AppendFormat( "204 Connected (Build: {0} Clients: {1})\r\n", GetVersionInfo, SocketServer.Count); // Provide current state information to the client if (!string.IsNullOrEmpty(MediaState.Volume)) { sb.AppendFormat("Volume={0}\r\n", MediaState.Volume); } if (!string.IsNullOrEmpty(MediaState.Mute)) { sb.AppendFormat("Mute={0}\r\n", MediaState.Mute); } if (MediaState.Page != MediaState.MEDIASTATUSPROPERTYTAG.Unknown) { sb.AppendFormat("{0}=True\r\n", MediaState.Page); } if (MediaState.MediaMode != MediaState.MEDIASTATUSPROPERTYTAG.Unknown) { sb.AppendFormat("{0}=True\r\n", MediaState.MediaMode); } if (MediaState.PlayRate != MediaState.MEDIASTATUSPROPERTYTAG.Unknown) { sb.AppendFormat("{0}=True\r\n", MediaState.PlayRate); } foreach (KeyValuePair<string, object> item in MediaState.MetaData) sb.AppendFormat("{0}={1}\r\n", item.Key, item.Value); // Send the data to the connected client Trace.TraceInformation(sb.ToString()); SocketServer.SendMessage(sb.ToString(), e.TcpClient); } catch (Exception ex) { Trace.TraceError(ex.ToString()); } finally { Trace.Unindent(); Trace.TraceInformation("socketServer_Connected() End"); } }