GlowCommon.CommandServer.InternalSendMessage C# (CSharp) Method

InternalSendMessage() private method

private InternalSendMessage ( Command cmd, DataWriter writer ) : System.Threading.Tasks.Task
cmd GlowCommon.DataObjects.Command
writer Windows.Storage.Streams.DataWriter
return System.Threading.Tasks.Task
        private async Task InternalSendMessage(Command cmd, DataWriter writer)
        {
            if(cmd == null)
            {
                return;
            }

            if(cmd.Program == GlowPrograms.None)
            {
                throw new Exception("The program can't be none!");
            }

            // Serialize the cmd
            string cmdJson = Newtonsoft.Json.JsonConvert.SerializeObject(cmd);
            UInt32 stringSize = writer.MeasureString(cmdJson);
            writer.WriteUInt32(stringSize);
            writer.WriteString(cmdJson);
            await writer.StoreAsync();
        }
    }