Example #1
0
        private static void VerifyScmpAttribute(Shared.Scmp.IScmp scmp, string attributeAsString)
        {
            var attributes =
                scmp.GetType().GetCustomAttributes(true);

            var bHasAttr =
                attributes.Cast <Attribute>().Any(
                    attr => string.Compare(
                        attr.ToString(),
                        attributeAsString,
                        true) == 0);

            if (bHasAttr)
            {
                return;
            }

            SledOutDevice.OutLine(
                SledMessageType.Warning,
                "[SledDebugService] I just packed or unpacked something " +
                "[{0}] that didn't have the right attribute [{1}]!",
                scmp.GetType().Name, attributeAsString);

            if (System.Diagnostics.Debugger.IsAttached)
            {
                System.Diagnostics.Debugger.Break();
            }
        }
Example #2
0
        /// <summary>
        /// Send a Scmp structure
        /// </summary>
        /// <param name="scmp">Data to send</param>
        /// <returns>Length of data sent</returns>
        public int SendScmp(Shared.Scmp.IScmp scmp)
        {
            // This check significantly slows things down so leave it
            // off unless actively adding/testing new protocol messages
            //VerifyScmpAttribute(scmp, "Sce.Sled.Shared.Scmp.ScmpSend");

            if ((m_netPlugin != null) && m_netPlugin.IsConnected)
            {
                var buffer = scmp.Pack();

                LogScmp(ScmpLogType.Send, buffer);

                return(m_netPlugin.Send(buffer, buffer.Length));
            }

            return(-1);
        }