void Socket_SocketConnectionEvent(UXLib.Sockets.SimpleClientSocket socket, Crestron.SimplSharp.CrestronSockets.SocketStatus status) { if (status == Crestron.SimplSharp.CrestronSockets.SocketStatus.SOCKET_STATUS_CONNECTED) { Channel.Subscribe(SoundWebChannelParamType.Mute); } }
void Socket_ReceivedPacketEvent(UXLib.Sockets.SimpleClientSocket socket, UXLib.Sockets.SimpleClientSocketReceiveEventArgs args) { string receivedString = Encoding.UTF7.GetString(args.ReceivedPacket, 1, args.ReceivedPacket.Length - 3); // string receivedString = new string(args.ReceivedPacket.Select(b => (char)b).ToArray()); string address = receivedString.Substring(1, 6); if (address == HiQAddress) { #if false var bytes = new byte[receivedString.Length]; for (int i = 0; i < receivedString.Length; i++) { bytes[i] = unchecked ((byte)receivedString[i]); } CrestronConsole.Print("Soundweb Rx (Len={0}): ", receivedString.Length); foreach (byte b in bytes) { if (b >= 32 && b <= 27) { CrestronConsole.Print("{0}", (char)b); } else { CrestronConsole.Print("\\x{0}", b.ToString("X2")); } } CrestronConsole.PrintLine(""); #endif try { if (receivedString.Length >= 13) { char[] c = receivedString.Substring(7, 2).ToCharArray(); int paramID = c[0] << 8 | c[1]; c = receivedString.Substring(9, 4).ToCharArray(); int value = c[0] << 24 | c[1] << 16 | c[2] << 8 | c[3]; OnReceive(paramID, value); } } catch (Exception e) { #if DEBUG CrestronConsole.PrintLine("Error in Soundweb Rx Event, {0}", e.Message); #endif ErrorLog.Error("Error in Soundweb Rx Event, {0}", e.Message); } } }